• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

kfadewidgeteffect.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
00003 
00004     This program is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) version 3.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 
00019 */
00020 
00021 #include "kfadewidgeteffect.h"
00022 #include "kfadewidgeteffect_p.h"
00023 #include <QtCore/QEvent>
00024 #include <QtGui/QPainter>
00025 
00026 #include <kglobalsettings.h>
00027 
00028 KFadeWidgetEffectPrivate::KFadeWidgetEffectPrivate(QWidget *_destWidget)
00029     : destWidget(_destWidget), disabled(false)
00030 {
00031 }
00032 
00033 KFadeWidgetEffect::KFadeWidgetEffect(QWidget *destWidget)
00034     : QWidget(destWidget ? destWidget->parentWidget() : 0),
00035     d_ptr(new KFadeWidgetEffectPrivate(destWidget))
00036 {
00037     Q_D(KFadeWidgetEffect);
00038     d->q_ptr = this;
00039     Q_ASSERT(destWidget && destWidget->parentWidget());
00040     if (!destWidget || !destWidget->parentWidget() || !destWidget->isVisible() ||
00041         !(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) {
00042         d->disabled = true;
00043         hide();
00044         return;
00045     }
00046     setGeometry(QRect(destWidget->mapTo(parentWidget(), QPoint(0, 0)), destWidget->size()));
00047     d->oldPixmap = QPixmap::grabWidget(destWidget);
00048     d->timeLine.setFrameRange(0, 255);
00049     connect(&d->timeLine, SIGNAL(finished()), SLOT(finished()));
00050     connect(&d->timeLine, SIGNAL(frameChanged(int)), SLOT(repaint()));
00051     show();
00052 }
00053 
00054 KFadeWidgetEffect::~KFadeWidgetEffect()
00055 {
00056     delete d_ptr;
00057 }
00058 
00059 void KFadeWidgetEffectPrivate::finished()
00060 {
00061     Q_Q(KFadeWidgetEffect);
00062     destWidget->setUpdatesEnabled(false);
00063     q->hide();
00064     q->deleteLater();
00065     destWidget->setUpdatesEnabled(true);
00066 }
00067 
00068 void KFadeWidgetEffect::start(int duration)
00069 {
00070     Q_D(KFadeWidgetEffect);
00071     if (d->disabled) {
00072         deleteLater();
00073         return;
00074     }
00075     d->timeLine.setDuration(duration);
00076     d->timeLine.start();
00077 }
00078 
00079 void KFadeWidgetEffect::paintEvent(QPaintEvent *)
00080 {
00081     Q_D(KFadeWidgetEffect);
00082     QPainter p(this);
00083     p.setOpacity(1.0 - d->timeLine.currentValue());
00084     p.drawPixmap(rect(), d->oldPixmap);
00085 }
00086 
00087 #include "moc_kfadewidgeteffect.cpp"

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal