1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 Kurt Granroth <granroth@kde.org> |
3 | Copyright (C) 2006 Hamish Rodda <rodda@kde.org> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License version 2 as published by the Free Software Foundation. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | */ |
19 | #ifndef KANIMATEDBUTTON_H |
20 | #define KANIMATEDBUTTON_H |
21 | |
22 | #include <kdeui_export.h> |
23 | #include <QtGui/QToolButton> |
24 | |
25 | /** |
26 | * @short An extended version of QToolButton which can display an animated icon. |
27 | * |
28 | * This widget extends QToolButton with the ability to display animation |
29 | * using a sequence of individual pixmaps. All you need to do is pass along |
30 | * a list of icon names and their size and everything else is taken |
31 | * care of. |
32 | * |
33 | * \note if you change the iconSize() via setIconSize(), you will need to call |
34 | * updateIcons() also to force reloading of the correct icon size. |
35 | * |
36 | * @author Kurt Granroth <granroth@kde.org> |
37 | */ |
38 | class KDEUI_EXPORT KAnimatedButton : public QToolButton |
39 | { |
40 | Q_OBJECT |
41 | Q_PROPERTY( QString icons READ icons WRITE setIcons ) |
42 | |
43 | public: |
44 | /** |
45 | * Construct an animated tool button. |
46 | * |
47 | * @param parent The parent widget |
48 | */ |
49 | explicit KAnimatedButton(QWidget *parent = 0L); |
50 | |
51 | /** |
52 | * Destructor |
53 | */ |
54 | virtual ~KAnimatedButton(); |
55 | |
56 | /** |
57 | * Returns the current maximum dimension (width or length) for an icon. |
58 | */ |
59 | int iconDimensions() const; |
60 | |
61 | /** |
62 | * Returns the current icons |
63 | */ |
64 | QString icons() const; |
65 | |
66 | /** |
67 | * Sets the name of the animated icons to load. This will use the |
68 | * KIconLoader::loadAnimated method for the actual loading. |
69 | * |
70 | * @param icons The name of the icons to use for the animation |
71 | */ |
72 | void setIcons( const QString& icons ); |
73 | |
74 | public Q_SLOTS: |
75 | /** |
76 | * Starts the animation from frame 1 |
77 | */ |
78 | void start(); |
79 | |
80 | /** |
81 | * Stops the animation. This will also reset the widget to frame 1. |
82 | */ |
83 | void stop(); |
84 | |
85 | /** |
86 | * Updates the icons by reloading them if required. |
87 | * |
88 | * You must call this after you change the icon size, in order for the correct |
89 | * size icon to be loaded. |
90 | */ |
91 | void updateIcons(); |
92 | |
93 | Q_SIGNALS: |
94 | void clicked(); |
95 | |
96 | protected Q_SLOTS: |
97 | void slotTimerUpdate(); |
98 | |
99 | private: |
100 | class KAnimatedButtonPrivate *const d; |
101 | |
102 | Q_PRIVATE_SLOT(d, void _k_movieFrameChanged(int)) |
103 | Q_PRIVATE_SLOT(d, void _k_movieFinished()) |
104 | |
105 | Q_DISABLE_COPY(KAnimatedButton) |
106 | }; |
107 | |
108 | #endif // KANIMATEDBUTTON_H |
109 | |