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_
25 #include <QDBusArgument>
26 #include <QDBusConnection>
31 // Custom message type for DBus
32 struct DBusImageStruct
39 using DBusImageVector = QVector<DBusImageStruct>;
41 struct DBusToolTipStruct
44 DBusImageVector image;
49 class StatusNotifierItem;
51 class StatusNotifierItemDBus : public QObject
55 Q_PROPERTY(QString Category READ Category)
56 Q_PROPERTY(QString Id READ Id)
57 Q_PROPERTY(QString Title READ Title)
58 Q_PROPERTY(QString Status READ Status)
59 Q_PROPERTY(int WindowId READ WindowId)
60 Q_PROPERTY(QString IconName READ IconName)
61 Q_PROPERTY(DBusImageVector IconPixmap READ IconPixmap)
62 Q_PROPERTY(QString OverlayIconName READ OverlayIconName)
63 Q_PROPERTY(DBusImageVector OverlayIconPixmap READ OverlayIconPixmap)
64 Q_PROPERTY(QString AttentionIconName READ AttentionIconName)
65 Q_PROPERTY(DBusImageVector AttentionIconPixmap READ AttentionIconPixmap)
66 Q_PROPERTY(QString AttentionMovieName READ AttentionMovieName)
67 Q_PROPERTY(DBusToolTipStruct ToolTip READ ToolTip)
68 Q_PROPERTY(QString IconThemePath READ IconThemePath)
69 Q_PROPERTY(QDBusObjectPath Menu READ Menu)
71 friend class StatusNotifierItem;
74 StatusNotifierItemDBus(StatusNotifierItem* parent);
75 ~StatusNotifierItemDBus() override;
78 * @return the dbus connection used by this object
80 QDBusConnection dbusConnection() const;
83 * Register the StatusNotifierItem to DBus
85 void registerTrayIcon();
88 * Unregister the StatusNotifierItem from DBus
90 void unregisterTrayIcon();
93 * @return the service this object is registered on the bus under
95 QString service() const;
98 * @return the category of the application associated to this item
101 QString Category() const;
104 * @return the id of this item
109 * @return the title of this item
111 QString Title() const;
114 * @return The status of this item
117 QString Status() const;
120 * @return The id of the main window of the application that controls the item
122 int WindowId() const;
125 * @return the name of the main icon to be displayed
126 * if image() is not empty this will always return an empty string
128 QString IconName() const;
131 * @return a serialization of the icon data
133 DBusImageVector IconPixmap() const;
136 * @return the name of the overlay of the main icon to be displayed
137 * if image() is not empty this will always return an empty string
139 QString OverlayIconName() const;
142 * @return a serialization of the icon data
144 DBusImageVector OverlayIconPixmap() const;
147 * @return the name of the icon to be displayed when the application
148 * is requesting the user's attention
149 * if attentionImage() is not empty this will always return an empty string
151 QString AttentionIconName() const;
154 * @return a serialization of the requesting attention icon data
156 DBusImageVector AttentionIconPixmap() const;
159 * @return the name of the attention movie
161 QString AttentionMovieName() const;
164 * all the data needed for a tooltip
166 DBusToolTipStruct ToolTip() const;
169 * @return path to extra icon theme, to load application specific icons
171 QString IconThemePath() const;
174 * @return object path to the dbusmenu object
176 QDBusObjectPath Menu() const;
181 * Shows the context menu associated to this item
182 * at the desired screen position
184 void ContextMenu(int x, int y);
187 * Shows the main widget and try to position it on top
188 * of the other windows, if the widget is already visible, hide it.
190 void Activate(int x, int y);
193 * The user activated the item in an alternate way (for instance with middle mouse button, this depends from the systray implementation)
195 void SecondaryActivate(int x, int y);
198 * Inform this item that the mouse wheel was used on its representation
200 void Scroll(int delta, const QString& orientation);
204 * Inform the systemtray that the own main icon has been changed,
205 * so should be reloaded
210 * Inform the systemtray that there is a new icon to be used as overlay
212 void NewOverlayIcon();
215 * Inform the systemtray that the requesting attention icon
216 * has been changed, so should be reloaded
218 void NewAttentionIcon();
221 * Inform the systemtray that something in the tooltip has been changed
226 * Signal the new status when it has been changed
229 void NewStatus(const QString& status);
232 StatusNotifierItem* m_statusNotifierItem;
233 QDBusConnection m_dbus;
234 static int s_serviceCount;
237 const QDBusArgument& operator<<(QDBusArgument& argument, const DBusImageStruct& icon);
238 const QDBusArgument& operator>>(const QDBusArgument& argument, DBusImageStruct& icon);
240 Q_DECLARE_METATYPE(DBusImageStruct)
242 const QDBusArgument& operator<<(QDBusArgument& argument, const DBusImageVector& iconVector);
243 const QDBusArgument& operator>>(const QDBusArgument& argument, DBusImageVector& iconVector);
245 Q_DECLARE_METATYPE(DBusImageVector)
247 const QDBusArgument& operator<<(QDBusArgument& argument, const DBusToolTipStruct& toolTip);
248 const QDBusArgument& operator>>(const QDBusArgument& argument, DBusToolTipStruct& toolTip);
250 Q_DECLARE_METATYPE(DBusToolTipStruct)