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 General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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)
67 friend class StatusNotifierItem;
69 StatusNotifierItemDBus(StatusNotifierItem *parent);
70 ~StatusNotifierItemDBus();
73 * Register the service to DBus
75 void registerService();
78 * Unregister the service from DBus
80 void unregisterService();
83 * @return the service this object is registered on the bus under
85 QString service() const;
88 * @return the category of the application associated to this item
91 QString Category() const;
94 * @return the id of this item
99 * @return the title of this item
101 QString Title() const;
104 * @return The status of this item
107 QString Status() const;
110 * @return The id of the main window of the application that controls the item
112 int WindowId() const;
115 * @return the name of the main icon to be displayed
116 * if image() is not empty this will always return an empty string
118 QString IconName() const;
121 * @return a serialization of the icon data
123 DBusImageVector IconPixmap() const;
126 * @return the name of the overlay of the main icon to be displayed
127 * if image() is not empty this will always return an empty string
129 QString OverlayIconName() const;
132 * @return a serialization of the icon data
134 DBusImageVector OverlayIconPixmap() const;
137 * @return the name of the icon to be displayed when the application
138 * is requesting the user's attention
139 * if attentionImage() is not empty this will always return an empty string
141 QString AttentionIconName() const;
144 * @return a serialization of the requesting attention icon data
146 DBusImageVector AttentionIconPixmap() const;
149 * @return the name of the attention movie
151 QString AttentionMovieName() const;
154 * all the data needed for a tooltip
156 DBusToolTipStruct ToolTip() const;
162 * Shows the context menu associated to this item
163 * at the desired screen position
165 void ContextMenu(int x, int y);
168 * Shows the main widget and try to position it on top
169 * of the other windows, if the widget is already visible, hide it.
171 void Activate(int x, int y);
174 * The user activated the item in an alternate way (for instance with middle mouse button, this depends from the systray implementation)
176 void SecondaryActivate(int x, int y);
179 * Inform this item that the mouse wheel was used on its representation
181 void Scroll(int delta, const QString &orientation);
185 * Inform the systemtray that the own main icon has been changed,
186 * so should be reloaded
191 * Inform the systemtray that there is a new icon to be used as overlay
193 void NewOverlayIcon();
196 * Inform the systemtray that the requesting attention icon
197 * has been changed, so should be reloaded
199 void NewAttentionIcon();
202 * Inform the systemtray that something in the tooltip has been changed
207 * Signal the new status when it has been changed
210 void NewStatus(const QString &status);
213 StatusNotifierItem *m_statusNotifierItem;
215 QDBusConnection m_dbus;
216 static int s_serviceCount;
220 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageStruct &icon);
221 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageStruct &icon);
223 Q_DECLARE_METATYPE(DBusImageStruct)
225 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageVector &iconVector);
226 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageVector &iconVector);
228 Q_DECLARE_METATYPE(DBusImageVector)
230 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusToolTipStruct &toolTip);
231 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusToolTipStruct &toolTip);
233 Q_DECLARE_METATYPE(DBusToolTipStruct)