File indexing completed on 2024-05-12 16:39:55
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 KEXIFADEWIDGETEFFECT_H 0022 #define KEXIFADEWIDGETEFFECT_H 0023 0024 #include <kexiutils_export.h> 0025 #include <QWidget> 0026 0027 class KexiFadeWidgetEffectPrivate; 0028 0029 /** \class KexiFadeWidgetEffect KexiFadeWidgetEffect.h KexiFadeWidgetEffect 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 * KexiFadeWidgetEffect *animation = new KexiFadeWidgetEffect(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. KexiFadeWidgetEffect does not work 0043 * for toplevel widgets (windows). 0044 */ 0045 class KEXIUTILS_EXPORT KexiFadeWidgetEffect : public QWidget 0046 { 0047 Q_OBJECT 0048 0049 public: 0050 /** 0051 * Create the animation widget. Takes a snapshot of the \p destWidget to use as old image 0052 * that gets faded out. 0053 * 0054 * \param destWidget The widget that will change and should fade to the new look. 0055 * \param defaultDuration The duration of the animation activated by start() in milliseconds. 0056 */ 0057 KexiFadeWidgetEffect(QWidget *destWidget, int defaultDuration = 250); 0058 0059 /** 0060 * Destructor. 0061 * 0062 * \warning KexiFadeWidgetEffect deletes itself after the animation is finished. 0063 */ 0064 ~KexiFadeWidgetEffect(); 0065 0066 public Q_SLOTS: 0067 /** 0068 * Starts the animation. 0069 * 0070 * Call this function after all visual changes are done. 0071 * 0072 * \param duration The duration of the animation in milliseconds. 0073 */ 0074 void start(int duration); 0075 0076 /** 0077 * Starts the animation with default duration specified in ctor. 0078 * 0079 * Call this function after all visual changes are done. 0080 */ 0081 void start(); 0082 0083 protected: 0084 /** 0085 * \internal 0086 */ 0087 void paintEvent(QPaintEvent *) override; 0088 0089 /** 0090 * \internal 0091 */ 0092 KexiFadeWidgetEffectPrivate *const d; 0093 0094 private Q_SLOTS: 0095 void finished(); 0096 }; 0097 0098 #endif