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 * @return the service this object is registered on the bus under
75 QString service() const;
78 * @return the category of the application associated to this item
81 QString Category() const;
84 * @return the id of this item
89 * @return the title of this item
91 QString Title() const;
94 * @return The status of this item
97 QString Status() const;
100 * @return The id of the main window of the application that controls the item
102 int WindowId() const;
105 * @return the name of the main icon to be displayed
106 * if image() is not empty this will always return an empty string
108 QString IconName() const;
111 * @return a serialization of the icon data
113 DBusImageVector IconPixmap() const;
116 * @return the name of the overlay of the main icon to be displayed
117 * if image() is not empty this will always return an empty string
119 QString OverlayIconName() const;
122 * @return a serialization of the icon data
124 DBusImageVector OverlayIconPixmap() const;
127 * @return the name of the icon to be displayed when the application
128 * is requesting the user's attention
129 * if attentionImage() is not empty this will always return an empty string
131 QString AttentionIconName() const;
134 * @return a serialization of the requesting attention icon data
136 DBusImageVector AttentionIconPixmap() const;
139 * @return the name of the attention movie
141 QString AttentionMovieName() const;
144 * all the data needed for a tooltip
146 DBusToolTipStruct ToolTip() const;
152 * Shows the context menu associated to this item
153 * at the desired screen position
155 void ContextMenu(int x, int y);
158 * Shows the main widget and try to position it on top
159 * of the other windows, if the widget is already visible, hide it.
161 void Activate(int x, int y);
164 * The user activated the item in an alternate way (for instance with middle mouse button, this depends from the systray implementation)
166 void SecondaryActivate(int x, int y);
169 * Inform this item that the mouse wheel was used on its representation
171 void Scroll(int delta, const QString &orientation);
175 * Inform the systemtray that the own main icon has been changed,
176 * so should be reloaded
181 * Inform the systemtray that there is a new icon to be used as overlay
183 void NewOverlayIcon();
186 * Inform the systemtray that the requesting attention icon
187 * has been changed, so should be reloaded
189 void NewAttentionIcon();
192 * Inform the systemtray that something in the tooltip has been changed
197 * Signal the new status when it has been changed
200 void NewStatus(const QString &status);
203 StatusNotifierItem *m_statusNotifierItem;
205 QDBusConnection m_dbus;
206 static int s_serviceCount;
210 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageStruct &icon);
211 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageStruct &icon);
213 Q_DECLARE_METATYPE(DBusImageStruct)
215 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageVector &iconVector);
216 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageVector &iconVector);
218 Q_DECLARE_METATYPE(DBusImageVector)
220 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusToolTipStruct &toolTip);
221 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusToolTipStruct &toolTip);
223 Q_DECLARE_METATYPE(DBusToolTipStruct)