This repository was archived by the owner on Jun 19, 2020. It is now read-only.
forked from Skycoder42/QTaskbarControl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqtaskbarcontrol.cpp
More file actions
99 lines (80 loc) · 2.06 KB
/
qtaskbarcontrol.cpp
File metadata and controls
99 lines (80 loc) · 2.06 KB
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
95
96
97
98
99
#include "qtaskbarcontrol.h"
#include "qtaskbarcontrol_p.h"
#include <QEvent>
QTaskbarControl::QTaskbarControl(QWidget *parent) :
QObject{parent},
d{QTaskbarControlPrivate::createPrivate(this)}
{
Q_ASSERT_X(parent, Q_FUNC_INFO, "QTaskbarControl must have a valid parent");
parent->installEventFilter(this);
if(parent->windowHandle())
d->setWindow(parent->windowHandle());
}
QTaskbarControl::~QTaskbarControl() = default;
bool QTaskbarControl::setAttribute(QTaskbarControl::SetupKey key, const QVariant &data)
{
return d->setAttribute(key, data);
}
QVariant QTaskbarControl::attribute(QTaskbarControl::SetupKey key) const
{
return d->attribute(key);
}
bool QTaskbarControl::progressVisible() const
{
return d->progressVisible;
}
double QTaskbarControl::progress() const
{
return d->progress;
}
bool QTaskbarControl::counterVisible() const
{
return d->counterVisible;
}
int QTaskbarControl::counter() const
{
return d->counter;
}
void QTaskbarControl::setProgressVisible(bool progressVisible)
{
if (d->progressVisible == progressVisible)
return;
d->progressVisible = progressVisible;
d->setProgress(progressVisible, d->progress);
emit progressVisibleChanged(progressVisible);
}
void QTaskbarControl::setProgress(double progress)
{
if (qFuzzyCompare(d->progress, progress))
return;
d->progress = progress;
d->setProgress(d->progressVisible, progress);
emit progressChanged(progress);
}
void QTaskbarControl::setCounterVisible(bool counterVisible)
{
if (d->counterVisible == counterVisible)
return;
d->counterVisible = counterVisible;
d->setCounter(counterVisible, d->counter);
emit counterVisibleChanged(counterVisible);
}
void QTaskbarControl::setCounter(int counter)
{
if (d->counter == counter)
return;
d->counter = counter;
d->setCounter(d->counterVisible, counter);
emit counterChanged(counter);
}
bool QTaskbarControl::eventFilter(QObject *watched, QEvent *event)
{
if(watched == parent()) {
if(event->type() == QEvent::Show) {
auto wid = qobject_cast<QWidget*>(parent());
if(wid)
d->setWindow(wid->windowHandle());
}
}
return false;
}