Changeset View
Changeset View
Standalone View
Standalone View
gmenu-dbusmenu-proxy/window.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2018 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
3 | * | ||||
4 | * This library is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU Lesser General Public | ||||
6 | * License as published by the Free Software Foundation; either | ||||
7 | * version 2.1 of the License, or (at your option) any later version. | ||||
8 | * | ||||
9 | * This library 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 GNU | ||||
12 | * Lesser General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Lesser General Public | ||||
15 | * License along with this library; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
17 | * | ||||
18 | */ | ||||
19 | | ||||
20 | #pragma once | ||||
21 | | ||||
22 | #include <QObject> | ||||
23 | #include <QDBusContext> | ||||
24 | #include <QString> | ||||
25 | #include <QVector> | ||||
26 | #include <QWindow> // for WId | ||||
27 | | ||||
28 | #include <functional> | ||||
29 | | ||||
30 | #include "gdbusmenutypes_p.h" | ||||
31 | #include "../libdbusmenuqt/dbusmenutypes_p.h" | ||||
32 | | ||||
33 | class QDBusVariant; | ||||
34 | | ||||
35 | class Actions; | ||||
36 | class Menu; | ||||
37 | | ||||
38 | class Window : public QObject, protected QDBusContext | ||||
39 | { | ||||
40 | Q_OBJECT | ||||
41 | | ||||
42 | // DBus | ||||
43 | Q_PROPERTY(QString Status READ status) | ||||
44 | Q_PROPERTY(uint Version READ version) | ||||
45 | | ||||
46 | public: | ||||
47 | Window(const QString &serviceName); | ||||
48 | ~Window(); | ||||
49 | | ||||
50 | void init(); | ||||
51 | | ||||
52 | WId winId() const; | ||||
53 | void setWinId(WId winId); | ||||
54 | | ||||
55 | QString serviceName() const; | ||||
56 | | ||||
57 | QString applicationObjectPath() const; | ||||
58 | void setApplicationObjectPath(const QString &applicationObjectPath); | ||||
59 | | ||||
60 | QString unityObjectPath() const; | ||||
61 | void setUnityObjectPath(const QString &unityObjectPath); | ||||
62 | | ||||
63 | QString windowObjectPath() const; | ||||
64 | void setWindowObjectPath(const QString &windowObjectPath); | ||||
65 | | ||||
66 | QString applicationMenuObjectPath() const; | ||||
67 | void setApplicationMenuObjectPath(const QString &applicationMenuObjectPath); | ||||
68 | | ||||
69 | QString menuBarObjectPath() const; | ||||
70 | void setMenuBarObjectPath(const QString &menuBarObjectPath); | ||||
71 | | ||||
72 | QString currentMenuObjectPath() const; | ||||
73 | | ||||
74 | QString proxyObjectPath() const; | ||||
75 | | ||||
76 | // DBus | ||||
77 | bool AboutToShow(int id); | ||||
78 | void Event(int id, const QString &eventId, const QDBusVariant &data, uint timestamp); | ||||
79 | DBusMenuItemList GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames); | ||||
80 | uint GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &dbusItem); | ||||
81 | QDBusVariant GetProperty(int id, const QString &property); | ||||
82 | | ||||
83 | QString status() const; | ||||
84 | uint version() const; | ||||
85 | | ||||
86 | signals: | ||||
87 | // don't want to pollute X stuff into Menu, let all of that be in MenuProxy | ||||
88 | void requestWriteWindowProperties(); | ||||
89 | void requestRemoveWindowProperties(); | ||||
90 | | ||||
91 | // DBus | ||||
92 | void ItemActivationRequested(int id, uint timestamp); | ||||
93 | void ItemsPropertiesUpdated(const DBusMenuItemList &updatedProps, const DBusMenuItemKeysList &removedProps); | ||||
94 | void LayoutUpdated(uint revision, int parent); | ||||
95 | | ||||
96 | private: | ||||
97 | void initMenu(); | ||||
98 | | ||||
99 | bool registerDBusObject(); | ||||
100 | void updateWindowProperties(); | ||||
101 | | ||||
102 | bool getAction(const QString &name, GMenuAction &action) const; | ||||
103 | void triggerAction(const QString &name, uint timestamp = 0); | ||||
104 | Actions *getActionsForAction(const QString &name, QString &lookupName) const; | ||||
105 | | ||||
106 | void menuChanged(const QVector<uint> &menuIds); | ||||
107 | void menuItemsChanged(const QVector<uint> &itemIds); | ||||
108 | | ||||
109 | void onActionsChanged(const QStringList &dirty, const QString &prefix); | ||||
110 | void onMenuSubscribed(uint id); | ||||
111 | | ||||
112 | QVariantMap gMenuToDBusMenuProperties(const QVariantMap &source) const; | ||||
113 | | ||||
114 | WId m_winId = 0; | ||||
115 | QString m_serviceName; // original GMenu service (the gtk app) | ||||
116 | | ||||
117 | QString m_applicationObjectPath; | ||||
118 | QString m_unityObjectPath; | ||||
119 | QString m_windowObjectPath; | ||||
120 | QString m_applicationMenuObjectPath; | ||||
121 | QString m_menuBarObjectPath; | ||||
122 | | ||||
123 | QString m_currentMenuObjectPath; | ||||
124 | | ||||
125 | QString m_proxyObjectPath; // our object path on this proxy app | ||||
126 | | ||||
127 | QHash<int, QDBusMessage> m_pendingGetLayouts; | ||||
128 | | ||||
129 | Menu *m_applicationMenu = nullptr; | ||||
130 | Menu *m_menuBar = nullptr; | ||||
131 | | ||||
132 | Menu *m_currentMenu = nullptr; | ||||
133 | | ||||
134 | Actions *m_applicationActions = nullptr; | ||||
135 | Actions *m_unityActions = nullptr; | ||||
136 | Actions *m_windowActions = nullptr; | ||||
137 | | ||||
138 | bool m_menuInited = false; | ||||
139 | | ||||
140 | }; |