Add support for the Creative ZEN and renew the way firmwares are
[Rockbox.git] / rbutil / rbutilqt / preview.cpp
blobbe1430c6a113c62f26b51383c8b683913d342731
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 (void) event;
48 this->close();
51 void PreviewDlg::leaveEvent(QEvent * event)
53 (void) event;
54 this->close();
57 PreviewLabel::PreviewLabel(QWidget * parent, Qt::WindowFlags f)
58 :QLabel(parent,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)
71 hovertimer.start();
72 mousex = event->globalX();
73 mousey = event->globalY();
75 void PreviewLabel::enterEvent(QEvent * event)
77 (void) event;
78 hovertimer.start();
80 void PreviewLabel::leaveEvent(QEvent * event)
82 (void) event;
83 hovertimer.stop();
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
98 QSize img;
99 img.setHeight(this->height());
100 img.setWidth(this->width());
101 QPixmap q;
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);