2 * Copyright (C) 2016 Canonical, Ltd.
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.
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.
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/>.
17#include "applicationmenuregistry.h"
23ApplicationMenuRegistry::ApplicationMenuRegistry(QObject *parent)
28ApplicationMenuRegistry::~ApplicationMenuRegistry()
30 qDeleteAll(m_appMenus);
33 qDeleteAll(m_surfaceMenus);
34 m_surfaceMenus.clear();
37void ApplicationMenuRegistry::RegisterAppMenu(pid_t processId,
38 const QDBusObjectPath &menuObjectPath,
39 const QDBusObjectPath &actionObjectPath,
40 const QString &service)
42 qDebug() << "RegisterApplicationMenu" << processId << " @ " << service << menuObjectPath.path() << actionObjectPath.path();
44 QMultiMap<pid_t, MenuServicePath*>::iterator i = m_appMenus.find(processId);
45 while (i != m_appMenus.end() && i.key() == processId) {
46 if (i.value()->m_menuPath == menuObjectPath.path().toUtf8()) {
47 qWarning() << "Already have a menu for application:" << processId << service << menuObjectPath.path();
53 auto menu = new MenuServicePath(service.toUtf8(), menuObjectPath.path().toUtf8(), actionObjectPath.path().toUtf8());
54 QQmlEngine::setObjectOwnership(menu, QQmlEngine::CppOwnership);
56 m_appMenus.insert(processId, menu);
57 Q_EMIT appMenuRegistered(processId);
60void ApplicationMenuRegistry::UnregisterAppMenu(pid_t processId, const QDBusObjectPath &menuObjectPath)
62 qDebug() << "RegisterApplicationMenu" << processId << " @ " << menuObjectPath.path();
64 QMultiMap<pid_t, MenuServicePath*>::iterator i = m_appMenus.find(processId);
65 while (i != m_appMenus.end() && i.key() == processId) {
66 if (i.value()->m_menuPath == menuObjectPath.path().toUtf8()) {
67 i.value()->deleteLater();
69 Q_EMIT appMenuUnregistered(processId);
76void ApplicationMenuRegistry::RegisterSurfaceMenu(const QString &surfaceId,
77 const QDBusObjectPath &menuObjectPath,
78 const QDBusObjectPath &actionObjectPath,
79 const QString &service)
81 qDebug() << "RegisterSurfaceMenu" << surfaceId << " @ " << service << menuObjectPath.path() << actionObjectPath.path();
83 QMultiMap<QString, MenuServicePath*>::iterator i = m_surfaceMenus.find(surfaceId);
84 while (i != m_surfaceMenus.end() && i.key() == surfaceId) {
85 if (i.value()->m_menuPath == menuObjectPath.path().toUtf8()) {
86 qWarning() << "Already have a menu for surface:" << surfaceId << service << menuObjectPath.path();
92 auto menu = new MenuServicePath(service.toUtf8(), menuObjectPath.path().toUtf8(), actionObjectPath.path().toUtf8());
93 QQmlEngine::setObjectOwnership(menu, QQmlEngine::CppOwnership);
95 m_surfaceMenus.insert(surfaceId, menu);
96 Q_EMIT surfaceMenuRegistered(surfaceId);
99void ApplicationMenuRegistry::UnregisterSurfaceMenu(const QString &surfaceId, const QDBusObjectPath &menuObjectPath)
101 qDebug() << "UnregisterSurfaceMenu" << surfaceId << " @ " << menuObjectPath.path();
103 QMultiMap<QString, MenuServicePath*>::iterator i = m_surfaceMenus.find(surfaceId);
104 while (i != m_surfaceMenus.end() && i.key() == surfaceId) {
105 if (i.value()->m_menuPath == menuObjectPath.path().toUtf8()) {
106 i.value()->deleteLater();
107 m_surfaceMenus.erase(i);
108 Q_EMIT surfaceMenuUnregistered(surfaceId);
115QList<QObject*> ApplicationMenuRegistry::getMenusForSurface(const QString &surfaceId)
117 QList<QObject*> list;
119 QMultiMap<QString, MenuServicePath*>::iterator i = m_surfaceMenus.find(surfaceId);
120 while (i != m_surfaceMenus.end() && i.key() == surfaceId) {
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list