-
Notifications
You must be signed in to change notification settings - Fork 2
/
kanimatedsystemtrayicon.cpp
94 lines (76 loc) · 2.17 KB
/
kanimatedsystemtrayicon.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
kanimatedsystemtrayicon.cpp - System Tray Icon that can play movies
Designed for Kopete but usable anywhere
Copyright (c) 2007 by Charles Connell <charles@connells.org>
Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
*************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
*************************************************************************
*/
#include "kanimatedsystemtrayicon.h"
#include <QMovie>
class KAnimatedSystemTrayIcon::Private
{
public:
Private(const QString& m) {
movie = new QMovie(m);
}
Private(QMovie * m = 0) {
movie = m;
}
~Private() {
delete movie;
}
QMovie * movie;
};
KAnimatedSystemTrayIcon::KAnimatedSystemTrayIcon(QWidget *parent)
: QSystemTrayIcon(0)
{
Q_UNUSED(parent);
d = new Private(0);
}
KAnimatedSystemTrayIcon::~KAnimatedSystemTrayIcon()
{
delete d;
}
void KAnimatedSystemTrayIcon::setMovie(QMovie* m)
{
delete d->movie;
d->movie = m;
}
const QMovie * KAnimatedSystemTrayIcon::movie() const
{
return d->movie;
}
void KAnimatedSystemTrayIcon::startMovie()
{
if (d->movie) {
connect(d->movie, SIGNAL(frameChanged(int)), this, SLOT(slotNewFrame()));
d->movie->setCacheMode(QMovie::CacheAll);
d->movie->start();
}
}
void KAnimatedSystemTrayIcon::stopMovie()
{
if (d->movie) {
d->movie->stop();
}
}
bool KAnimatedSystemTrayIcon::isPlaying() const
{
if (!d->movie)
return false;
if (d->movie->state() == QMovie::Running)
return true;
else
return false;
}
void KAnimatedSystemTrayIcon::slotNewFrame()
{
setIcon(QIcon(d->movie->currentPixmap()));
}