1 | /*************************************************************************** |
2 | * The original file is part of the KDE libraries * |
3 | * Copyright (C) 2009 by Marco Martin <notmart@gmail.com> * |
4 | * Quasselfied 2010 by Manuel Nickschas <sputnick@quassel-irc.org> * |
5 | * * |
6 | * This file is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU Library General Public License (LGPL) * |
8 | * as published by the Free Software Foundation; either version 2 of the * |
9 | * License, or (at your option) any later version. * |
10 | * * |
11 | * This program is distributed in the hope that it will be useful, * |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
14 | * GNU General Public License for more details. * |
15 | * * |
16 | * You should have received a copy of the GNU General Public License * |
17 | * along with this program; if not, write to the * |
18 | * Free Software Foundation, Inc., * |
19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
20 | ***************************************************************************/ |
21 | |
22 | #ifndef STATUSNOTIFIERITEMDBUS_H_ |
23 | #define STATUSNOTIFIERITEMDBUS_H_ |
24 | |
25 | #include <QObject> |
26 | #include <QString> |
27 | #include <QDBusArgument> |
28 | #include <QDBusConnection> |
29 | #include <QPixmap> |
30 | |
31 | //Custom message type for DBus |
32 | struct DBusImageStruct { |
33 | int width; |
34 | int height; |
35 | QByteArray data; |
36 | }; |
37 | |
38 | typedef QVector<DBusImageStruct> DBusImageVector; |
39 | |
40 | struct DBusToolTipStruct { |
41 | QString icon; |
42 | DBusImageVector image; |
43 | QString title; |
44 | QString subTitle; |
45 | }; |
46 | |
47 | class StatusNotifierItem; |
48 | |
49 | class StatusNotifierItemDBus : public QObject |
50 | { |
51 | Q_OBJECT |
52 | |
53 | Q_PROPERTY(QString Category READ Category) |
54 | Q_PROPERTY(QString Id READ Id) |
55 | Q_PROPERTY(QString Title READ Title) |
56 | Q_PROPERTY(QString Status READ Status) |
57 | Q_PROPERTY(int WindowId READ WindowId) |
58 | Q_PROPERTY(QString IconName READ IconName) |
59 | Q_PROPERTY(DBusImageVector IconPixmap READ IconPixmap) |
60 | Q_PROPERTY(QString OverlayIconName READ OverlayIconName) |
61 | Q_PROPERTY(DBusImageVector OverlayIconPixmap READ OverlayIconPixmap) |
62 | Q_PROPERTY(QString AttentionIconName READ AttentionIconName) |
63 | Q_PROPERTY(DBusImageVector AttentionIconPixmap READ AttentionIconPixmap) |
64 | Q_PROPERTY(QString AttentionMovieName READ AttentionMovieName) |
65 | Q_PROPERTY(DBusToolTipStruct ToolTip READ ToolTip) |
66 | Q_PROPERTY(QString IconThemePath READ IconThemePath) |
67 | Q_PROPERTY(QDBusObjectPath Menu READ Menu) |
68 | |
69 | friend class StatusNotifierItem; |
70 | public: |
71 | StatusNotifierItemDBus(StatusNotifierItem *parent); |
72 | ~StatusNotifierItemDBus(); |
73 | |
74 | /** |
75 | * @return the dbus connection used by this object |
76 | */ |
77 | QDBusConnection dbusConnection() const; |
78 | |
79 | /** |
80 | * Register the service to DBus |
81 | */ |
82 | void registerService(); |
83 | |
84 | /** |
85 | * Unregister the service from DBus |
86 | */ |
87 | void unregisterService(); |
88 | |
89 | /** |
90 | * @return the service this object is registered on the bus under |
91 | */ |
92 | QString service() const; |
93 | |
94 | /** |
95 | * @return the category of the application associated to this item |
96 | * @see Category |
97 | */ |
98 | QString Category() const; |
99 | |
100 | /** |
101 | * @return the id of this item |
102 | */ |
103 | QString Id() const; |
104 | |
105 | /** |
106 | * @return the title of this item |
107 | */ |
108 | QString Title() const; |
109 | |
110 | /** |
111 | * @return The status of this item |
112 | * @see Status |
113 | */ |
114 | QString Status() const; |
115 | |
116 | /** |
117 | * @return The id of the main window of the application that controls the item |
118 | */ |
119 | int WindowId() const; |
120 | |
121 | /** |
122 | * @return the name of the main icon to be displayed |
123 | * if image() is not empty this will always return an empty string |
124 | */ |
125 | QString IconName() const; |
126 | |
127 | /** |
128 | * @return a serialization of the icon data |
129 | */ |
130 | DBusImageVector IconPixmap() const; |
131 | |
132 | /** |
133 | * @return the name of the overlay of the main icon to be displayed |
134 | * if image() is not empty this will always return an empty string |
135 | */ |
136 | QString OverlayIconName() const; |
137 | |
138 | /** |
139 | * @return a serialization of the icon data |
140 | */ |
141 | DBusImageVector OverlayIconPixmap() const; |
142 | |
143 | /** |
144 | * @return the name of the icon to be displayed when the application |
145 | * is requesting the user's attention |
146 | * if attentionImage() is not empty this will always return an empty string |
147 | */ |
148 | QString AttentionIconName() const; |
149 | |
150 | /** |
151 | * @return a serialization of the requesting attention icon data |
152 | */ |
153 | DBusImageVector AttentionIconPixmap() const; |
154 | |
155 | /** |
156 | * @return the name of the attention movie |
157 | */ |
158 | QString AttentionMovieName() const; |
159 | |
160 | /** |
161 | * all the data needed for a tooltip |
162 | */ |
163 | DBusToolTipStruct ToolTip() const; |
164 | |
165 | /** |
166 | * @return path to extra icon theme, to load application specific icons |
167 | */ |
168 | QString IconThemePath() const; |
169 | |
170 | /** |
171 | * @return object path to the dbusmenu object |
172 | */ |
173 | QDBusObjectPath () const; |
174 | |
175 | public Q_SLOTS: |
176 | //interaction |
177 | /** |
178 | * Shows the context menu associated to this item |
179 | * at the desired screen position |
180 | */ |
181 | void (int x, int y); |
182 | |
183 | /** |
184 | * Shows the main widget and try to position it on top |
185 | * of the other windows, if the widget is already visible, hide it. |
186 | */ |
187 | void Activate(int x, int y); |
188 | |
189 | /** |
190 | * The user activated the item in an alternate way (for instance with middle mouse button, this depends from the systray implementation) |
191 | */ |
192 | void SecondaryActivate(int x, int y); |
193 | |
194 | /** |
195 | * Inform this item that the mouse wheel was used on its representation |
196 | */ |
197 | void Scroll(int delta, const QString &orientation); |
198 | |
199 | Q_SIGNALS: |
200 | /** |
201 | * Inform the systemtray that the own main icon has been changed, |
202 | * so should be reloaded |
203 | */ |
204 | void NewIcon(); |
205 | |
206 | /** |
207 | * Inform the systemtray that there is a new icon to be used as overlay |
208 | */ |
209 | void NewOverlayIcon(); |
210 | |
211 | /** |
212 | * Inform the systemtray that the requesting attention icon |
213 | * has been changed, so should be reloaded |
214 | */ |
215 | void NewAttentionIcon(); |
216 | |
217 | /** |
218 | * Inform the systemtray that something in the tooltip has been changed |
219 | */ |
220 | void NewToolTip(); |
221 | |
222 | /** |
223 | * Signal the new status when it has been changed |
224 | * @see Status |
225 | */ |
226 | void NewStatus(const QString &status); |
227 | |
228 | private: |
229 | StatusNotifierItem *m_statusNotifierItem; |
230 | QString m_service; |
231 | QDBusConnection m_dbus; |
232 | static int s_serviceCount; |
233 | }; |
234 | |
235 | |
236 | const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageStruct &icon); |
237 | const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageStruct &icon); |
238 | |
239 | Q_DECLARE_METATYPE(DBusImageStruct) |
240 | |
241 | const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageVector &iconVector); |
242 | const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageVector &iconVector); |
243 | |
244 | Q_DECLARE_METATYPE(DBusImageVector) |
245 | |
246 | const QDBusArgument &operator<<(QDBusArgument &argument, const DBusToolTipStruct &toolTip); |
247 | const QDBusArgument &operator>>(const QDBusArgument &argument, DBusToolTipStruct &toolTip); |
248 | |
249 | Q_DECLARE_METATYPE(DBusToolTipStruct) |
250 | |
251 | #endif |
252 | |