on xenial help sign in
Add tool to browse menus of a running app
6b27379Albert Astals Cid
qml/Panel/Panel.qml+1
@@ -306,6 +306,7 @@ Item {
306 onEnabledChanged: {
306 onEnabledChanged: {
307 if (!enabled) hide();
307 if (!enabled) hide();
308 }
308 }
309+
309 }
310 }
310
311
311 PanelMenu {
312 PanelMenu {
tools/CMakeLists.txt+2−12
@@ -1,14 +1,4 @@
1−add_executable(${SCOPE_TOOL}
1+add_subdirectory(menutool)
2− scopetool.cpp
2+add_subdirectory(scopetool)
3− registry-tracker.cpp
4− ../src/UnixSignalHandler.cpp
5− )
6−
7−qt5_use_modules(${SCOPE_TOOL} Qml Quick)
8−
9−# install binaries
10−install(TARGETS ${SCOPE_TOOL}
11− RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
12− )
13
3
14install(FILES unlock-device DESTINATION ${SHELL_APP_DIR})
4install(FILES unlock-device DESTINATION ${SHELL_APP_DIR})
tools/menutool/CMakeLists.txtnew file+5
@@ -0,0 +1,5 @@
1+add_executable(menutool
2+ menutool.cpp
3+ )
4+
5+qt5_use_modules(menutool Qml Quick)
tools/menutool/READMEnew file+11
@@ -0,0 +1,11 @@
1+This tool can be used to browse the menus of another application
2+
3+How to use:
4+ * Start application that exports menus
5+ e.g. QT_QPA_PLATFORMTHEME=ubuntuappmenu kate
6+ * Figure out which is the dbus address
7+ * This is a bit tricky, but using qdbusviewer to see the addresses
8+ that appear when starting the app and looking for one that
9+ contains com/Ubuntu/Menu/0 should be enough
10+ * Start tool passing the dbus address
11+ builddir/menutool/menutool :1.293
tools/menutool/menutool.cppnew file+62
@@ -0,0 +1,62 @@
1+/*
2+ * Copyright (C) 2017 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+ */
16+
17+// Qt
18+#include <QDebug>
19+#include <QCommandLineParser>
20+#include <QGuiApplication>
21+#include <QQmlContext>
22+#include <QQmlEngine>
23+#include <QQuickView>
24+
25+// local
26+#include <paths.h>
27+
28+int main(int argc, char *argv[])
29+{
30+ QGuiApplication::setApplicationName("Menu Test Tool");
31+ QGuiApplication *application = new QGuiApplication(argc, argv);
32+
33+ QCommandLineParser parser;
34+ parser.parse(application->arguments());
35+ const QStringList args = parser.positionalArguments();
36+
37+ if (args.count() != 1) {
38+ qWarning() << "You need to pass the dbus address";
39+ return 1;
40+ }
41+
42+ QQuickView* view = new QQuickView();
43+ view->setResizeMode(QQuickView::SizeRootObjectToView);
44+ view->setTitle(QGuiApplication::applicationName());
45+ view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
46+ view->rootContext()->setContextProperty("contextBusName", args[0]);
47+
48+ QUrl source(::sourceDirectory() + "/tools/menutool/menutool.qml");
49+ prependImportPaths(view->engine(), ::overrideImportPaths());
50+ prependImportPaths(view->engine(), ::nonMirImportPaths());
51+
52+ view->setSource(source);
53+
54+ view->show();
55+
56+ int result = application->exec();
57+
58+ delete view;
59+ delete application;
60+
61+ return result;
62+}
tools/menutool/menutool.qmlnew file+89
@@ -0,0 +1,89 @@
1+/*
2+* Copyright (C) 2017 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+*/
16+
17+import QtQuick 2.4
18+import Ubuntu.Components 1.3
19+
20+import "../../qml/ApplicationMenus"
21+import "../../qml/Panel"
22+import "../../qml/Components/PanelState"
23+
24+import QMenuModel 0.1
25+import Unity.Indicators 0.1 as Indicators
26+
27+Item {
28+ width: units.gu(180)
29+ height: units.gu(120)
30+
31+ UnityMenuModel {
32+ id: menuModel
33+ busName: contextBusName
34+ menuObjectPath: "/com/ubuntu/Menu/0"
35+ actions: { "unity": "/com/ubuntu/Menu/0" }
36+ }
37+
38+ Panel {
39+ id: panel
40+
41+ height: parent.height
42+ width: parent.width / 2
43+ minimizedPanelHeight: units.gu(6)
44+
45+ mode: "windowed"
46+
47+ applicationMenus {
48+ model: menuModel
49+ }
50+
51+ Rectangle {
52+ color: "green"
53+ anchors.bottom: parent.bottom
54+ anchors.right: parent.right
55+ Label {
56+ id: label
57+ anchors.centerIn: parent
58+ text: "Click here to open touch menu manually"
59+ }
60+ width: label.width + units.gu(2)
61+ height: label.height + units.gu(2)
62+ MouseArea {
63+ anchors.fill: parent
64+ onClicked: panel.applicationMenus.show();
65+ }
66+ visible: !panel.applicationMenus.shown
67+ }
68+ }
69+
70+ Rectangle {
71+ color: "blue"
72+ height: parent.height
73+ width: parent.width / 2
74+ x: width
75+
76+ MenuBar {
77+ id: menuBar
78+ height: units.gu(3)
79+ width: parent.width
80+ enableKeyFilter: true
81+ unityMenuModel: menuModel
82+ }
83+ }
84+
85+ Component.onCompleted: {
86+ theme.name = "Ubuntu.Components.Themes.SuruDark";
87+ PanelState.title = "Drag here to open touch menu";
88+ }
89+}
tools/scopetool/CMakeLists.txtnew file+12
@@ -0,0 +1,12 @@
1+add_executable(${SCOPE_TOOL}
2+ scopetool.cpp
3+ registry-tracker.cpp
4+ ../../src/UnixSignalHandler.cpp
5+ )
6+
7+qt5_use_modules(${SCOPE_TOOL} Qml Quick)
8+
9+# install binaries
10+install(TARGETS ${SCOPE_TOOL}
11+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
12+ )
tools/registry-tracker.cpp → tools/scopetool/registry-tracker.cpprenamed

The content is the same.

tools/registry-tracker.h → tools/scopetool/registry-tracker.hrenamed

The content is the same.

tools/scopetool.cpp → tools/scopetool/scopetool.cpprenamed

The content is the same.