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 ****************************************************************************/
20 #include <QMouseEvent>
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
)
58 void PreviewDlg::changeEvent(QEvent
*e
)
60 if(e
->type() == QEvent::LanguageChange
) {
61 ui
.retranslateUi(this);
63 QWidget::changeEvent(e
);
67 PreviewLabel::PreviewLabel(QWidget
* parent
, Qt::WindowFlags f
)
70 this->setMouseTracking(true);
72 preview
= new PreviewDlg(parent
);
74 hovertimer
.setInterval(1500); // wait for 1.5 seconds before showing the Fullsize Preview
75 hovertimer
.setSingleShot(true);
76 connect(&hovertimer
,SIGNAL(timeout ()),this,SLOT(timeout()));
79 void PreviewLabel::mouseMoveEvent(QMouseEvent
* event
)
82 mousex
= event
->globalX();
83 mousey
= event
->globalY();
85 void PreviewLabel::enterEvent(QEvent
* event
)
90 void PreviewLabel::leaveEvent(QEvent
* event
)
96 void PreviewLabel::timeout()
98 preview
->move(mousex
-(preview
->width()/2) ,mousey
-(preview
->height()/2));
99 preview
->setVisible(true);
102 void PreviewLabel::setPixmap(QPixmap p
)
104 // set the image for the Fullsize Preview
105 preview
->setPixmap(p
);
107 //scale the image for use in the label
109 img
.setHeight(this->height());
110 img
.setWidth(this->width());
112 q
= p
.scaled(img
, Qt::KeepAspectRatio
, Qt::SmoothTransformation
);
113 this->setScaledContents(false);
114 QLabel::setPixmap(q
);
117 void PreviewLabel::setText(QString text
)
119 QLabel::setText(text
);
120 preview
->setText(text
);