QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsanimatedicon.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsanimatedicon.h - QgsAnimatedIcon
3
4 ---------------------
5 begin : 13.3.2017
6 copyright : (C) 2017 by Matthias Kuhn
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSANIMATEDICON_H
17#define QGSANIMATEDICON_H
18
19#include <QObject>
20#include <QMovie>
21#include <QIcon>
22#include <QMetaMethod>
23
24#include "qgis_core.h"
25
30class CORE_EXPORT QgsAnimatedIcon : public QObject
31{
32 Q_OBJECT
33 public:
34
38 QgsAnimatedIcon( const QString &iconPath = QString(), QObject *parent = nullptr );
39
43 QString iconPath() const;
44
48 void setIconPath( const QString &iconPath );
49
55 QIcon icon() const;
56
57#ifndef SIP_RUN
58
69 template <typename Func1>
70 bool connectFrameChanged( const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot )
71 {
72 if ( connect( this, &QgsAnimatedIcon::frameChanged, receiver, slot ) )
73 {
74 mMovie->setPaused( false );
75 return true;
76 }
77 else
78 return false;
79 }
80
87 template <typename Func1>
88 bool disconnectFrameChanged( const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot )
89 {
90 return disconnect( this, &QgsAnimatedIcon::frameChanged, receiver, slot );
91 }
92
93#endif
94
103 bool connectFrameChanged( const QObject *receiver, const char *method );
104
109 bool disconnectFrameChanged( const QObject *receiver, const char *method );
110
111
116 int width() const;
117
122 int height() const;
123
124 signals:
125
134
135 private slots:
136 void onFrameChanged();
137
138 private:
139 QMovie *mMovie = nullptr;
140 QIcon mIcon;
141};
142
143#endif // QGSANIMATEDICON_H
Animated icon is keeping an animation running if there are listeners connected to frameChanged.
bool disconnectFrameChanged(const typename QtPrivate::FunctionPointer< Func1 >::Object *receiver, Func1 slot)
Convenience function to disconnect the same style that the frame change connection was established.
void frameChanged()
Emitted when the icon changed.
bool connectFrameChanged(const typename QtPrivate::FunctionPointer< Func1 >::Object *receiver, Func1 slot)
Connect a slot that will be notified repeatedly whenever a frame changes and which should request the...