QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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
7  email : [email protected]
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 
30 class 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 
70  template <typename Func1>
71  bool connectFrameChanged( const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot )
72  {
73  if ( connect( this, &QgsAnimatedIcon::frameChanged, receiver, slot ) )
74  {
75  mMovie->setPaused( false );
76  return true;
77  }
78  else
79  return false;
80  }
81 
89  template <typename Func1>
90  bool disconnectFrameChanged( const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot )
91  {
92  return disconnect( this, &QgsAnimatedIcon::frameChanged, receiver, slot );
93  }
94 
95 #endif
96 
106  bool connectFrameChanged( const QObject *receiver, const char *method );
107 
113  bool disconnectFrameChanged( const QObject *receiver, const char *method );
114 
115 
121  int width() const;
122 
128  int height() const;
129 
130  signals:
131 
139  void frameChanged();
140 
141  private slots:
142  void onFrameChanged();
143 
144  private:
145  QMovie *mMovie = nullptr;
146  QIcon mIcon;
147 };
148 
149 #endif // QGSANIMATEDICON_H
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...
Animated icon is keeping an animation running if there are listeners connected to frameChanged...
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...
void frameChanged()
Emitted when the icon changed.