1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Wenger
11 * All files in this archive are subject to the GNU General Public License.
12 * See the file COPYING in the source tree root for full license agreement.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
23 PreviewDlg::PreviewDlg(QWidget
*parent
) : QDialog(parent
)
27 this->setMouseTracking(true);
28 this->setWindowFlags(Qt::Dialog
| Qt::FramelessWindowHint
);
32 void PreviewDlg::setText(QString text
)
34 ui
.themePreview
->setText(text
);
37 void PreviewDlg::setPixmap(QPixmap p
)
39 ui
.themePreview
->setFixedSize(p
.size());
40 this->resize(QSize(10,10));
41 ui
.themePreview
->setPixmap(p
);
44 void PreviewDlg::mouseMoveEvent(QMouseEvent
* event
)
50 void PreviewDlg::leaveEvent(QEvent
* event
)
57 void PreviewDlg::changeEvent(QEvent
*e
)
59 if(e
->type() == QEvent::LanguageChange
) {
60 ui
.retranslateUi(this);
62 QWidget::changeEvent(e
);
66 PreviewLabel::PreviewLabel(QWidget
* parent
, Qt::WindowFlags f
)
69 this->setMouseTracking(true);
71 preview
= new PreviewDlg(parent
);
73 hovertimer
.setInterval(1500); // wait for 1.5 seconds before showing the Fullsize Preview
74 hovertimer
.setSingleShot(true);
75 connect(&hovertimer
,SIGNAL(timeout ()),this,SLOT(timeout()));
78 void PreviewLabel::mouseMoveEvent(QMouseEvent
* event
)
81 mousex
= event
->globalX();
82 mousey
= event
->globalY();
84 void PreviewLabel::enterEvent(QEvent
* event
)
89 void PreviewLabel::leaveEvent(QEvent
* event
)
95 void PreviewLabel::timeout()
97 preview
->move(mousex
-(preview
->width()/2) ,mousey
-(preview
->height()/2));
98 preview
->setVisible(true);
101 void PreviewLabel::setPixmap(QPixmap p
)
103 // set the image for the Fullsize Preview
104 preview
->setPixmap(p
);
106 //scale the image for use in the label
108 img
.setHeight(this->height());
109 img
.setWidth(this->width());
111 q
= p
.scaled(img
, Qt::KeepAspectRatio
, Qt::SmoothTransformation
);
112 this->setScaledContents(false);
113 QLabel::setPixmap(q
);
116 void PreviewLabel::setText(QString text
)
118 QLabel::setText(text
);
119 preview
->setText(text
);