diff --git a/includes/CMakeLists.txt b/includes/CMakeLists.txt index 9d13614e..c2b9ae2c 100644 --- a/includes/CMakeLists.txt +++ b/includes/CMakeLists.txt @@ -118,7 +118,6 @@ install( KEditToolBar KEncodingFileDialog KExtendableItemDelegate - KFadeWidgetEffect KFile KFileDialog KFileFilterCombo diff --git a/includes/KFadeWidgetEffect b/includes/KFadeWidgetEffect deleted file mode 100644 index 707d5160..00000000 --- a/includes/KFadeWidgetEffect +++ /dev/null @@ -1 +0,0 @@ -#include "../kfadewidgeteffect.h" diff --git a/kdeui/CMakeLists.txt b/kdeui/CMakeLists.txt index 90c8db7c..cddda28b 100644 --- a/kdeui/CMakeLists.txt +++ b/kdeui/CMakeLists.txt @@ -208,7 +208,6 @@ set(kdeui_LIB_SRCS widgets/kdatetimewidget.cpp widgets/kdatewidget.cpp widgets/keditlistwidget.cpp - widgets/kfadewidgeteffect.cpp widgets/khbox.cpp widgets/khelpmenu.cpp widgets/khistorycombobox.cpp @@ -528,7 +527,6 @@ install( widgets/kdatewidget.h widgets/kdialogbuttonbox.h widgets/keditlistwidget.h - widgets/kfadewidgeteffect.h widgets/khbox.h widgets/khelpmenu.h widgets/khistorycombobox.h diff --git a/kdeui/tests/CMakeLists.txt b/kdeui/tests/CMakeLists.txt index 0b04532c..e50dda31 100644 --- a/kdeui/tests/CMakeLists.txt +++ b/kdeui/tests/CMakeLists.txt @@ -38,7 +38,6 @@ KDEUI_UNIT_TESTS( kcompletioncoretest kconfigskeletontest kdualactiontest - kfadewidgeteffecttest kfindtest kglobalsettingstest kmainwindow_unittest diff --git a/kdeui/tests/kfadewidgeteffecttest.cpp b/kdeui/tests/kfadewidgeteffecttest.cpp deleted file mode 100644 index a4ef0b86..00000000 --- a/kdeui/tests/kfadewidgeteffecttest.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. - -*/ - -#include -#include -#include - -class KFadeWidgetEffectTest : public QObject -{ - Q_OBJECT - private slots: - void initTestCase(); - void createEffect(); - void startEffect(); - void cleanupTestCase(); - - private: - QWidget *parent, *w; - QPointer fade; -}; - -void KFadeWidgetEffectTest::initTestCase() -{ - parent = new QWidget; - w = new QWidget(parent); - //parent->show(); -} - -void KFadeWidgetEffectTest::createEffect() -{ - fade = new KFadeWidgetEffect(w); -} - -void KFadeWidgetEffectTest::startEffect() -{ - fade->start(250); - QVERIFY(QTest::kWaitForSignal(fade, SIGNAL(destroyed(QObject*)), 2000)); -} - -void KFadeWidgetEffectTest::cleanupTestCase() -{ - QVERIFY(!fade); - delete parent; -} - -QTEST_KDEMAIN(KFadeWidgetEffectTest, GUI) - -#include "kfadewidgeteffecttest.moc" diff --git a/kdeui/widgets/kfadewidgeteffect.cpp b/kdeui/widgets/kfadewidgeteffect.cpp deleted file mode 100644 index 22358413..00000000 --- a/kdeui/widgets/kfadewidgeteffect.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - Copyright (C) 2008 Rafael Fernández López - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) version 3. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include "kfadewidgeteffect.h" -#include "kfadewidgeteffect_p.h" - -#include -#include -#include - -#include - -KFadeWidgetEffectPrivate::KFadeWidgetEffectPrivate(QWidget *_destWidget) - : destWidget(_destWidget), disabled(false) -{ -} - -// Code from KFileItemDelegate (Author: Frederik Höglund) -// Fast transitions. Read: -// http://techbase.kde.org/Development/Tutorials/Graphics/Performance -// for further information on why not use setOpacity. -QPixmap KFadeWidgetEffectPrivate::transition(const QPixmap &from, const QPixmap &to, qreal amount) const -{ - const int value = int(0xff * amount); - - if (value == 0) - return from; - - if (value == 1) - return to; - - QColor color; - color.setAlphaF(amount); - - // If the native paint engine supports Porter/Duff compositing and CompositionMode_Plus - if (from.paintEngine()->hasFeature(QPaintEngine::PorterDuff) && - from.paintEngine()->hasFeature(QPaintEngine::BlendModes)) - { - QPixmap under = from; - QPixmap over = to; - - QPainter p; - p.begin(&over); - p.setCompositionMode(QPainter::CompositionMode_DestinationIn); - p.fillRect(over.rect(), color); - p.end(); - - p.begin(&under); - p.setCompositionMode(QPainter::CompositionMode_DestinationOut); - p.fillRect(under.rect(), color); - p.setCompositionMode(QPainter::CompositionMode_Plus); - p.drawPixmap(0, 0, over); - p.end(); - - return under; - } else { - // Fall back to using QRasterPaintEngine to do the transition. - QImage under = from.toImage(); - QImage over = to.toImage(); - - QPainter p; - p.begin(&over); - p.setCompositionMode(QPainter::CompositionMode_DestinationIn); - p.fillRect(over.rect(), color); - p.end(); - - p.begin(&under); - p.setCompositionMode(QPainter::CompositionMode_DestinationOut); - p.fillRect(under.rect(), color); - p.setCompositionMode(QPainter::CompositionMode_Plus); - p.drawImage(0, 0, over); - p.end(); - - return QPixmap::fromImage(under); - } -} - -KFadeWidgetEffect::KFadeWidgetEffect(QWidget *destWidget) - : QWidget(destWidget ? destWidget->parentWidget() : 0), - d_ptr(new KFadeWidgetEffectPrivate(destWidget)) -{ - Q_D(KFadeWidgetEffect); - d->q_ptr = this; - Q_ASSERT(destWidget && destWidget->parentWidget()); - if (!destWidget || !destWidget->parentWidget() || !destWidget->isVisible() || - !(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects)) { - d->disabled = true; - hide(); - return; - } - setGeometry(QRect(destWidget->mapTo(parentWidget(), QPoint(0, 0)), destWidget->size())); - d->oldPixmap = QPixmap::grabWidget(destWidget); - d->timeLine.setFrameRange(0, 255); - d->timeLine.setEasingCurve(QEasingCurve(QEasingCurve::OutCurve)); - connect(&d->timeLine, SIGNAL(finished()), SLOT(finished())); - connect(&d->timeLine, SIGNAL(frameChanged(int)), SLOT(repaint())); - show(); -} - -KFadeWidgetEffect::~KFadeWidgetEffect() -{ - delete d_ptr; -} - -void KFadeWidgetEffectPrivate::finished() -{ - Q_Q(KFadeWidgetEffect); - destWidget->setUpdatesEnabled(false); - q->hide(); - q->deleteLater(); - destWidget->setUpdatesEnabled(true); -} - -void KFadeWidgetEffect::start(int duration) -{ - Q_D(KFadeWidgetEffect); - if (d->disabled) { - deleteLater(); - return; - } - d->newPixmap = QPixmap::grabWidget(d->destWidget); - d->timeLine.setDuration(duration); - d->timeLine.start(); -} - -void KFadeWidgetEffect::paintEvent(QPaintEvent *) -{ - Q_D(KFadeWidgetEffect); - QPainter p(this); - p.drawPixmap(rect(), d->transition(d->oldPixmap, d->newPixmap, d->timeLine.currentValue())); - p.end(); -} - -#include "moc_kfadewidgeteffect.cpp" diff --git a/kdeui/widgets/kfadewidgeteffect.h b/kdeui/widgets/kfadewidgeteffect.h deleted file mode 100644 index 717aa4d6..00000000 --- a/kdeui/widgets/kfadewidgeteffect.h +++ /dev/null @@ -1,92 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) version 3. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KFADEWIDGETEFFECT_H -#define KFADEWIDGETEFFECT_H - -#include -#include - -class KFadeWidgetEffectPrivate; - -/** \class KFadeWidgetEffect kfadewidgeteffect.h KFadeWidgetEffect - * \brief Animates changes fading the new UI over the old look. - * - * This widget will put itself above the widget that will change and show a fading transition from - * the old to the new UI. It will delete itself after the animation is finished. - * Example: - * \code - * KFadeWidgetEffect *animation = new KFadeWidgetEffect(widgetThatWillChange); - * // do changes on widgetThatWillChange - * // ... - * animation->start(); - * \endcode - * - * \note The widget that changes needs to have a parent widget. KFadeWidgetEffect does not work - * for toplevel widgets (windows). - * - * \author Matthias Kretz - * \since 4.1 - */ -class KDEUI_EXPORT KFadeWidgetEffect : public QWidget -{ - Q_OBJECT - Q_DECLARE_PRIVATE(KFadeWidgetEffect) - public: - /** - * Create the animation widget. Takes a snapshot of the \p destWidget to use as old image - * that gets faded out. - * - * \param destWidget The widget that will change and should fade to the new look. - */ - KFadeWidgetEffect(QWidget *destWidget); - - /** - * Destructor. - * - * \warning KFadeWidgetEffect deletes itself after the animation is finished. - */ - ~KFadeWidgetEffect(); - - /** - * Starts the animation. - * - * Call this function after all visual changes are done. - * - * \param duration The duration of the animation in milliseconds. - */ - void start(int duration = 250); - - protected: - /** - * \internal - */ - void paintEvent(QPaintEvent *); - - /** - * \internal - */ - KFadeWidgetEffectPrivate *const d_ptr; - - private: - Q_PRIVATE_SLOT(d_func(), void finished()) -}; - -#endif // KFADEWIDGETEFFECT_H diff --git a/kdeui/widgets/kfadewidgeteffect_p.h b/kdeui/widgets/kfadewidgeteffect_p.h deleted file mode 100644 index 78cbbed0..00000000 --- a/kdeui/widgets/kfadewidgeteffect_p.h +++ /dev/null @@ -1,47 +0,0 @@ -/* This file is part of the KDE project - Copyright (C) 2008 Matthias Kretz - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) version 3. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef KFADEWIDGETEFFECT_P_H -#define KFADEWIDGETEFFECT_P_H - -#include "kfadewidgeteffect.h" - -#include -#include - -class KFadeWidgetEffectPrivate -{ - Q_DECLARE_PUBLIC(KFadeWidgetEffect) - protected: - KFadeWidgetEffectPrivate(QWidget *_destWidget); - KFadeWidgetEffect *q_ptr; - - private: - QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount) const; - void finished(); - - QTimeLine timeLine; - QPixmap oldPixmap; - QPixmap newPixmap; - QWidget *destWidget; - bool disabled; -}; - -#endif // KFADEWIDGETEFFECT_P_H