Merge lp:~mitya57/appmenu-qt5/menus-and-systemtrayicons into lp:appmenu-qt5

Proposed by Dmitry Shachnev
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 28
Merged at revision: 29
Proposed branch: lp:~mitya57/appmenu-qt5/menus-and-systemtrayicons
Merge into: lp:appmenu-qt5
Diff against target: 1241 lines (+1139/-5)
13 files modified
src/appmenuplatformmenu.cpp (+129/-0)
src/appmenuplatformmenu.h (+59/-0)
src/appmenuplatformmenubar.cpp (+11/-2)
src/appmenuplatformmenuitem.cpp (+124/-0)
src/appmenuplatformmenuitem.h (+54/-0)
src/appmenuplatformsystemtrayicon.cpp (+235/-0)
src/appmenuplatformsystemtrayicon.h (+101/-0)
src/dbusstructures.cpp (+64/-0)
src/dbusstructures.h (+58/-0)
src/iconcache.cpp (+140/-0)
src/iconcache.h (+54/-0)
src/org.kde.StatusNotifierItem.xml (+96/-0)
src/src.pro (+14/-3)
To merge this branch: bzr merge lp:~mitya57/appmenu-qt5/menus-and-systemtrayicons
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
Indicator Applet Developers Pending
Review via email: mp+244545@code.launchpad.net

Commit message

Add implementations of QPlatformMenuItem, QPlatformMenu and QPlatformSystemTrayIcon.

Description of the change

This adds new AppMenuPlatformMenuItem, AppMenuPlatformMenu, AppMenuPlatformSystemTrayIcon classes and helper classes/methods. A result of all this is that QSystemTrayIcon is useful again on Ubuntu.

Please read the QLTBA (questions likely to be asked) in the commit message.

How to test it: you need either Qt 5.4 from ppa:canonical-qt5-edgers/qt5-beta2 or patched Qt 5.3 from ppa:mitya57/test2 (the patch will be in the next official upload). Running systray example from qtbase5-examples should be a good way to test it.

To post a comment you must log in.
27. By Dmitry Shachnev

Add AppMenuPlatformMenuItem and AppMenuPlatformMenu classes

Having these classes will allow us to implement missing functionality
for AppMenuPlatformMenuBar class, and also add a new class for system
tray icons (AppMenuPlatformSystemTrayIcon).

28. By Dmitry Shachnev

Add AppMenuPlatformSystemTrayIcon implementation

Q: What’s this for?
A: Currently Qt 5 desktop applications which try to display a system
   tray icon will fail to do so in Unity desktop, because we abandoned
   the old XEmbed-based tray. This branch will make it work again, and
   in a nicer way. As a side-effect, notifications will now work too.

Q: We already have sni-qt, why is this needed?
A: sni-qt was only working with Qt 4, it does not work with Qt 5.
   Actually, a big part of code in this commit is copied from sni-qt.

Q: Why not just port sni-qt to Qt 5, why this code should be here?
A: In Qt 5, features such as platform tray icon should be implemented
   using Qt Platform Abstraction (QPA), which was not the case in Qt 4.
   More important, things like platform menu bar and platform tray icon
   should be in the same plugin, called “platform theme”. There should be
   only one platform theme for a platform, in Ubuntu it is appmenu-qt5.

Q: So is it just a copy of sni-qt code?
A: Most of it is based on sni-qt code, but it was changed a lot to work
   with Qt 5 and QPA interface. I also cleaned it up a bit and deleted
   some stuff that I think is not relevant.

Q: Does it add any additional dependencies to appmenu-qt5?
A: No. The only third-party library it needs is libdbusmenu-qt5, which
   is already used by appmenu-qt5.

Q: How does it work?
A: There are two things we should export — the “status notifier item”
   (which contains icon, tooltip, etc) and the menu. While the status
   notifier item will work with any server-side implementation, the menu
   will only work with ours (indicator-application). When
   indicator-application sees that an item has a menu, it will convert
   it into an indicator, and any indicator renderer (such as Unity, or
   indicator-applet) will show it.

Q: Which desktop environments will it work with?
A: It is designed to work with anything that supports indicators, like
   Unity or GNOME Flashback.

Q: Why the interface has KDE in name?
A: The StatusNotifierItem was originally developed by KDE project. While
   it is very possible that this standard will be adopted by FreeDesktop,
   indicator-application currently only supports the KDE name.

Q: Can KDE reuse this implementation?
A: They already have their own implementation, in Framework Integration.
   I could not reuse their code because they have not signed the
   Canonical contributor license agreement.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

This is ready for review now.

Note that this is disabled for KDE, as it is not going to work properly there. I think we should drop the KDE support altogether, as KDE now has its own platform theme and these two will conflict.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Looks really good so far. I would like to do a few additional tests tomorrow morning still. Come to think of it, maybe soon we might need to think of changing the name from appmenu-qt5 to something more 'ubuntu-generic'.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Yes, I want to get bug 1378935 fixed (when I have time for it), and after that it will become a full-featured platform theme. Maybe ubuntu-qt5-platform-theme will be a good name for it.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

I have just been pointed to https://codereview.qt-project.org/102386, which makes this whole branch unneeded. However it has not been merged yes, and if it is merged, in may or may not land in Qt 5.5. So let's keep my implementation until we have that new Qt (5.5 or 5.6) in Ubuntu.

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

Ok, the code looks good. I didn't know too much of the old sni-qt code, but it seems everything we need is now included here as well. And let's not worry about future plans for Qt5, we can deprecate this when the need arises. For this cycle we're targeting 5.4 and I'm not sure if we'd jump to an even higher revision before release still.

review: Approve
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Hi Łukasz, are you going to land my branches, or should I take care of that? (Or do you have other pending changes?)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'src/appmenuplatformmenu.cpp'
--- src/appmenuplatformmenu.cpp 1970-01-01 00:00:00 +0000
+++ src/appmenuplatformmenu.cpp 2014-12-13 15:39:31 +0000
@@ -0,0 +1,129 @@
1/*
2 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, version 3 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "appmenuplatformmenuitem.h"
18#include "appmenuplatformmenu.h"
19
20AppMenuPlatformMenu::AppMenuPlatformMenu():
21 m_menu(new QMenu()),
22 m_tag(0)
23{
24 connect(m_menu, &QMenu::aboutToShow, this, &QPlatformMenu::aboutToShow);
25 connect(m_menu, &QMenu::aboutToHide, this, &QPlatformMenu::aboutToHide);
26}
27
28AppMenuPlatformMenu::~AppMenuPlatformMenu()
29{
30 delete m_menu;
31}
32
33void AppMenuPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before)
34{
35 AppMenuPlatformMenuItem *myMenuItem = qobject_cast<AppMenuPlatformMenuItem *>(menuItem);
36 AppMenuPlatformMenuItem *myBefore = qobject_cast<AppMenuPlatformMenuItem *>(before);
37
38 QAction *beforeAction = myBefore ? myBefore->m_action : Q_NULLPTR;
39 m_menu->insertAction(beforeAction, myMenuItem->m_action);
40
41 if (!myBefore) {
42 m_menuitems.append(myMenuItem);
43 return;
44 }
45
46 for (int i = 0; i < m_menuitems.size(); ++i) {
47 if (m_menuitems.at(i)->m_action == beforeAction) {
48 m_menuitems.insert(i, myMenuItem);
49 return;
50 }
51 }
52}
53
54void AppMenuPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem)
55{
56 AppMenuPlatformMenuItem *myMenuItem = qobject_cast<AppMenuPlatformMenuItem *>(menuItem);
57 m_menuitems.removeOne(myMenuItem);
58 m_menu->removeAction(myMenuItem->m_action);
59}
60
61void AppMenuPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem)
62{
63 Q_UNUSED(menuItem);
64}
65
66void AppMenuPlatformMenu::syncSeparatorsCollapsible(bool enable)
67{
68 m_menu->setSeparatorsCollapsible(enable);
69}
70
71void AppMenuPlatformMenu::setTag(quintptr tag)
72{
73 m_tag = tag;
74}
75
76quintptr AppMenuPlatformMenu::tag() const
77{
78 return m_tag;
79}
80
81void AppMenuPlatformMenu::setText(const QString &text)
82{
83 m_menu->setTitle(text);
84}
85
86void AppMenuPlatformMenu::setIcon(const QIcon &icon)
87{
88 m_menu->setIcon(icon);
89}
90
91void AppMenuPlatformMenu::setEnabled(bool enabled)
92{
93 m_menu->setEnabled(enabled);
94}
95
96void AppMenuPlatformMenu::setVisible(bool visible)
97{
98 m_menu->setVisible(visible);
99}
100
101void AppMenuPlatformMenu::setMinimumWidth(int width)
102{
103 m_menu->setMinimumWidth(width);
104}
105
106void AppMenuPlatformMenu::setFont(const QFont &font)
107{
108 m_menu->setFont(font);
109}
110
111QPlatformMenuItem *AppMenuPlatformMenu::menuItemAt(int position) const
112{
113 return m_menuitems.at(position);
114}
115
116QPlatformMenuItem *AppMenuPlatformMenu::menuItemForTag(quintptr tag) const
117{
118 foreach (AppMenuPlatformMenuItem *item, m_menuitems) {
119 if (item->m_tag == tag) {
120 return item;
121 }
122 }
123 return Q_NULLPTR;
124}
125
126QPlatformMenuItem *AppMenuPlatformMenu::createMenuItem() const
127{
128 return new AppMenuPlatformMenuItem();
129}
0130
=== added file 'src/appmenuplatformmenu.h'
--- src/appmenuplatformmenu.h 1970-01-01 00:00:00 +0000
+++ src/appmenuplatformmenu.h 2014-12-13 15:39:31 +0000
@@ -0,0 +1,59 @@
1/*
2 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, version 3 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef APPMENUPLATFORMMENU_H
18#define APPMENUPLATFORMMENU_H
19
20#include <QtCore/qlist.h>
21#include <QtWidgets/qmenu.h>
22#include <qpa/qplatformmenu.h>
23#include "appmenuplatformmenuitem.h"
24
25class AppMenuPlatformMenu : public QPlatformMenu
26{
27 Q_OBJECT
28 friend class AppMenuPlatformMenuItem;
29 friend class AppMenuPlatformSystemTrayIcon;
30
31public:
32 AppMenuPlatformMenu();
33 virtual ~AppMenuPlatformMenu();
34
35 virtual void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before);
36 virtual void removeMenuItem(QPlatformMenuItem *menuItem);
37 virtual void syncMenuItem(QPlatformMenuItem *menuItem);
38 virtual void syncSeparatorsCollapsible(bool enable);
39 virtual void setTag(quintptr tag);
40 virtual quintptr tag() const;
41 virtual void setText(const QString &text);
42 virtual void setIcon(const QIcon &icon);
43 virtual void setEnabled(bool enabled);
44 virtual void setVisible(bool visible);
45 virtual void setMinimumWidth(int width);
46 virtual void setFont(const QFont &font);
47 virtual QPlatformMenuItem *menuItemAt(int position) const;
48 virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const;
49 virtual QPlatformMenuItem *createMenuItem() const;
50
51private:
52 Q_DISABLE_COPY(AppMenuPlatformMenu)
53
54 QMenu *m_menu;
55 QList<AppMenuPlatformMenuItem *> m_menuitems;
56 quintptr m_tag;
57};
58
59#endif /* APPMENUPLATFORMMENU_H */
060
=== modified file 'src/appmenuplatformmenubar.cpp'
--- src/appmenuplatformmenubar.cpp 2014-11-24 15:17:32 +0000
+++ src/appmenuplatformmenubar.cpp 2014-12-13 15:39:31 +0000
@@ -17,6 +17,8 @@
17 */17 */
1818
19#include "appmenuplatformmenubar.h"19#include "appmenuplatformmenubar.h"
20#include "appmenuplatformmenuitem.h"
21#include "appmenuplatformsystemtrayicon.h"
20#include "registrar_interface.h"22#include "registrar_interface.h"
2123
22// Ugly, but sadly we need to use private headers for desktop-theme related classes24// Ugly, but sadly we need to use private headers for desktop-theme related classes
@@ -243,9 +245,14 @@
243{245{
244public:246public:
245 GnomeAppMenuPlatformTheme();247 GnomeAppMenuPlatformTheme();
246 virtual QPlatformMenuItem* createPlatformMenuItem() const { return 0; }248 virtual QPlatformMenuItem* createPlatformMenuItem() const {
249 return new AppMenuPlatformMenuItem();
250 }
247 virtual QPlatformMenu* createPlatformMenu() const { return 0; }251 virtual QPlatformMenu* createPlatformMenu() const { return 0; }
248 virtual QPlatformMenuBar* createPlatformMenuBar() const;252 virtual QPlatformMenuBar* createPlatformMenuBar() const;
253 virtual QPlatformSystemTrayIcon* createPlatformSystemTrayIcon() const {
254 return new AppMenuPlatformSystemTrayIcon();
255 }
249256
250 virtual QVariant themeHint(QPlatformTheme::ThemeHint hint) const;257 virtual QVariant themeHint(QPlatformTheme::ThemeHint hint) const;
251};258};
@@ -304,7 +311,9 @@
304 {311 {
305 }312 }
306#endif313#endif
307 virtual QPlatformMenuItem* createPlatformMenuItem() const { return 0; }314 virtual QPlatformMenuItem* createPlatformMenuItem() const {
315 return new AppMenuPlatformMenuItem();
316 }
308 virtual QPlatformMenu* createPlatformMenu() const { return 0; }317 virtual QPlatformMenu* createPlatformMenu() const { return 0; }
309 virtual QPlatformMenuBar* createPlatformMenuBar() const;318 virtual QPlatformMenuBar* createPlatformMenuBar() const;
310};319};
311320
=== added file 'src/appmenuplatformmenuitem.cpp'
--- src/appmenuplatformmenuitem.cpp 1970-01-01 00:00:00 +0000
+++ src/appmenuplatformmenuitem.cpp 2014-12-13 15:39:31 +0000
@@ -0,0 +1,124 @@
1/*
2 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, version 3 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "appmenuplatformmenuitem.h"
18#include "appmenuplatformmenu.h"
19
20AppMenuPlatformMenuItem::AppMenuPlatformMenuItem():
21 m_action(new QAction(this)),
22 m_tag(0)
23{
24 connect(m_action, &QAction::triggered, this, &QPlatformMenuItem::activated);
25 connect(m_action, &QAction::hovered, this, &QPlatformMenuItem::hovered);
26}
27
28AppMenuPlatformMenuItem::~AppMenuPlatformMenuItem()
29{
30 delete m_action;
31}
32
33void AppMenuPlatformMenuItem::setTag(quintptr tag)
34{
35 m_tag = tag;
36}
37
38quintptr AppMenuPlatformMenuItem::tag() const
39{
40 return m_tag;
41}
42
43void AppMenuPlatformMenuItem::setText(const QString &text)
44{
45 m_action->setText(text);
46}
47
48void AppMenuPlatformMenuItem::setIcon(const QIcon &icon)
49{
50 m_action->setIcon(icon);
51}
52
53void AppMenuPlatformMenuItem::setMenu(QPlatformMenu *menu)
54{
55 if (menu) {
56 AppMenuPlatformMenu *myMenu = qobject_cast<AppMenuPlatformMenu *>(menu);
57 m_action->setMenu(myMenu->m_menu);
58 }
59}
60
61void AppMenuPlatformMenuItem::setVisible(bool isVisible)
62{
63 m_action->setVisible(isVisible);
64}
65
66void AppMenuPlatformMenuItem::setIsSeparator(bool isSeparator)
67{
68 m_action->setSeparator(isSeparator);
69}
70
71void AppMenuPlatformMenuItem::setFont(const QFont &font)
72{
73 m_action->setFont(font);
74}
75
76void AppMenuPlatformMenuItem::setRole(MenuRole role)
77{
78 QAction::MenuRole newRole;
79 switch (role) {
80 case TextHeuristicRole:
81 newRole = QAction::TextHeuristicRole;
82 break;
83 case ApplicationSpecificRole:
84 newRole = QAction::ApplicationSpecificRole;
85 break;
86 case AboutRole:
87 newRole = QAction::AboutRole;
88 break;
89 case PreferencesRole:
90 newRole = QAction::PreferencesRole;
91 break;
92 case QuitRole:
93 newRole = QAction::QuitRole;
94 break;
95 default:
96 newRole = QAction::NoRole;
97 }
98 m_action->setMenuRole(newRole);
99}
100
101void AppMenuPlatformMenuItem::setCheckable(bool checkable)
102{
103 m_action->setCheckable(checkable);
104}
105
106void AppMenuPlatformMenuItem::setChecked(bool isChecked)
107{
108 m_action->setChecked(isChecked);
109}
110
111void AppMenuPlatformMenuItem::setShortcut(const QKeySequence& shortcut)
112{
113 m_action->setShortcut(shortcut);
114}
115
116void AppMenuPlatformMenuItem::setEnabled(bool enabled)
117{
118 m_action->setEnabled(enabled);
119}
120
121void AppMenuPlatformMenuItem::setIconSize(int size)
122{
123 Q_UNUSED(size);
124}
0125
=== added file 'src/appmenuplatformmenuitem.h'
--- src/appmenuplatformmenuitem.h 1970-01-01 00:00:00 +0000
+++ src/appmenuplatformmenuitem.h 2014-12-13 15:39:31 +0000
@@ -0,0 +1,54 @@
1/*
2 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, version 3 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef APPMENUPLATFORMMENUITEM_H
18#define APPMENUPLATFORMMENUITEM_H
19
20#include <QtWidgets/qaction.h>
21#include <qpa/qplatformmenu.h>
22
23class AppMenuPlatformMenuItem : public QPlatformMenuItem
24{
25 Q_OBJECT
26 friend class AppMenuPlatformMenu;
27
28public:
29 AppMenuPlatformMenuItem();
30 virtual ~AppMenuPlatformMenuItem();
31
32 virtual void setTag(quintptr tag);
33 virtual quintptr tag() const;
34 virtual void setText(const QString &text);
35 virtual void setIcon(const QIcon &icon);
36 virtual void setMenu(QPlatformMenu *menu);
37 virtual void setVisible(bool isVisible);
38 virtual void setIsSeparator(bool isSeparator);
39 virtual void setFont(const QFont &font);
40 virtual void setRole(MenuRole role);
41 virtual void setCheckable(bool checkable);
42 virtual void setChecked(bool isChecked);
43 virtual void setShortcut(const QKeySequence& shortcut);
44 virtual void setEnabled(bool enabled);
45 virtual void setIconSize(int size);
46
47private:
48 Q_DISABLE_COPY(AppMenuPlatformMenuItem)
49
50 QAction *m_action;
51 quintptr m_tag;
52};
53
54#endif /* APPMENUPLATFORMMENUITEM_H */
055
=== added file 'src/appmenuplatformsystemtrayicon.cpp'
--- src/appmenuplatformsystemtrayicon.cpp 1970-01-01 00:00:00 +0000
+++ src/appmenuplatformsystemtrayicon.cpp 2014-12-13 15:39:31 +0000
@@ -0,0 +1,235 @@
1/*
2 * Copyright 2011 Canonical Ltd.
3 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, version 3 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Based on sni-qt code by Aurelien Gateau <aurelien.gateau@canonical.com>.
18 */
19
20#include <QtCore/qcoreapplication.h>
21#include <QtDBus/qdbusconnection.h>
22#include <QtDBus/qdbusconnectioninterface.h>
23#include <QtDBus/qdbusinterface.h>
24#include "appmenuplatformmenu.h"
25#include "appmenuplatformsystemtrayicon.h"
26#include "iconcache.h"
27
28static const char *SNW_INTERFACE = "org.kde.StatusNotifierWatcher";
29static const char *SNW_SERVICE = "org.kde.StatusNotifierWatcher";
30static const char *SNW_PATH = "/StatusNotifierWatcher";
31
32static const char *NOTIFICATION_INTERFACE = "org.freedesktop.Notifications";
33static const char *NOTIFICATION_SERVICE = "org.freedesktop.Notifications";
34static const char *NOTIFICATION_PATH = "/org/freedesktop/Notifications";
35
36static IconCache iconCache;
37
38AppMenuPlatformSystemTrayIcon::AppMenuPlatformSystemTrayIcon():
39 m_sniAdaptor(new StatusNotifierItemAdaptor(this)),
40 m_dbusMenuExporter(Q_NULLPTR)
41{
42 static int id = 1;
43 m_objectPath = QString("/org/kde/statusnotifieritem/%1").arg(id++);
44
45 registerMetaTypes();
46 QDBusConnection bus = QDBusConnection::sessionBus();
47 bus.registerObject(m_objectPath, this, QDBusConnection::ExportAdaptors);
48 QDBusInterface snw(SNW_SERVICE, SNW_PATH, SNW_INTERFACE);
49 snw.asyncCall("RegisterStatusNotifierItem", m_objectPath);
50}
51
52AppMenuPlatformSystemTrayIcon::~AppMenuPlatformSystemTrayIcon()
53{
54 delete m_sniAdaptor;
55}
56
57// QPlatformSystemTrayIcon implementation
58
59void AppMenuPlatformSystemTrayIcon::init()
60{
61 m_status = QStringLiteral("Active");
62 emit NewStatus(m_status);
63}
64
65void AppMenuPlatformSystemTrayIcon::cleanup()
66{
67 m_status = QStringLiteral("Passive");
68 emit NewStatus(m_status);
69}
70
71void AppMenuPlatformSystemTrayIcon::updateIcon(const QIcon &icon)
72{
73 m_icon = icon;
74 emit NewIcon();
75 emit NewToolTip(); // ToolTip contains the icon
76}
77
78void AppMenuPlatformSystemTrayIcon::updateToolTip(const QString &tooltip)
79{
80 m_tooltip = tooltip;
81 emit NewToolTip();
82}
83
84void AppMenuPlatformSystemTrayIcon::updateMenu(QPlatformMenu *menu)
85{
86 QMenu *qMenu = qobject_cast<AppMenuPlatformMenu *>(menu)->m_menu;
87 QString menuObjectPath = m_objectPath + QStringLiteral("/menu");
88 m_dbusMenuExporter = new DBusMenuExporter(menuObjectPath, qMenu);
89}
90
91QRect AppMenuPlatformSystemTrayIcon::geometry() const
92{
93 return QRect();
94}
95
96void AppMenuPlatformSystemTrayIcon::showMessage(const QString &title, const QString &msg,
97 const QIcon &icon, MessageIcon iconType, int msecs)
98{
99 QString iconString = icon.name();
100 if (iconString.isEmpty()) {
101 switch (iconType) {
102 case NoIcon:
103 break;
104 case Information:
105 iconString = "dialog-information";
106 break;
107 case Warning:
108 iconString = "dialog-warning";
109 break;
110 case Critical:
111 iconString = "dialog-error";
112 break;
113 }
114 }
115
116 QDBusInterface iface(NOTIFICATION_SERVICE, NOTIFICATION_PATH, NOTIFICATION_INTERFACE);
117 iface.asyncCall("Notify",
118 id(),
119 quint32(0), // replaces_id
120 iconString,
121 title,
122 msg,
123 QStringList(), // actions
124 QVariantMap(), // hints
125 msecs); // timeout
126}
127
128bool AppMenuPlatformSystemTrayIcon::isSystemTrayAvailable() const
129{
130 const QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface();
131 if (!interface->isServiceRegistered(SNW_SERVICE).value()) {
132 return false;
133 }
134 QDBusInterface snw(SNW_SERVICE, SNW_PATH, SNW_INTERFACE);
135 QVariant value = snw.property("IsStatusNotifierHostRegistered");
136 if (!value.canConvert<bool>()) {
137 return false;
138 }
139 return value.toBool();
140}
141
142bool AppMenuPlatformSystemTrayIcon::supportsMessages() const
143{
144 const QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface();
145 return interface->isServiceRegistered(NOTIFICATION_SERVICE).value();
146}
147
148QPlatformMenu *AppMenuPlatformSystemTrayIcon::createMenu() const
149{
150 return new AppMenuPlatformMenu();
151}
152
153// Properties
154
155QString AppMenuPlatformSystemTrayIcon::category() const
156{
157 return QStringLiteral("ApplicationStatus");
158}
159
160QString AppMenuPlatformSystemTrayIcon::id() const
161{
162 return QCoreApplication::applicationFilePath().section('/', -1);
163}
164
165QString AppMenuPlatformSystemTrayIcon::title() const
166{
167 QString title = QCoreApplication::applicationName();
168 return title.isEmpty() ? id() : title;
169}
170
171QString AppMenuPlatformSystemTrayIcon::status() const
172{
173 return m_status;
174}
175
176QString AppMenuPlatformSystemTrayIcon::iconThemePath() const
177{
178 return iconCache.themePath();
179}
180
181QString AppMenuPlatformSystemTrayIcon::iconName() const
182{
183 if (m_icon.isNull()) {
184 return QString();
185 }
186 QString name = m_icon.name();
187 if (!name.isEmpty()) {
188 return name;
189 }
190
191 return iconCache.nameForIcon(m_icon);
192}
193
194DBusToolTip AppMenuPlatformSystemTrayIcon::toolTip() const
195{
196 DBusToolTip tip;
197 tip.iconName = iconName();
198 tip.title = m_tooltip;
199 return tip;
200}
201
202QDBusObjectPath AppMenuPlatformSystemTrayIcon::menu() const
203{
204 return m_dbusMenuExporter
205 ? QDBusObjectPath(m_objectPath + QStringLiteral("/menu"))
206 : QDBusObjectPath("/invalid");
207}
208
209// StatusNotifierItem implementation
210
211void AppMenuPlatformSystemTrayIcon::ContextMenu(int x, int y)
212{
213 Q_UNUSED(x);
214 Q_UNUSED(y);
215}
216
217void AppMenuPlatformSystemTrayIcon::Activate(int x, int y)
218{
219 Q_UNUSED(x);
220 Q_UNUSED(y);
221 emit activated(Trigger);
222}
223
224void AppMenuPlatformSystemTrayIcon::SecondaryActivate(int x, int y)
225{
226 Q_UNUSED(x);
227 Q_UNUSED(y);
228 emit activated(MiddleClick);
229}
230
231void AppMenuPlatformSystemTrayIcon::Scroll(int delta, const QString& orientation)
232{
233 Q_UNUSED(delta);
234 Q_UNUSED(orientation);
235}
0236
=== added file 'src/appmenuplatformsystemtrayicon.h'
--- src/appmenuplatformsystemtrayicon.h 1970-01-01 00:00:00 +0000
+++ src/appmenuplatformsystemtrayicon.h 2014-12-13 15:39:31 +0000
@@ -0,0 +1,101 @@
1/*
2 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, version 3 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef APPMENUPLATFORMSYSTEMTRAYICON_H
18#define APPMENUPLATFORMSYSTEMTRAYICON_H
19
20#include <QtCore/qrect.h>
21#include <QtCore/qstring.h>
22#include <QtGui/qicon.h>
23#include <qpa/qplatformsystemtrayicon.h>
24#include <dbusmenuexporter.h>
25#include "statusnotifieritem_adaptor.h"
26
27class AppMenuPlatformSystemTrayIcon : public QPlatformSystemTrayIcon
28{
29 Q_OBJECT
30 Q_PROPERTY(QString Category READ category)
31 Q_PROPERTY(QString Id READ id)
32 Q_PROPERTY(QString Title READ title)
33 Q_PROPERTY(QString Status READ status)
34 Q_PROPERTY(quint32 WindowId READ windowId)
35 Q_PROPERTY(QString IconThemePath READ iconThemePath)
36 Q_PROPERTY(QString IconName READ iconName)
37 Q_PROPERTY(DBusImageList IconPixmap READ iconPixmap)
38 Q_PROPERTY(QString OverlayIconName READ overlayIconName)
39 Q_PROPERTY(DBusImageList OverlayIconPixmap READ overlayIconPixmap)
40 Q_PROPERTY(QString AttentionIconName READ attentionIconName)
41 Q_PROPERTY(DBusImageList AttentionIconPixmap READ attentionIconPixmap)
42 Q_PROPERTY(QString AttentionMovieName READ attentionMovieName)
43 Q_PROPERTY(DBusToolTip ToolTip READ toolTip)
44 Q_PROPERTY(QDBusObjectPath Menu READ menu)
45
46public:
47 AppMenuPlatformSystemTrayIcon();
48 virtual ~AppMenuPlatformSystemTrayIcon();
49
50 // QPlatformSystemTrayIcon
51 virtual void init();
52 virtual void cleanup();
53 virtual void updateIcon(const QIcon &icon);
54 virtual void updateToolTip(const QString &tooltip);
55 virtual void updateMenu(QPlatformMenu *menu);
56 virtual QRect geometry() const;
57 virtual void showMessage(const QString &title, const QString &msg,
58 const QIcon &icon, MessageIcon iconType, int msecs);
59 virtual bool isSystemTrayAvailable() const;
60 virtual bool supportsMessages() const;
61 virtual QPlatformMenu *createMenu() const;
62
63 // Properties
64 QString category() const;
65 QString id() const;
66 QString title() const;
67 QString status() const;
68 quint32 windowId() const { return 0; }
69 QString iconThemePath() const;
70 QString iconName() const;
71 DBusImageList iconPixmap() const { return DBusImageList(); }
72 QString overlayIconName() const { return QString(); }
73 DBusImageList overlayIconPixmap() const { return DBusImageList(); }
74 QString attentionIconName() const { return QString(); }
75 DBusImageList attentionIconPixmap() const { return DBusImageList(); }
76 QString attentionMovieName() const { return QString(); }
77 DBusToolTip toolTip() const;
78 QDBusObjectPath menu() const;
79
80 // StatusNotifierItem
81 void ContextMenu(int x, int y);
82 void Activate(int x, int y);
83 void SecondaryActivate(int x, int y);
84 void Scroll(int delta, const QString& orientation);
85
86Q_SIGNALS:
87 void NewStatus(const QString &status);
88 void NewIcon();
89 void NewToolTip();
90
91private:
92 QString m_objectPath;
93 QString m_status;
94 QIcon m_icon;
95 QString m_tooltip;
96
97 StatusNotifierItemAdaptor *m_sniAdaptor;
98 DBusMenuExporter *m_dbusMenuExporter;
99};
100
101#endif /* APPMENUPLATFORMSYSTEMTRAYICON_H */
0102
=== added file 'src/dbusstructures.cpp'
--- src/dbusstructures.cpp 1970-01-01 00:00:00 +0000
+++ src/dbusstructures.cpp 2014-12-13 15:39:31 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2011 Canonical Ltd.
3 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, version 3 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Based on sni-qt code by Aurelien Gateau <aurelien.gateau@canonical.com>.
18 */
19
20#include <QtDBus/qdbusmetatype.h>
21#include "dbusstructures.h"
22
23QDBusArgument &operator<<(QDBusArgument &argument, const DBusImage &image)
24{
25 argument.beginStructure();
26 argument << image.width << image.height << image.pixels;
27 argument.endStructure();
28 return argument;
29}
30
31const QDBusArgument &operator>>(const QDBusArgument &argument, DBusImage &image)
32{
33 argument.beginStructure();
34 argument >> image.width >> image.height >> image.pixels;
35 argument.endStructure();
36 return argument;
37}
38
39QDBusArgument &operator<<(QDBusArgument &argument, const DBusToolTip &tip)
40{
41 argument.beginStructure();
42 argument << tip.iconName << tip.iconPixmap << tip.title << tip.description;
43 argument.endStructure();
44 return argument;
45}
46
47const QDBusArgument &operator>>(const QDBusArgument &argument, DBusToolTip &tip)
48{
49 argument.beginStructure();
50 argument >> tip.iconName >> tip.iconPixmap >> tip.title >> tip.description;
51 argument.endStructure();
52 return argument;
53}
54
55void registerMetaTypes()
56{
57 static bool registered = false;
58 if (registered) {
59 return;
60 }
61 qDBusRegisterMetaType<DBusImage>();
62 qDBusRegisterMetaType<DBusImageList>();
63 qDBusRegisterMetaType<DBusToolTip>();
64}
065
=== added file 'src/dbusstructures.h'
--- src/dbusstructures.h 1970-01-01 00:00:00 +0000
+++ src/dbusstructures.h 2014-12-13 15:39:31 +0000
@@ -0,0 +1,58 @@
1/*
2 * Copyright 2011 Canonical Ltd.
3 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, version 3 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Based on sni-qt code by Aurelien Gateau <aurelien.gateau@canonical.com>.
18 */
19
20#ifndef DBUSSTRUCTURES_H
21#define DBUSSTRUCTURES_H
22
23#include <QtCore/qbytearray.h>
24#include <QtCore/qstring.h>
25#include <QtCore/qlist.h>
26#include <QtGui/qicon.h>
27#include <QtGui/qpixmap.h>
28#include <QtDBus/qdbusargument.h>
29
30struct DBusImage
31{
32 int width;
33 int height;
34 QByteArray pixels;
35};
36Q_DECLARE_METATYPE(DBusImage)
37
38typedef QList<DBusImage> DBusImageList;
39Q_DECLARE_METATYPE(DBusImageList)
40
41struct DBusToolTip
42{
43 QString iconName;
44 DBusImageList iconPixmap;
45 QString title;
46 QString description;
47};
48Q_DECLARE_METATYPE(DBusToolTip)
49
50QDBusArgument &operator<<(QDBusArgument&, const DBusImage&);
51const QDBusArgument &operator>>(const QDBusArgument&, DBusImage&);
52
53QDBusArgument &operator<<(QDBusArgument&, const DBusToolTip&);
54const QDBusArgument &operator>>(const QDBusArgument&, DBusToolTip&);
55
56void registerMetaTypes();
57
58#endif /* DBUSSTRUCTURES_H */
059
=== added file 'src/iconcache.cpp'
--- src/iconcache.cpp 1970-01-01 00:00:00 +0000
+++ src/iconcache.cpp 2014-12-13 15:39:31 +0000
@@ -0,0 +1,140 @@
1/*
2 * Copyright 2011 Canonical Ltd.
3 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, version 3 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Based on sni-qt code by Aurelien Gateau <aurelien.gateau@canonical.com>.
18 */
19
20#include <sys/types.h>
21#include <utime.h>
22#include <QtCore/qcoreapplication.h>
23#include <QtCore/qdatetime.h>
24#include <QtCore/qdebug.h>
25#include <QtCore/qdir.h>
26#include "iconcache.h"
27
28const int IconCache::MaxIconCount = 20;
29
30IconCache::IconCache(QObject *parent):
31 QObject(parent),
32 m_temporaryDir(Q_NULLPTR),
33 m_initialized(false)
34{
35}
36
37IconCache::~IconCache()
38{
39 if (m_temporaryDir) {
40 delete m_temporaryDir;
41 }
42}
43
44QString IconCache::themePath()
45{
46 if (!m_initialized) {
47 QString path = QDir::tempPath() + QStringLiteral("/iconcache-XXXXXX");
48 m_temporaryDir = new QTemporaryDir(path);
49 m_initialized = true;
50 }
51 return m_temporaryDir->path();
52}
53
54QString IconCache::nameForIcon(const QIcon &icon)
55{
56 if (icon.isNull()) {
57 return QString();
58 }
59
60 qint64 key = icon.cacheKey();
61 QList<qint64>::iterator it = qFind(m_cacheKeys.begin(), m_cacheKeys.end(), key);
62 if (it == m_cacheKeys.end()) {
63 cacheIcon(key, icon);
64 trimCache();
65 } else {
66 // Place key at the end of list as it is the most recently accessed
67 m_cacheKeys.erase(it);
68 m_cacheKeys.append(key);
69 }
70
71 return QString::number(key);
72}
73
74void IconCache::trimCache()
75{
76 QDir dir(themePath() + "/hicolor");
77 dir.setFilter(QDir::Dirs);
78
79 while (m_cacheKeys.count() > MaxIconCount) {
80 qint64 cacheKey = m_cacheKeys.takeFirst();
81
82 Q_FOREACH(const QString &sizeDir, dir.entryList()) {
83 QString iconSubPath = QString("%1/apps/%2.png").arg(sizeDir).arg(cacheKey);
84 if (dir.exists(iconSubPath)) {
85 dir.remove(iconSubPath);
86 }
87 }
88 }
89}
90
91void touch(const QString &_name, const QDateTime &time)
92{
93 QByteArray name = QFile::encodeName(_name);
94 struct utimbuf buf;
95 buf.actime = time.toTime_t();
96 buf.modtime = buf.actime;
97 int ret = utime(name.data(), &buf);
98 if (ret) {
99 qCritical("Failed to touch %s: %s", name.data(), strerror(errno));
100 }
101}
102
103void IconCache::cacheIcon(qint64 key, const QIcon &icon)
104{
105 QList<QSize> sizes; //= icon.availableSizes();
106 if (sizes.isEmpty()) {
107 // sizes can be empty if icon is an SVG. In this case generate images for a few sizes
108 sizes << QSize(16, 16) << QSize(22, 22) << QSize(32, 32) << QSize(48, 48);
109 }
110
111 QDir dir(themePath());
112 Q_FOREACH(const QSize &size, sizes) {
113 QPixmap pix = icon.pixmap(size);
114 QString dirName = QString("hicolor/%1x%1/apps").arg(size.width());
115 if (!dir.exists(dirName)) {
116 if (!dir.mkpath(dirName)) {
117 qWarning("Could not create '%s' dir in '%s'",
118 qPrintable(themePath()), qPrintable(dirName));
119 continue;
120 }
121 }
122 QString pixPath = QString("%1/%2/%3.png")
123 .arg(themePath()).arg(dirName).arg(key);
124 if (!pix.save(pixPath, "png")) {
125 qWarning("Could not save icon as '%s'", qPrintable(pixPath));
126 }
127 }
128
129 m_cacheKeys << key;
130
131 // Touch the theme path: GTK icon loading system checks the mtime of the
132 // dir to decide whether it should look for new icons in the theme dir.
133 //
134 // Note: We do not use QDateTime::currentDateTime() as the new time because
135 // if the icon is updated in less than one second, GTK won't notice it.
136 // See https://bugs.launchpad.net/sni-qt/+bug/812884
137 QFileInfo info(themePath());
138 QDateTime mtime = info.lastModified();
139 touch(themePath(), mtime.addSecs(1));
140}
0141
=== added file 'src/iconcache.h'
--- src/iconcache.h 1970-01-01 00:00:00 +0000
+++ src/iconcache.h 2014-12-13 15:39:31 +0000
@@ -0,0 +1,54 @@
1/*
2 * Copyright 2011 Canonical Ltd.
3 * Copyright 2014 Dmitry Shachnev <mitya57@ubuntu.com>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, version 3 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Based on sni-qt code by Aurelien Gateau <aurelien.gateau@canonical.com>.
18 */
19
20#ifndef ICONCACHE_H
21#define ICONCACHE_H
22
23#include <QtCore/qlist.h>
24#include <QtCore/qobject.h>
25#include <QtCore/qstring.h>
26#include <QtCore/qtemporarydir.h>
27#include <QtGui/qicon.h>
28
29/**
30 * This class will save pixmaps from icons in a temporary dir on the disk,
31 * making it possible to pass filenames for icons without names.
32 */
33class IconCache : public QObject
34{
35 Q_OBJECT
36public:
37 IconCache(QObject* parent=0);
38 ~IconCache();
39
40 static const int MaxIconCount;
41
42 QString themePath();
43 QString nameForIcon(const QIcon &icon);
44
45private:
46 QTemporaryDir *m_temporaryDir;
47 mutable QList<qint64> m_cacheKeys;
48 bool m_initialized;
49
50 void cacheIcon(qint64 key, const QIcon &);
51 void trimCache();
52};
53
54#endif /* ICONCACHE_H */
055
=== added file 'src/org.kde.StatusNotifierItem.xml'
--- src/org.kde.StatusNotifierItem.xml 1970-01-01 00:00:00 +0000
+++ src/org.kde.StatusNotifierItem.xml 2014-12-13 15:39:31 +0000
@@ -0,0 +1,96 @@
1<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
2<node>
3 <interface name="org.kde.StatusNotifierItem">
4
5 <property name="Category" type="s" access="read"/>
6 <property name="Id" type="s" access="read"/>
7 <property name="Title" type="s" access="read"/>
8 <property name="Status" type="s" access="read"/>
9 <property name="WindowId" type="i" access="read"/>
10
11 <!-- An additional path to add to the theme search path to find the icons specified above. -->
12 <property name="IconThemePath" type="s" access="read"/>
13 <property name="Menu" type="o" access="read"/>
14 <property name="ItemIsMenu" type="b" access="read"/>
15
16
17 <!-- main icon -->
18 <!-- names are preferred over pixmaps -->
19 <property name="IconName" type="s" access="read"/>
20
21 <!--struct containing width, height and image data-->
22 <property name="IconPixmap" type="(iiay)" access="read">
23 <annotation name="org.qtproject.QtDBus.QtTypeName" value="DBusImageList"/>
24 </property>
25
26 <property name="OverlayIconName" type="s" access="read"/>
27
28 <property name="OverlayIconPixmap" type="(iiay)" access="read">
29 <annotation name="org.qtproject.QtDBus.QtTypeName" value="DBusImageList"/>
30 </property>
31
32
33 <!-- Requesting attention icon -->
34 <property name="AttentionIconName" type="s" access="read"/>
35
36 <!--same definition as image-->
37 <property name="AttentionIconPixmap" type="(iiay)" access="read">
38 <annotation name="org.qtproject.QtDBus.QtTypeName" value="DBusImageList"/>
39 </property>
40
41 <property name="AttentionMovieName" type="s" access="read"/>
42
43
44
45 <!-- tooltip data -->
46
47 <!--(iiay) is an image-->
48 <property name="ToolTip" type="(s(iiay)ss)" access="read">
49 <annotation name="org.qtproject.QtDBus.QtTypeName" value="DBusToolTip"/>
50 </property>
51
52
53 <!-- interaction: the systemtray wants the application to do something -->
54 <method name="ContextMenu">
55 <!-- we're passing the coordinates of the icon, so the app knows where to put the popup window -->
56 <arg name="x" type="i" direction="in"/>
57 <arg name="y" type="i" direction="in"/>
58 </method>
59
60 <method name="Activate">
61 <arg name="x" type="i" direction="in"/>
62 <arg name="y" type="i" direction="in"/>
63 </method>
64
65 <method name="SecondaryActivate">
66 <arg name="x" type="i" direction="in"/>
67 <arg name="y" type="i" direction="in"/>
68 </method>
69
70 <method name="Scroll">
71 <arg name="delta" type="i" direction="in"/>
72 <arg name="orientation" type="s" direction="in"/>
73 </method>
74
75 <!-- Signals: the client wants to change something in the status-->
76 <signal name="NewTitle">
77 </signal>
78
79 <signal name="NewIcon">
80 </signal>
81
82 <signal name="NewAttentionIcon">
83 </signal>
84
85 <signal name="NewOverlayIcon">
86 </signal>
87
88 <signal name="NewToolTip">
89 </signal>
90
91 <signal name="NewStatus">
92 <arg name="status" type="s"/>
93 </signal>
94
95 </interface>
96</node>
097
=== modified file 'src/src.pro'
--- src/src.pro 2014-04-14 15:04:02 +0000
+++ src/src.pro 2014-12-13 15:39:31 +0000
@@ -6,14 +6,25 @@
66
7QT += core-private gui-private platformsupport-private dbus widgets7QT += core-private gui-private platformsupport-private dbus widgets
8DBUS_INTERFACES += com.canonical.AppMenu.Registrar.xml8DBUS_INTERFACES += com.canonical.AppMenu.Registrar.xml
9DBUS_ADAPTORS += org.kde.StatusNotifierItem.xml
10QDBUSXML2CPP_ADAPTOR_HEADER_FLAGS += -i dbusstructures.h
911
10CONFIG += X11 link_pkgconfig debug12CONFIG += X11 link_pkgconfig debug
11PKGCONFIG += dbusmenu-qt5 gtk+-2.013PKGCONFIG += dbusmenu-qt5 gtk+-2.0
12DESTDIR = ./14DESTDIR = ./
1315
14HEADERS += \16HEADERS += \
15 appmenuplatformmenubar.h17 appmenuplatformmenuitem.h \
18 appmenuplatformmenu.h \
19 appmenuplatformmenubar.h \
20 appmenuplatformsystemtrayicon.h \
21 dbusstructures.h \
22 iconcache.h
1623
17SOURCES += \24SOURCES += \
18 appmenuplatformmenubar.cpp25 appmenuplatformmenuitem.cpp \
1926 appmenuplatformmenu.cpp \
27 appmenuplatformmenubar.cpp \
28 appmenuplatformsystemtrayicon.cpp \
29 dbusstructures.cpp \
30 iconcache.cpp

Subscribers

People subscribed via source and target branches