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
)
51 void PreviewDlg::leaveEvent(QEvent
* event
)
57 PreviewLabel::PreviewLabel(QWidget
* parent
, Qt::WindowFlags f
)
60 this->setMouseTracking(true);
62 preview
= new PreviewDlg(parent
);
64 hovertimer
.setInterval(1500); // wait for 1.5 seconds before showing the Fullsize Preview
65 hovertimer
.setSingleShot(true);
66 connect(&hovertimer
,SIGNAL(timeout ()),this,SLOT(timeout()));
69 void PreviewLabel::mouseMoveEvent(QMouseEvent
* event
)
72 mousex
= event
->globalX();
73 mousey
= event
->globalY();
75 void PreviewLabel::enterEvent(QEvent
* event
)
80 void PreviewLabel::leaveEvent(QEvent
* event
)
86 void PreviewLabel::timeout()
88 preview
->move(mousex
-(preview
->width()/2) ,mousey
-(preview
->height()/2));
89 preview
->setVisible(true);
92 void PreviewLabel::setPixmap(QPixmap p
)
94 // set the image for the Fullsize Preview
95 preview
->setPixmap(p
);
97 //scale the image for use in the label
99 img
.setHeight(this->height());
100 img
.setWidth(this->width());
102 q
= p
.scaled(img
, Qt::KeepAspectRatio
, Qt::SmoothTransformation
);
103 this->setScaledContents(false);
104 QLabel::setPixmap(q
);
107 void PreviewLabel::setText(QString text
)
109 QLabel::setText(text
);
110 preview
->setText(text
);