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> *
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. *
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. *
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 ***************************************************************************/
22 #ifndef STATUSNOTIFIERITEMDBUS_H_
23 #define STATUSNOTIFIERITEMDBUS_H_
27 #include <QDBusArgument>
28 #include <QDBusConnection>
31 //Custom message type for DBus
32 struct DBusImageStruct {
38 typedef QVector<DBusImageStruct> DBusImageVector;
40 struct DBusToolTipStruct {
42 DBusImageVector image;
47 class StatusNotifierItem;
49 class StatusNotifierItemDBus : public QObject
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)
69 friend class StatusNotifierItem;
71 StatusNotifierItemDBus(StatusNotifierItem *parent);
72 ~StatusNotifierItemDBus();
75 * @return the dbus connection used by this object
77 QDBusConnection dbusConnection() const;
80 * Register the StatusNotifierItem to DBus
82 void registerTrayIcon();
85 * Unregister the StatusNotifierItem from DBus
87 void unregisterTrayIcon();
90 * @return the service this object is registered on the bus under
92 QString service() const;
95 * @return the category of the application associated to this item
98 QString Category() const;
101 * @return the id of this item
106 * @return the title of this item
108 QString Title() const;
111 * @return The status of this item
114 QString Status() const;
117 * @return The id of the main window of the application that controls the item
119 int WindowId() const;
122 * @return the name of the main icon to be displayed
123 * if image() is not empty this will always return an empty string
125 QString IconName() const;
128 * @return a serialization of the icon data
130 DBusImageVector IconPixmap() const;
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
136 QString OverlayIconName() const;
139 * @return a serialization of the icon data
141 DBusImageVector OverlayIconPixmap() const;
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
148 QString AttentionIconName() const;
151 * @return a serialization of the requesting attention icon data
153 DBusImageVector AttentionIconPixmap() const;
156 * @return the name of the attention movie
158 QString AttentionMovieName() const;
161 * all the data needed for a tooltip
163 DBusToolTipStruct ToolTip() const;
166 * @return path to extra icon theme, to load application specific icons
168 QString IconThemePath() const;
171 * @return object path to the dbusmenu object
173 QDBusObjectPath Menu() const;
178 * Shows the context menu associated to this item
179 * at the desired screen position
181 void ContextMenu(int x, int y);
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.
187 void Activate(int x, int y);
190 * The user activated the item in an alternate way (for instance with middle mouse button, this depends from the systray implementation)
192 void SecondaryActivate(int x, int y);
195 * Inform this item that the mouse wheel was used on its representation
197 void Scroll(int delta, const QString &orientation);
201 * Inform the systemtray that the own main icon has been changed,
202 * so should be reloaded
207 * Inform the systemtray that there is a new icon to be used as overlay
209 void NewOverlayIcon();
212 * Inform the systemtray that the requesting attention icon
213 * has been changed, so should be reloaded
215 void NewAttentionIcon();
218 * Inform the systemtray that something in the tooltip has been changed
223 * Signal the new status when it has been changed
226 void NewStatus(const QString &status);
229 StatusNotifierItem *m_statusNotifierItem;
230 QDBusConnection m_dbus;
231 static int s_serviceCount;
235 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageStruct &icon);
236 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageStruct &icon);
238 Q_DECLARE_METATYPE(DBusImageStruct)
240 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageVector &iconVector);
241 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageVector &iconVector);
243 Q_DECLARE_METATYPE(DBusImageVector)
245 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusToolTipStruct &toolTip);
246 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusToolTipStruct &toolTip);
248 Q_DECLARE_METATYPE(DBusToolTipStruct)