Added support for dbusmenu
[dbusmenu:kdebase-workspace.git] / plasma / generic / dataengines / statusnotifieritem / statusnotifieritemsource.h
1 /***************************************************************************
2  *                                                                         *
3  *   Copyright (C) 2009 Marco Martin <notmart@gmail.com>                   *
4  *   Copyright (C) 2009 Matthieu Gallien <matthieu_gallien@yahoo.fr>       *
5  *                                                                         *
6  *   This program 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  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
20  ***************************************************************************/
21
22 #ifndef STATUSNOTIFIERITEMSOURCE_H
23 #define STATUSNOTIFIERITEMSOURCE_H
24
25 #include <Plasma/DataContainer>
26 #include <QString>
27 #include <QDBusPendingCallWatcher>
28
29 #include "statusnotifieritem_interface.h"
30
31 class KIconLoader;
32
33 class DBusMenuImporter;
34
35 class StatusNotifierItemSource : public Plasma::DataContainer
36 {
37
38     Q_OBJECT
39
40 public:
41     StatusNotifierItemSource(const QString &service, QObject *parent);
42     ~StatusNotifierItemSource();
43     Plasma::Service *createService();
44
45     void activate(int x, int y);
46     void secondaryActivate(int x, int y);
47     void scroll(int delta, const QString &direction);
48     void contextMenu(int x, int y);
49
50 private slots:
51
52     void refresh();
53     void syncStatus(QString);
54     void refreshCallback(QDBusPendingCallWatcher *);
55
56 private:
57
58     QPixmap KDbusImageStructToPixmap(const KDbusImageStruct &image) const;
59     QIcon imageVectorToPixmap(const KDbusImageVector &vector) const;
60     void overlayIcon(QIcon *icon, QIcon *overlay);
61     KIconLoader *iconLoader() const;
62
63     bool m_valid;
64     QString m_typeId;
65     QString m_name;
66     KIconLoader *m_customIconLoader;
67     DBusMenuImporter *m_menuImporter;
68     org::kde::StatusNotifierItem *m_statusNotifierItemInterface;
69 };
70
71 #endif // STATUSNOTIFIERITEMSOURCE_H