File indexing completed on 2024-04-14 14:20:19
0001 /* This file is part of the KDE project 0002 Copyright (C) 2008 Matthias Kretz <kretz@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) version 3. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 0019 */ 0020 0021 #ifndef KFADEWIDGETEFFECT_H 0022 #define KFADEWIDGETEFFECT_H 0023 0024 #include <kdelibs4support_export.h> 0025 #include <QWidget> 0026 0027 class KFadeWidgetEffectPrivate; 0028 0029 /** \class KFadeWidgetEffect kfadewidgeteffect.h KFadeWidgetEffect 0030 * \brief Animates changes fading the new UI over the old look. 0031 * 0032 * This widget will put itself above the widget that will change and show a fading transition from 0033 * the old to the new UI. It will delete itself after the animation is finished. 0034 * Example: 0035 * \code 0036 * KFadeWidgetEffect *animation = new KFadeWidgetEffect(widgetThatWillChange); 0037 * // do changes on widgetThatWillChange 0038 * // ... 0039 * animation->start(); 0040 * \endcode 0041 * 0042 * \note The widget that changes needs to have a parent widget. KFadeWidgetEffect does not work 0043 * for toplevel widgets (windows). 0044 * 0045 * \author Matthias Kretz <kretz@kde.org> 0046 * \since 4.1 0047 */ 0048 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KFadeWidgetEffect : public QWidget 0049 { 0050 Q_OBJECT 0051 Q_DECLARE_PRIVATE(KFadeWidgetEffect) 0052 public: 0053 /** 0054 * Create the animation widget. Takes a snapshot of the \p destWidget to use as old image 0055 * that gets faded out. 0056 * 0057 * \param destWidget The widget that will change and should fade to the new look. 0058 */ 0059 KFadeWidgetEffect(QWidget *destWidget); 0060 0061 /** 0062 * Destructor. 0063 * 0064 * \warning KFadeWidgetEffect deletes itself after the animation is finished. 0065 */ 0066 ~KFadeWidgetEffect() override; 0067 0068 /** 0069 * Starts the animation. 0070 * 0071 * Call this function after all visual changes are done. 0072 * 0073 * \param duration The duration of the animation in milliseconds. 0074 */ 0075 void start(int duration = 250); 0076 0077 protected: 0078 /** 0079 * \internal 0080 */ 0081 void paintEvent(QPaintEvent *) override; 0082 0083 /** 0084 * \internal 0085 */ 0086 KFadeWidgetEffectPrivate *const d_ptr; 0087 0088 private: 0089 Q_PRIVATE_SLOT(d_func(), void finished()) 0090 }; 0091 0092 #endif // KFADEWIDGETEFFECT_H