QGIS API Documentation
4.3.0-Master (a080b0d5f12)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgsanimatedicon.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsanimatedicon.cpp - QgsAnimatedIcon
3
4
---------------------
5
begin : 13.3.2017
6
copyright : (C) 2017 by Matthias Kuhn
7
email : matthias@opengis.ch
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
17
#include "
qgsanimatedicon.h
"
18
19
#include "moc_qgsanimatedicon.cpp"
20
21
QgsAnimatedIcon::QgsAnimatedIcon
(
const
QString &
iconPath
, QObject *parent )
22
: QObject( parent )
23
, mMovie( new QMovie( this ) )
24
{
25
if
( !
iconPath
.isEmpty() )
26
{
27
mMovie->setFileName( iconPath );
28
}
29
mMovie->setCacheMode( QMovie::CacheAll );
30
connect( mMovie, &QMovie::frameChanged,
this
, &QgsAnimatedIcon::onFrameChanged );
31
}
32
33
QString
QgsAnimatedIcon::iconPath
()
const
34
{
35
return
mMovie->fileName();
36
}
37
38
void
QgsAnimatedIcon::setIconPath
(
const
QString &
iconPath
)
39
{
40
mMovie->setFileName(
iconPath
);
41
}
42
43
QIcon
QgsAnimatedIcon::icon
()
const
44
{
45
return
mIcon;
46
}
47
48
bool
QgsAnimatedIcon::connectFrameChanged
(
const
QObject *receiver,
const
char
*method )
49
{
50
if
( connect(
this
, SIGNAL(
frameChanged
() ), receiver, method ) )
51
{
52
mMovie->setPaused(
false
);
53
return
true
;
54
}
55
else
56
return
false
;
57
}
58
59
bool
QgsAnimatedIcon::disconnectFrameChanged
(
const
QObject *receiver,
const
char
*method )
60
{
61
return
disconnect(
this
, SIGNAL(
frameChanged
() ), receiver, method );
62
}
63
64
int
QgsAnimatedIcon::width
()
const
65
{
66
return
mMovie->currentPixmap().width();
67
}
68
69
int
QgsAnimatedIcon::height
()
const
70
{
71
return
mMovie->currentPixmap().height();
72
}
73
void
QgsAnimatedIcon::onFrameChanged()
74
{
75
if
( !isSignalConnected( QMetaMethod::fromSignal( &
QgsAnimatedIcon::frameChanged
) ) )
76
mMovie->setPaused(
true
);
77
78
mIcon = QIcon( mMovie->currentPixmap() );
79
emit
frameChanged
();
80
}
QgsAnimatedIcon::disconnectFrameChanged
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.
Definition
qgsanimatedicon.h:85
QgsAnimatedIcon::frameChanged
void frameChanged()
Emitted when the icon changed.
QgsAnimatedIcon::QgsAnimatedIcon
QgsAnimatedIcon(const QString &iconPath=QString(), QObject *parent=nullptr)
Create a new animated icon.
Definition
qgsanimatedicon.cpp:21
QgsAnimatedIcon::height
int height() const
The native height of the icon.
Definition
qgsanimatedicon.cpp:69
QgsAnimatedIcon::width
int width() const
The native width of the icon.
Definition
qgsanimatedicon.cpp:64
QgsAnimatedIcon::connectFrameChanged
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...
Definition
qgsanimatedicon.h:68
QgsAnimatedIcon::setIconPath
void setIconPath(const QString &iconPath)
Path to a movie, e.g.
Definition
qgsanimatedicon.cpp:38
QgsAnimatedIcon::icon
QIcon icon() const
Gets the icons representation in the current frame.
Definition
qgsanimatedicon.cpp:43
QgsAnimatedIcon::iconPath
QString iconPath() const
Path to a movie, e.g.
Definition
qgsanimatedicon.cpp:33
qgsanimatedicon.h
Generated on
for QGIS API Documentation by
1.17.0