1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Wenger
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
24 PreviewDlg::PreviewDlg(QWidget
*parent
) : QDialog(parent
)
28 this->setMouseTracking(true);
29 this->setWindowFlags(Qt::Dialog
| Qt::FramelessWindowHint
);
33 void PreviewDlg::setText(QString text
)
35 ui
.themePreview
->setText(text
);
38 void PreviewDlg::setPixmap(QPixmap p
)
40 ui
.themePreview
->setFixedSize(p
.size());
41 this->resize(QSize(10,10));
42 ui
.themePreview
->setPixmap(p
);
45 void PreviewDlg::mouseMoveEvent(QMouseEvent
* event
)
50 void PreviewDlg::leaveEvent(QEvent
* event
)
55 PreviewLabel::PreviewLabel(QWidget
* parent
, Qt::WindowFlags f
)
58 this->setMouseTracking(true);
60 preview
= new PreviewDlg(parent
);
62 hovertimer
.setInterval(1500); // wait for 1.5 seconds before showing the Fullsize Preview
63 hovertimer
.setSingleShot(true);
64 connect(&hovertimer
,SIGNAL(timeout ()),this,SLOT(timeout()));
67 void PreviewLabel::mouseMoveEvent(QMouseEvent
* event
)
70 mousex
= event
->globalX();
71 mousey
= event
->globalY();
73 void PreviewLabel::enterEvent(QEvent
* event
)
77 void PreviewLabel::leaveEvent(QEvent
* event
)
82 void PreviewLabel::timeout()
84 preview
->move(mousex
-(preview
->width()/2) ,mousey
-(preview
->height()/2));
85 preview
->setVisible(true);
88 void PreviewLabel::setPixmap(QPixmap p
)
90 // set the image for the Fullsize Preview
91 preview
->setPixmap(p
);
93 //scale the image for use in the label
95 img
.setHeight(this->height());
96 img
.setWidth(this->width());
98 q
= p
.scaled(img
, Qt::KeepAspectRatio
, Qt::SmoothTransformation
);
99 this->setScaledContents(false);
100 QLabel::setPixmap(q
);
103 void PreviewLabel::setText(QString text
)
105 QLabel::setText(text
);
106 preview
->setText(text
);