summaryrefslogtreecommitdiffstats
path: root/examples/applicationmanager/application-features
diff options
context:
space:
mode:
authorBernd Weimer <bernd.weimer@pelagicore.com>2019-09-20 16:01:22 +0200
committerBernd Weimer <bernd.weimer@pelagicore.com>2019-11-14 16:26:40 +0100
commit973a514b1a5ed706b024866c715dacdff68f70ab (patch)
treef8a91914afa4a774e902c2df8f38d2ace5443194 /examples/applicationmanager/application-features
parent8e46d6738c8335b9983fa365dfc684d4edb606c2 (diff)
Rename classes
Those classes are not restricted to QML, but provide general inter- process communication via DBus. They can be used from native applications, as well: - QmlApplicationInterface to DBusApplicationInterface - QmlApplicationInterfaceExtension to DBusApplicationInterfaceExtension - QmlNotification to DBusNotification Task-number: AUTOSUITE-1260 Change-Id: Iaff6251e61d62b7173e0e17a81863b4f653e8b5d Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Diffstat (limited to 'examples/applicationmanager/application-features')
-rw-r--r--examples/applicationmanager/application-features/apps/widgets/info.yaml5
-rw-r--r--examples/applicationmanager/application-features/native/widgets/main.cpp42
-rw-r--r--examples/applicationmanager/application-features/system-ui/main.qml8
3 files changed, 44 insertions, 11 deletions
diff --git a/examples/applicationmanager/application-features/apps/widgets/info.yaml b/examples/applicationmanager/application-features/apps/widgets/info.yaml
index 9d9cfce5..7e90e2ab 100644
--- a/examples/applicationmanager/application-features/apps/widgets/info.yaml
+++ b/examples/applicationmanager/application-features/apps/widgets/info.yaml
@@ -2,11 +2,12 @@ formatVersion: 1
formatType: am-application
---
id: 'widgets'
+name:
+ en: 'Native Widgets'
icon: 'icon.png'
code: 'widgets'
runtime: 'native'
runtimeParameters:
environmentVariables:
QT_WAYLAND_DISABLE_WINDOWDECORATION: "1"
-name:
- en: 'Native Widgets'
+supportsApplicationInterface: yes
diff --git a/examples/applicationmanager/application-features/native/widgets/main.cpp b/examples/applicationmanager/application-features/native/widgets/main.cpp
index 3403065f..4c1c0914 100644
--- a/examples/applicationmanager/application-features/native/widgets/main.cpp
+++ b/examples/applicationmanager/application-features/native/widgets/main.cpp
@@ -29,14 +29,18 @@
#include <QApplication>
#include <QPushButton>
#include <QDialog>
+#include <QVBoxLayout>
#include "launchermain.h"
#include "logging.h"
+#include "dbusapplicationinterface.h"
+#include "dbusnotification.h"
int main(int argc, char *argv[])
{
QtAM::Logging::initialize(argc, argv);
+ QtAM::Logging::setApplicationId("widgets");
QtAM::LauncherMain::initialize();
QApplication app(argc, argv);
@@ -44,19 +48,39 @@ int main(int argc, char *argv[])
launcher.registerWaylandExtensions();
launcher.loadConfiguration();
- launcher.setupDBusConnections();
launcher.setupLogging(false, launcher.loggingRules(), QString(), launcher.useAMConsoleLogger());
+ launcher.setupDBusConnections();
+
+ QWidget window;
+ QVBoxLayout layout(&window);
+
+ // Popup using application manager window property
+ QPushButton button1(QStringLiteral("Click to open/close a popup"));
+ button1.setStyleSheet(QStringLiteral("QPushButton { background-color : limegreen; font-size: 36px; }"));
+ layout.addWidget(&button1);
+
+ QDialog *popup1 = new QDialog(&window);
+ (new QPushButton(QStringLiteral("I'm a popup!"), popup1))->resize(340, 140);
+ popup1->setStyleSheet(QStringLiteral("QPushButton { background-color : limegreen; color : white; font-size: 24px; }"));
+ QObject::connect(&button1, &QPushButton::clicked, [&popup1, &launcher] () {
+ popup1->setVisible(!popup1->isVisible());
+ launcher.setWindowProperty(popup1->windowHandle(), "type", QStringLiteral("pop-up"));
+ });
- QPushButton window("I'm a top-level window!\nClick to open/close a popup.");
- QDialog *popup = new QDialog(&window);
- (new QPushButton("I'm a popup!", popup))->resize(300, 100);
+ // Notification
+ QPushButton button2(QStringLiteral("Click to open a notification"));
+ button2.setStyleSheet(QStringLiteral("QPushButton { background-color : darkgrey; font-size: 36px; }"));
+ layout.addWidget(&button2);
- window.setStyleSheet("QPushButton { background-color : lightgrey; font-size: 36px; }");
- popup->setStyleSheet("QPushButton { background-color : green; color : white; font-size: 24px; }");
+ QtAM::DBusNotification *notification = QtAM::DBusNotification::create(&app);
+ notification->setSummary(QStringLiteral("I'm a notification"));
+ QObject::connect(&button2, &QPushButton::clicked, notification, &QtAM::DBusNotification::show);
- QObject::connect(&window, &QPushButton::clicked, [&popup, &launcher] () {
- popup->setVisible(!popup->isVisible());
- launcher.setWindowProperty(popup->windowHandle(), "type", QVariant::fromValue(QStringLiteral("pop-up")));
+ // Application interface for handling quit
+ QtAM::DBusApplicationInterface iface(launcher.p2pDBusName(), launcher.notificationDBusName());
+ iface.initialize();
+ QObject::connect(&iface, &QtAM::DBusApplicationInterface::quit, [&iface] () {
+ iface.acknowledgeQuit();
});
app.processEvents();
diff --git a/examples/applicationmanager/application-features/system-ui/main.qml b/examples/applicationmanager/application-features/system-ui/main.qml
index e6e00880..83c1c408 100644
--- a/examples/applicationmanager/application-features/system-ui/main.qml
+++ b/examples/applicationmanager/application-features/system-ui/main.qml
@@ -188,6 +188,14 @@ Window {
}
}
+ Text {
+ z: 9999
+ font.pixelSize: 46
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: NotificationManager.count > 0 ? NotificationManager.get(0).summary : ""
+ }
+
Connections {
target: WindowManager
onWindowAdded: {