QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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 "qgis_core.h"
20
21#include <QIcon>
22#include <QMetaMethod>
23#include <QMovie>
24#include <QObject>
25
30class CORE_EXPORT QgsAnimatedIcon : public QObject
31{
32 Q_OBJECT
33 public:
37 QgsAnimatedIcon( const QString &iconPath = QString(), QObject *parent = nullptr );
38
42 QString iconPath() const;
43
47 void setIconPath( const QString &iconPath );
48
54 QIcon icon() const;
55
56#ifndef SIP_RUN
57
68 template<typename Func1> bool connectFrameChanged( const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot )
69 {
70 if ( connect( this, &QgsAnimatedIcon::frameChanged, receiver, slot ) )
71 {
72 mMovie->setPaused( false );
73 return true;
74 }
75 else
76 return false;
77 }
78
85 template<typename Func1> bool disconnectFrameChanged( const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot )
86 {
87 return disconnect( this, &QgsAnimatedIcon::frameChanged, receiver, slot );
88 }
89
90#endif
91
100 bool connectFrameChanged( const QObject *receiver, const char *method );
101
106 bool disconnectFrameChanged( const QObject *receiver, const char *method );
107
108
113 int width() const;
114
119 int height() const;
120
121 signals:
122
131
132 private slots:
133 void onFrameChanged();
134
135 private:
136 QMovie *mMovie = nullptr;
137 QIcon mIcon;
138};
139
140#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.
void frameChanged()
Emitted when the icon changed.
QgsAnimatedIcon(const QString &iconPath=QString(), QObject *parent=nullptr)
Create a new animated icon.
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 setIconPath(const QString &iconPath)
Path to a movie, e.g.
QIcon icon() const
Gets the icons representation in the current frame.
QString iconPath() const
Path to a movie, e.g.