From 1b6b435d44ef2be5624638d7e46a3151896744d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 26 May 2025 16:44:35 +0200 Subject: [PATCH] Add main menu custom entry possibility --- nymea-app/ui/MainMenu.qml | 64 ++++++++++++++----- nymea-app/ui/Nymea.qml | 1 - .../ui/mainviews/energy/ConsumerStats.qml | 2 - version.txt | 2 +- 4 files changed, 49 insertions(+), 20 deletions(-) diff --git a/nymea-app/ui/MainMenu.qml b/nymea-app/ui/MainMenu.qml index 75c95124..4533610c 100644 --- a/nymea-app/ui/MainMenu.qml +++ b/nymea-app/ui/MainMenu.qml @@ -13,15 +13,15 @@ Drawer { property ConfiguredHostsModel configuredHosts: null readonly property Engine currentEngine: configuredHosts.count > 0 ? configuredHosts.get(configuredHosts.currentIndex).engine : null - signal openThingSettings(); - signal openMagicSettings(); - signal openAppSettings(); - signal openSystemSettings(); - signal openCustomPage(string page); - signal configureMainView(); + signal openThingSettings() + signal openMagicSettings() + signal openAppSettings() + signal openSystemSettings() + signal openCustomPage(string page) + signal configureMainView() - signal startWirelessSetup(); - signal startManualConnection(); + signal startWirelessSetup() + signal startManualConnection() background: Rectangle { color: Style.backgroundColor @@ -29,6 +29,12 @@ Drawer { onClosed: topSectionLayout.configureConnections = false; + // This allows to emit a custom signal and perform any other task besids opening a page + // By defining a signalName property in the customMenuLinks it can be distinguished by using + // the signalName string + signal customMenuLinkClicked(string signalName) + property var customMenuLinks: [ ] + Settings { id: tokenSettings category: "jsonTokens" @@ -341,18 +347,51 @@ Drawer { root.openSystemSettings(); root.close(); } + } - Layout.bottomMargin: app.margins + // Custom entries + Repeater { + id: customRepeater + + model: root.customMenuLinks + delegate: NymeaItemDelegate { + property var entry: root.customMenuLinks[index] + Layout.fillWidth: true + text: entry.text + iconName: entry.iconName + visible: entry.requiresEngine === true ? root.currentEngine && root.currentEngine.jsonRpcClient.currentHost && root.currentEngine.jsonRpcClient.connected : true + progressive: false + onClicked: { + if (entry.page !== undefined) { + root.openCustomPage(entry.page) + } + + if (entry.signalName !== undefined) { + root.customMenuLinkClicked(entry.signalName) + } + + root.close() + } + } } + Item { + id: spaceItem + Layout.fillWidth: true + Layout.preferredHeight: app.margins + } + Repeater { + id: configurationRepeater + model: Configuration.mainMenuLinks delegate: NymeaItemDelegate { property var entry: Configuration.mainMenuLinks[index] Layout.fillWidth: true text: entry.text iconName: entry.iconName + visible: entry.requiresEngine === true ? root.currentEngine && root.currentEngine.jsonRpcClient.currentHost && root.currentEngine.jsonRpcClient.connected : true progressive: false onClicked: { if (entry.page !== undefined) { @@ -372,12 +411,5 @@ Drawer { } } } - - // Component { - // id: hostConnectionInfoComponent - // MeaDialog { - - // } - // } } diff --git a/nymea-app/ui/Nymea.qml b/nymea-app/ui/Nymea.qml index a4e93d92..ddef430f 100644 --- a/nymea-app/ui/Nymea.qml +++ b/nymea-app/ui/Nymea.qml @@ -115,7 +115,6 @@ ApplicationWindow { id: m height: app.height width: Math.min(300, app.width) -// z: 1000 configuredHosts: configuredHostsModel onOpenThingSettings: rootItem.openThingSettings(); onOpenMagicSettings: rootItem.openMagicSettings(); diff --git a/nymea-app/ui/mainviews/energy/ConsumerStats.qml b/nymea-app/ui/mainviews/energy/ConsumerStats.qml index ca8d7fb4..c479092f 100644 --- a/nymea-app/ui/mainviews/energy/ConsumerStats.qml +++ b/nymea-app/ui/mainviews/energy/ConsumerStats.qml @@ -571,7 +571,5 @@ StatsBase { } } } - } - } diff --git a/version.txt b/version.txt index 645f687b..dce6a84a 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ 1.10.2 -662 +663