set missing keywords property.
[Rockbox.git] / rbutil / rbutilqt / preview.cpp
blob918fa10aa19a6abd8b719441d4bf4abe6d179153
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id$
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 ****************************************************************************/
20 #include <QtGui>
22 #include "preview.h"
24 PreviewDlg::PreviewDlg(QWidget *parent) : QDialog(parent)
26 ui.setupUi(this);
27 this->setModal(true);
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)
47 this->close();
50 void PreviewDlg::leaveEvent(QEvent * event)
52 this->close();
55 PreviewLabel::PreviewLabel(QWidget * parent, Qt::WindowFlags f)
56 :QLabel(parent,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)
69 hovertimer.start();
70 mousex = event->globalX();
71 mousey = event->globalY();
73 void PreviewLabel::enterEvent(QEvent * event)
75 hovertimer.start();
77 void PreviewLabel::leaveEvent(QEvent * event)
79 hovertimer.stop();
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
94 QSize img;
95 img.setHeight(this->height());
96 img.setWidth(this->width());
97 QPixmap q;
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);