on 70209fb help sign in
unity8/plugins/Unity/ApplicationMenu/applicationmenuregistry.h
81 lines 2.7 kB history raw
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#ifndef APPLICATIONMENUREGISTRY_H
18#define APPLICATIONMENUREGISTRY_H
20#include <QObject>
21#include <QDBusContext>
22#include <QDBusObjectPath>
23#include <QtQml>
25class MenuServicePath : public QObject
27 Q_OBJECT
28 Q_PROPERTY(QByteArray service MEMBER m_service CONSTANT)
29 Q_PROPERTY(QByteArray menuPath MEMBER m_menuPath CONSTANT)
30 Q_PROPERTY(QByteArray actionPath MEMBER m_actionPath CONSTANT)
31public:
32 explicit MenuServicePath(const QByteArray &service,
33 const QByteArray &menuPath,
34 const QByteArray &actionPath)
35 : m_service(service)
36 , m_menuPath(menuPath)
37 , m_actionPath(actionPath)
38 {}
40 const QByteArray m_service;
41 const QByteArray m_menuPath;
42 const QByteArray m_actionPath;
43};
45class ApplicationMenuRegistry : public QObject
47 Q_OBJECT
48public:
49 virtual ~ApplicationMenuRegistry();
51 // for qml
52 Q_INVOKABLE QList<QObject*> getMenusForSurface(const QString &surfaceId);
54 // for dbus
55 void RegisterAppMenu(pid_t processId,
56 const QDBusObjectPath &menuObjectPath,
57 const QDBusObjectPath &actionObjectPath,
58 const QString &service);
59 void UnregisterAppMenu(pid_t processId, const QDBusObjectPath &menuObjectPath);
61 void RegisterSurfaceMenu(const QString &surfaceId,
62 const QDBusObjectPath &menuObjectPath,
63 const QDBusObjectPath &actionObjectPath,
64 const QString &service);
65 void UnregisterSurfaceMenu(const QString &surfaceId, const QDBusObjectPath &menuObjectPath);
67Q_SIGNALS:
68 void appMenuRegistered(pid_t processId);
69 void appMenuUnregistered(pid_t processId);
71 void surfaceMenuRegistered(const QString& surfaceId);
72 void surfaceMenuUnregistered(const QString& surfaceId);
74protected:
75 explicit ApplicationMenuRegistry(QObject *parent = 0);
77 QMultiMap<pid_t, MenuServicePath*> m_appMenus;
78 QMultiMap<QString, MenuServicePath*> m_surfaceMenus;
79};
81#endif // APPLICATIONMENUREGISTRY_H