File 0007-Add-small-app-for-testing-appmenu.patch of Package plasma5-workspace
From 36fd10c963307da2489e4233265754c077a5ea0f Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Tue, 10 Jan 2017 11:40:07 +0000
Subject: [PATCH 07/44] Add small app for testing appmenu
Summary:
App which exports a menu, designed to simulate so that the dbus menu can
be easily extended for obscure conditions then tested and debugged
Test Plan: Exports a menu
Reviewers: #plasma, apol
Reviewed By: apol
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D4058
---
libdbusmenuqt/CMakeLists.txt | 1 +
libdbusmenuqt/test/README | 2 ++
libdbusmenuqt/test/main.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+)
create mode 100644 libdbusmenuqt/test/README
create mode 100644 libdbusmenuqt/test/main.cpp
diff --git a/libdbusmenuqt/CMakeLists.txt b/libdbusmenuqt/CMakeLists.txt
index 9995811e..6c13e470 100644
--- a/libdbusmenuqt/CMakeLists.txt
+++ b/libdbusmenuqt/CMakeLists.txt
@@ -11,3 +11,4 @@ target_link_libraries(dbusmenuqt
Qt5::Widgets
)
+add_subdirectory(test)
diff --git a/libdbusmenuqt/test/README b/libdbusmenuqt/test/README
new file mode 100644
index 00000000..99dd020f
--- /dev/null
+++ b/libdbusmenuqt/test/README
@@ -0,0 +1,2 @@
+App with a menu, designed for use testing appmenu QPTs/applets/kded modules
+small enough that we can attach debuggers and breakpoints without drowning in data
diff --git a/libdbusmenuqt/test/main.cpp b/libdbusmenuqt/test/main.cpp
new file mode 100644
index 00000000..526638ef
--- /dev/null
+++ b/libdbusmenuqt/test/main.cpp
@@ -0,0 +1,66 @@
+#include <QApplication>
+
+#include <QMainWindow>
+#include <QMenuBar>
+#include <QDateTime>
+#include <QIcon>
+#include <QDebug>
+
+class MainWindow : public QMainWindow
+{
+public:
+ MainWindow();
+};
+
+MainWindow::MainWindow() :
+ QMainWindow()
+{
+ /*set an initial menu with the following
+ Menu A
+ - Item
+ - Checkable Item
+ - Item With Icon
+ - A separator
+ - Menu B
+ - Item B1
+ Menu C
+ - DynamicItem ${timestamp}
+
+ TopLevelItem
+ */
+
+ QAction *t;
+ auto menuA = new QMenu("Menu A", this);
+ menuA->addAction("Item");
+
+ t = menuA->addAction("Checkable Item");
+ t->setCheckable(true);
+
+ t = menuA->addAction(QIcon::fromTheme("document-edit"), "Item with icon");
+
+ menuA->addSeparator();
+
+ auto menuB = new QMenu("Menu B", this);
+ menuB->addAction("Item B1");
+ menuA->addMenu(menuB);
+
+ menuBar()->addMenu(menuA);
+
+ auto menuC = new QMenu("Menu C", this);
+ connect(menuC, &QMenu::aboutToShow, this, [menuC]() {
+ menuC->clear();
+ menuC->addAction("Dynamic Item " + QDateTime::currentDateTime().toString());
+ });
+
+ menuBar()->addMenu(menuC);
+
+ menuBar()->addAction("Top Level Item");
+}
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+ MainWindow mw;
+ mw.show();
+ return app.exec();
+}
--
2.12.0