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 kanimatedbutton.h KAnimatedButton
17 *
18 * @short An extended version of QToolButton which can display an animation.
19 *
20 * This widget extends QToolButton with the ability to display an animation.
21 * All you need to do is pass along a path to a file containing an animation,
22 * it can be anything supported by QMovie, or a picture containing all the
23 * frames of the animation next to each other (each frame being assumed of
24 * having the same size).
25 *
26 * @author Kurt Granroth <granroth@kde.org>
27 */
28class KWIDGETSADDONS_EXPORT KAnimatedButton : public QToolButton
29{
30 Q_OBJECT
31 Q_PROPERTY(QString animationPath READ animationPath WRITE setAnimationPath)
32
33public:
34 /**
35 * Construct an animated tool button.
36 *
37 * @param parent The parent widget
38 */
39 explicit KAnimatedButton(QWidget *parent = nullptr);
40
41 /**
42 * Destructor
43 */
44 ~KAnimatedButton() override;
45
46 /**
47 * Returns the path used to load the animation
48 */
49 QString animationPath() const;
50
51 /**
52 * Sets the path to the file which contains the animation to load.
53 *
54 * @param path The path of the file containing the animation
55 */
56 void setAnimationPath(const QString &path);
57
58public Q_SLOTS:
59 /**
60 * Starts the animation from frame 1
61 */
62 void start();
63
64 /**
65 * Stops the animation. This will also reset the widget to frame 1.
66 */
67 void stop();
68
69private:
70 std::unique_ptr<class KAnimatedButtonPrivate> const d;
71
72 Q_DISABLE_COPY(KAnimatedButton)
73};
74
75#endif // KANIMATEDBUTTON_H
76

source code of kwidgetsaddons/src/kanimatedbutton.h