1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org> |
4 | SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-only |
7 | */ |
8 | #ifndef KANIMATEDBUTTON_H |
9 | #define KANIMATEDBUTTON_H |
10 | |
11 | #include <QToolButton> |
12 | #include <kwidgetsaddons_export.h> |
13 | #include <memory> |
14 | |
15 | /*! |
16 | * \class KAnimatedButton |
17 | * \inmodule KWidgetsAddons |
18 | * |
19 | * \brief An extended version of QToolButton which can display an animation. |
20 | * |
21 | * This widget extends QToolButton with the ability to display an animation. |
22 | * All you need to do is pass along a path to a file containing an animation, |
23 | * it can be anything supported by QMovie, or a picture containing all the |
24 | * frames of the animation next to each other (each frame being assumed of |
25 | * having the same size). |
26 | */ |
27 | class KWIDGETSADDONS_EXPORT KAnimatedButton : public QToolButton |
28 | { |
29 | Q_OBJECT |
30 | /*! |
31 | * \property KAnimatedButton::animationPath |
32 | */ |
33 | Q_PROPERTY(QString animationPath READ animationPath WRITE setAnimationPath) |
34 | |
35 | public: |
36 | /*! |
37 | * Construct an animated tool button. |
38 | * |
39 | * \a parent The parent widget |
40 | */ |
41 | explicit KAnimatedButton(QWidget *parent = nullptr); |
42 | |
43 | ~KAnimatedButton() override; |
44 | |
45 | /*! |
46 | * Returns the path used to load the animation |
47 | */ |
48 | QString animationPath() const; |
49 | |
50 | /*! |
51 | * Sets the path to the file which contains the animation to load. |
52 | * |
53 | * \a path The path of the file containing the animation |
54 | */ |
55 | void setAnimationPath(const QString &path); |
56 | |
57 | public Q_SLOTS: |
58 | /*! |
59 | * Starts the animation from frame 1 |
60 | */ |
61 | void start(); |
62 | |
63 | /*! |
64 | * Stops the animation. This will also reset the widget to frame 1. |
65 | */ |
66 | void stop(); |
67 | |
68 | private: |
69 | std::unique_ptr<class KAnimatedButtonPrivate> const d; |
70 | |
71 | Q_DISABLE_COPY(KAnimatedButton) |
72 | }; |
73 | |
74 | #endif // KANIMATEDBUTTON_H |
75 | |