Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qstatusnotifieritemadaptor.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
/*
6
This file was originally created by qdbusxml2cpp version 0.8
7
Command line was:
8
qdbusxml2cpp -a statusnotifieritem ../../3rdparty/dbus-ifaces/org.kde.StatusNotifierItem.xml
9
10
However it is maintained manually, because this adapter needs to do
11
significant interface adaptation, and can do it more efficiently using the
12
QDBusTrayIcon API directly rather than via QObject::property() and
13
QMetaObject::invokeMethod().
14
*/
15
16
#
include
"qstatusnotifieritemadaptor_p.h"
17
18
#
ifndef
QT_NO_SYSTEMTRAYICON
19
20
#
include
<
QtCore
/
QLoggingCategory
>
21
#
include
<
QtCore
/
QCoreApplication
>
22
23
#
include
"qdbustrayicon_p.h"
24
25
QT_BEGIN_NAMESPACE
26
27
Q_DECLARE_LOGGING_CATEGORY(qLcMenu)
28
Q_DECLARE_LOGGING_CATEGORY(qLcTray)
29
30
QStatusNotifierItemAdaptor::QStatusNotifierItemAdaptor(QDBusTrayIcon *parent)
31
: QDBusAbstractAdaptor(parent), m_trayIcon(parent)
32
{
33
setAutoRelaySignals(
true
);
34
}
35
36
QStatusNotifierItemAdaptor::~QStatusNotifierItemAdaptor()
37
{
38
}
39
40
QString QStatusNotifierItemAdaptor::attentionIconName()
const
41
{
42
return
m_trayIcon->attentionIconName();
43
}
44
45
QXdgDBusImageVector QStatusNotifierItemAdaptor::attentionIconPixmap()
const
46
{
47
return
iconToQXdgDBusImageVector(m_trayIcon->attentionIcon());
48
}
49
50
QString QStatusNotifierItemAdaptor::attentionMovieName()
const
51
{
52
return
QString();
53
}
54
55
QString QStatusNotifierItemAdaptor::category()
const
56
{
57
return
m_trayIcon->category();
58
}
59
60
QString QStatusNotifierItemAdaptor::iconName()
const
61
{
62
return
m_trayIcon->iconName();
63
}
64
65
QXdgDBusImageVector QStatusNotifierItemAdaptor::iconPixmap()
const
66
{
67
return
iconToQXdgDBusImageVector(m_trayIcon->icon());
68
}
69
70
QString QStatusNotifierItemAdaptor::id()
const
71
{
72
// from the API docs: "a name that should be unique for this application and
73
// consistent between sessions, such as the application name itself"
74
return
QCoreApplication::applicationName();
75
}
76
77
bool
QStatusNotifierItemAdaptor::itemIsMenu()
const
78
{
79
// From KDE docs: if this is true, the item only supports the context menu,
80
// so the visualization should prefer sending ContextMenu() instead of Activate().
81
// But QSystemTrayIcon doesn't have such a setting: it will emit activated()
82
// and the application is free to use it or ignore it; we don't know whether it will.
83
return
false
;
84
}
85
86
QDBusObjectPath QStatusNotifierItemAdaptor::menu()
const
87
{
88
return
QDBusObjectPath(m_trayIcon->menu() ?
"/MenuBar"
:
"/NO_DBUSMENU"
);
89
}
90
91
QString QStatusNotifierItemAdaptor::overlayIconName()
const
92
{
93
return
QString();
94
}
95
96
QXdgDBusImageVector QStatusNotifierItemAdaptor::overlayIconPixmap()
const
97
{
98
QXdgDBusImageVector ret;
// empty vector
99
return
ret;
100
}
101
102
QString QStatusNotifierItemAdaptor::status()
const
103
{
104
return
m_trayIcon->status();
105
}
106
107
QString QStatusNotifierItemAdaptor::title()
const
108
{
109
// Shown e.g. when the icon is hidden, in the popup showing all hidden items.
110
// Since QSystemTrayIcon doesn't have this property, the application name
111
// is the best information we have available.
112
return
QCoreApplication::applicationName();
113
}
114
115
QXdgDBusToolTipStruct QStatusNotifierItemAdaptor::toolTip()
const
116
{
117
QXdgDBusToolTipStruct ret;
118
if
(m_trayIcon->isRequestingAttention()) {
119
ret.title = m_trayIcon->attentionTitle();
120
ret.subTitle = m_trayIcon->attentionMessage();
121
ret.icon = m_trayIcon->attentionIconName();
122
}
else
{
123
ret.title = m_trayIcon->tooltip();
124
}
125
return
ret;
126
}
127
128
void
QStatusNotifierItemAdaptor::Activate(
int
x,
int
y)
129
{
130
qCDebug(qLcTray) << x << y;
131
emit m_trayIcon->activated(QPlatformSystemTrayIcon::Trigger);
132
}
133
134
void
QStatusNotifierItemAdaptor::ContextMenu(
int
x,
int
y)
135
{
136
qCDebug(qLcTray) << x << y;
137
emit m_trayIcon->activated(QPlatformSystemTrayIcon::Context);
138
}
139
140
void
QStatusNotifierItemAdaptor::ProvideXdgActivationToken(
const
QString &token)
141
{
142
qCDebug(qLcTray) << token;
143
qputenv(
"XDG_ACTIVATION_TOKEN"
, token.toUtf8());
144
}
145
146
void
QStatusNotifierItemAdaptor::Scroll(
int
w,
const
QString &s)
147
{
148
qCDebug(qLcTray) << w << s;
149
// unsupported
150
}
151
152
void
QStatusNotifierItemAdaptor::SecondaryActivate(
int
x,
int
y)
153
{
154
qCDebug(qLcTray) << x << y;
155
emit m_trayIcon->activated(QPlatformSystemTrayIcon::MiddleClick);
156
}
157
158
QT_END_NAMESPACE
159
160
#
include
"moc_qstatusnotifieritemadaptor_p.cpp"
161
162
#
endif
// QT_NO_SYSTEMTRAYICON
qtbase
src
gui
platform
unix
dbustray
qstatusnotifieritemadaptor.cpp
Generated on
for Qt by
1.18.0