blob: 81683ddfebc0e4ed1277b50658cf43f84a3c0500 (
plain)
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
#include "xdgstatusnotifieritem.h"
#include <statusnotifieritemadaptor.h>
#include <XdgStatusNotifierWatcherIface.h>
#include <QDBusConnection>
#include <QGuiApplication>
#include <debug.h>
using namespace KaZoe;
StatusNotifierItem::StatusNotifierItem(QObject *parent)
: QObject{parent}
{
QDBusConnection bus = QDBusConnection::sessionBus();
if (!bus.isConnected()) {
qCWarning(SYSTEM_TRAY) << "Cannot connect to the D-Bus session bus.\n" << "Please check your system settings and try again.\n";
}
QString serviceName = "org.kazoe.xdg";
setId((QGuiApplication::desktopFileName().isEmpty())?(QCoreApplication::applicationName()):(QGuiApplication::desktopFileName()));
serviceName.append(Id());
serviceName.append("-");
serviceName.append(QString::number(QCoreApplication::applicationPid()));
qCDebug(SYSTEM_TRAY) << "Register Item service" << serviceName << ":" << bus.registerService(serviceName);
new StatusNotifierItemAdaptor(this);
bus.registerObject("/StatusNotifierItem", this);
OrgKdeStatusNotifierWatcherInterface *watcher = new OrgKdeStatusNotifierWatcherInterface("org.kde.StatusNotifierWatcher", "/StatusNotifierWatcher", bus);
watcher->RegisterStatusNotifierItem(serviceName);
}
QString StatusNotifierItem::Title() const
{
return m_Title;
}
void StatusNotifierItem::setTitle(const QString &newTitle)
{
if (m_Title == newTitle)
return;
m_Title = newTitle;
emit NewTitle();
emit TitleChanged();
}
QString StatusNotifierItem::IconName() const
{
return m_IconName;
}
void StatusNotifierItem::setIconName(const QString &newIconName)
{
if (m_IconName == newIconName)
return;
m_IconName = newIconName;
emit IconNameChanged();
emit NewIcon();
}
void StatusNotifierItem::Activate(uint x, uint y)
{
emit activated(x, y);
}
void StatusNotifierItem::SecondaryActivate(uint x, uint y)
{
emit secondaryActivated(x, y);
}
QString StatusNotifierItem::Status() const
{
return m_Status;
}
void StatusNotifierItem::setStatus(const QString &newStatus)
{
if (m_Status == newStatus)
return;
if(!xdgStatus.contains(newStatus))
{
qCWarning(SYSTEM_TRAY) << "Status " << newStatus << "not authorized";
return;
}
m_Status = newStatus;
emit StatusChanged();
emit NewStatus(m_Status);
}
QString StatusNotifierItem::OverlayIconName() const
{
return m_OverlayIconName;
}
void StatusNotifierItem::setOverlayIconName(const QString &newOverlayIconName)
{
if (m_OverlayIconName == newOverlayIconName)
return;
m_OverlayIconName = newOverlayIconName;
emit overlayIconNameChanged();
emit NewOverlayIcon();
}
QString StatusNotifierItem::Category() const
{
return m_Category;
}
void StatusNotifierItem::setCategory(const QString &newCategory)
{
if (m_Category == newCategory)
return;
if(!xdgCategories.contains(newCategory))
{
qCWarning(SYSTEM_TRAY) << "Category " << newCategory << "not authorized";
return;
}
m_Category = newCategory;
emit CategoryChanged();
}
QString StatusNotifierItem::Id() const
{
return m_Id;
}
void StatusNotifierItem::setId(const QString &newId)
{
if (m_Id == newId)
return;
m_Id = newId;
emit IdChanged();
}
QString StatusNotifierItem::WindowId() const
{
return m_WindowId;
}
void StatusNotifierItem::setWindowId(const QString &newWindowId)
{
if (m_WindowId == newWindowId)
return;
m_WindowId = newWindowId;
emit WindowIdChanged();
}
QString StatusNotifierItem::AttentionIconName() const
{
return m_AttentionIconName;
}
void StatusNotifierItem::setAttentionIconName(const QString &newAttentionIconName)
{
if (m_AttentionIconName == newAttentionIconName)
return;
m_AttentionIconName = newAttentionIconName;
emit AttentionIconNameChanged();
}
QString StatusNotifierItem::AttentionMovieName() const
{
return m_AttentionMovieName;
}
void StatusNotifierItem::setAttentionMovieName(const QString &newAttentionMovieName)
{
if (m_AttentionMovieName == newAttentionMovieName)
return;
m_AttentionMovieName = newAttentionMovieName;
emit AttentionMovieNameChanged();
}
|