This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
forked from Skycoder42/QTaskbarControl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
qtaskbarcontrol_x11.cpp
42 lines (36 loc) · 1.26 KB
/
qtaskbarcontrol_x11.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
#include "qtaskbarcontrol_x11.h"
#include <QDBusMessage>
#include <QDBusConnection>
#include <QDebug>
#include <QGuiApplication>
QTaskbarControlPrivate *QTaskbarControlPrivate::createPrivate(QTaskbarControl *)
{
return new QX11TaskbarControl{};
}
void QX11TaskbarControl::setProgress(bool visible, double value)
{
QVariantMap properties;
properties.insert(QStringLiteral("progress-visible"), visible);
properties.insert(QStringLiteral("progress"), value);
sendMessage(properties);
}
void QX11TaskbarControl::setCounter(bool visible, int value)
{
QVariantMap properties;
properties.insert(QStringLiteral("count-visible"), visible);
properties.insert(QStringLiteral("count"), value);
sendMessage(properties);
}
void QX11TaskbarControl::sendMessage(const QVariantMap ¶ms)
{
if(QGuiApplication::desktopFileName().isEmpty()) {
qWarning() << "You need to set the desktop file name before you can use QTaskbarControl!";
return;
}
auto message = QDBusMessage::createSignal(QStringLiteral("/de/skycoder42/QTaskbarProgress"),
QStringLiteral("com.canonical.Unity.LauncherEntry"),
QStringLiteral("Update"));
message << QStringLiteral("application://") + QGuiApplication::desktopFileName()
<< params;
QDBusConnection::sessionBus().send(message);
}