mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdeui: remove unused KFadeWidgetEffect class
for example on how to do it (somewhat) properly see KMessageWidget Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
a37bd35627
commit
521d3cd59b
8 changed files with 0 additions and 364 deletions
|
@ -118,7 +118,6 @@ install(
|
|||
KEditToolBar
|
||||
KEncodingFileDialog
|
||||
KExtendableItemDelegate
|
||||
KFadeWidgetEffect
|
||||
KFile
|
||||
KFileDialog
|
||||
KFileFilterCombo
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "../kfadewidgeteffect.h"
|
|
@ -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
|
||||
|
|
|
@ -38,7 +38,6 @@ KDEUI_UNIT_TESTS(
|
|||
kcompletioncoretest
|
||||
kconfigskeletontest
|
||||
kdualactiontest
|
||||
kfadewidgeteffecttest
|
||||
kfindtest
|
||||
kglobalsettingstest
|
||||
kmainwindow_unittest
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
|
||||
|
||||
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 <qtest_kde.h>
|
||||
#include <kfadewidgeteffect.h>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
class KFadeWidgetEffectTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void createEffect();
|
||||
void startEffect();
|
||||
void cleanupTestCase();
|
||||
|
||||
private:
|
||||
QWidget *parent, *w;
|
||||
QPointer<KFadeWidgetEffect> 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"
|
|
@ -1,152 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
|
||||
Copyright (C) 2008 Rafael Fernández López <ereslibre@kde.org>
|
||||
|
||||
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 <QtCore/QEvent>
|
||||
#include <QtGui/QPaintEngine>
|
||||
#include <QtGui/QPainter>
|
||||
|
||||
#include <kglobalsettings.h>
|
||||
|
||||
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"
|
|
@ -1,92 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
|
||||
|
||||
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 <kdeui_export.h>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
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 <kretz@kde.org>
|
||||
* \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
|
|
@ -1,47 +0,0 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
|
||||
|
||||
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 <QtCore/QTimeLine>
|
||||
#include <QtGui/QPixmap>
|
||||
|
||||
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
|
Loading…
Add table
Reference in a new issue