This repository has been archived by the owner on Mar 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
qtaskbarcontrol.cpp
136 lines (108 loc) · 2.62 KB
/
qtaskbarcontrol.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include "qtaskbarcontrol.h"
#include "qtaskbarcontrol_p.h"
#include <QEvent>
#include <QWidget>
#include <QIcon>
QTaskbarControl::QTaskbarControl(QObject *parent) :
QObject{parent},
d{QTaskbarControlPrivate::createPrivate(this)}
{}
void QTaskbarControl::setWidget(QWidget *widget)
{
if (widget && widget->windowHandle()) {
setWindow(widget->windowHandle());
return;
}
if (d->watchedWidget)
d->watchedWidget->removeEventFilter(this);
d->watchedWidget = widget;
if (d->watchedWidget)
d->watchedWidget->installEventFilter(this);
}
void QTaskbarControl::setWindow(QWindow *window)
{
setWidget(nullptr);
d->setWindow(window);
}
QTaskbarControl::~QTaskbarControl() = default;
QTaskbarControl::WinProgressState QTaskbarControl::windowsProgressState() const
{
return d->windowsProgressState();
}
QIcon QTaskbarControl::windowsBadgeIcon() const
{
return d->windowsBadgeIcon();
}
QColor QTaskbarControl::windowsBadgeTextColor() const
{
return d->windowsBadgeTextColor();
}
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::setWindowsProgressState(QTaskbarControl::WinProgressState state)
{
d->setWindowsProgressState(state);
}
void QTaskbarControl::setWindowsBadgeIcon(const QIcon &icon)
{
d->setWindowsBadgeIcon(icon);
}
void QTaskbarControl::setWindowsBadgeTextColor(const QColor &color)
{
d->setWindowsBadgeTextColor(color);
}
void QTaskbarControl::setProgressVisible(bool visible)
{
if (d->progressVisible == visible)
return;
d->progressVisible = visible;
d->setProgress(visible, d->progress);
emit progressVisibleChanged(visible);
}
void QTaskbarControl::setProgress(double value)
{
if (qFuzzyCompare(d->progress, value))
return;
d->progress = value;
d->setProgress(d->progressVisible, value);
emit progressChanged(value);
}
void QTaskbarControl::setCounterVisible(bool visible)
{
if (d->counterVisible == visible)
return;
d->counterVisible = visible;
d->setCounter(visible, d->counter);
emit counterVisibleChanged(visible);
}
void QTaskbarControl::setCounter(int value)
{
if (d->counter == value)
return;
d->counter = value;
d->setCounter(d->counterVisible, value);
emit counterChanged(value);
}
bool QTaskbarControl::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::Show) {
auto *widget = qobject_cast<QWidget*>(watched);
if (widget)
setWindow(widget->windowHandle());
}
return QObject::eventFilter(watched, event);
}