1 /****************************************************************************
3 ** Copyright (C) 2006 Trolltech AS. All rights reserved.
5 ** This file is part of the documentation of Qt. It was originally
6 ** published as part of Qt Quarterly.
8 ** This file may be used under the terms of the GNU General Public License
9 ** version 2.0 as published by the Free Software Foundation or under the
10 ** terms of the Qt Commercial License Agreement. The respective license
11 ** texts for these are provided with the open source and commercial
14 ** If you are unsure which license is appropriate for your use, please
15 ** review the following information:
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 ** sales department at sales@trolltech.com.
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 ****************************************************************************/
26 #include "faderwidget.h"
28 FaderWidget::FaderWidget(QWidget *parent)
32 startColor = endColor = parent->palette().window().color();
34 startColor = endColor = Qt::white;
41 timer = new QTimer(this);
42 connect(timer, SIGNAL(timeout()), this, SLOT(update()));
44 setAttribute(Qt::WA_DeleteOnClose);
45 resize(parent->size());
48 void FaderWidget::start()
56 void FaderWidget::startFadeOut()
64 void FaderWidget::paintEvent(QPaintEvent * /* event */)
66 QPainter painter(this);
67 QColor semiTransparentColor = startColor;
68 semiTransparentColor.setAlpha(currentAlpha);
69 painter.fillRect(rect(), semiTransparentColor);
72 currentAlpha += 255 * timer->interval() / duration;
73 if (currentAlpha >= 255) {
75 emit done( (QWidget *)parent() );
79 currentAlpha -= 255 * timer->interval() / duration;
80 if (currentAlpha <= 0) {
82 emit done( (QWidget *)parent() );