Allow configuration of shortcuts for platforms other than KDE
[quassel.git] / src / qtui / statusnotifieritemdbus.h
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 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.                                   *
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  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, 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
67     friend class StatusNotifierItem;
68 public:
69     StatusNotifierItemDBus(StatusNotifierItem *parent);
70     ~StatusNotifierItemDBus();
71
72     /**
73      * Register the service to DBus
74      */
75     void registerService();
76
77     /**
78      * Unregister the service from DBus
79      */
80     void unregisterService();
81
82     /**
83      * @return the service this object is registered on the bus under
84      */
85     QString service() const;
86
87     /**
88      * @return the category of the application associated to this item
89      * @see Category
90      */
91     QString Category() const;
92
93     /**
94      * @return the id of this item
95      */
96     QString Id() const;
97
98     /**
99      * @return the title of this item
100      */
101     QString Title() const;
102
103     /**
104      * @return The status of this item
105      * @see Status
106      */
107     QString Status() const;
108
109     /**
110      * @return The id of the main window of the application that controls the item
111      */
112     int WindowId() const;
113
114     /**
115      * @return the name of the main icon to be displayed
116      * if image() is not empty this will always return an empty string
117      */
118     QString IconName() const;
119
120     /**
121      * @return a serialization of the icon data
122      */
123     DBusImageVector IconPixmap() const;
124
125     /**
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
128      */
129     QString OverlayIconName() const;
130
131     /**
132      * @return a serialization of the icon data
133      */
134     DBusImageVector OverlayIconPixmap() const;
135
136     /**
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
140      */
141     QString AttentionIconName() const;
142
143     /**
144      * @return a serialization of the requesting attention icon data
145      */
146     DBusImageVector AttentionIconPixmap() const;
147
148     /**
149      * @return the name of the attention movie
150      */
151     QString AttentionMovieName() const;
152
153     /**
154      * all the data needed for a tooltip
155      */
156     DBusToolTipStruct ToolTip() const;
157
158
159 public Q_SLOTS:
160     //interaction
161     /**
162      * Shows the context menu associated to this item
163      * at the desired screen position
164      */
165     void ContextMenu(int x, int y);
166
167     /**
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.
170      */
171     void Activate(int x, int y);
172
173     /**
174      * The user activated the item in an alternate way (for instance with middle mouse button, this depends from the systray implementation)
175      */
176     void SecondaryActivate(int x, int y);
177
178     /**
179      * Inform this item that the mouse wheel was used on its representation
180      */
181     void Scroll(int delta, const QString &orientation);
182
183 Q_SIGNALS:
184     /**
185      * Inform the systemtray that the own main icon has been changed,
186      * so should be reloaded
187      */
188     void NewIcon();
189
190     /**
191      * Inform the systemtray that there is a new icon to be used as overlay
192      */
193     void NewOverlayIcon();
194
195     /**
196      * Inform the systemtray that the requesting attention icon
197      * has been changed, so should be reloaded
198      */
199     void NewAttentionIcon();
200
201     /**
202      * Inform the systemtray that something in the tooltip has been changed
203      */
204     void NewToolTip();
205
206     /**
207      * Signal the new status when it has been changed
208      * @see Status
209      */
210     void NewStatus(const QString &status);
211
212 private:
213     StatusNotifierItem *m_statusNotifierItem;
214     QString m_service;
215     QDBusConnection m_dbus;
216     static int s_serviceCount;
217 };
218
219
220 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageStruct &icon);
221 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageStruct &icon);
222
223 Q_DECLARE_METATYPE(DBusImageStruct)
224
225 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusImageVector &iconVector);
226 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImageVector &iconVector);
227
228 Q_DECLARE_METATYPE(DBusImageVector)
229
230 const QDBusArgument &operator<<(QDBusArgument &argument, const DBusToolTipStruct &toolTip);
231 const QDBusArgument &operator>>(const QDBusArgument &argument, DBusToolTipStruct &toolTip);
232
233 Q_DECLARE_METATYPE(DBusToolTipStruct)
234
235 #endif