Add main menu custom entry possibility

pull/1115/head
Simon Stürz 2025-05-26 16:44:35 +02:00
parent 65079f998f
commit 1b6b435d44
4 changed files with 49 additions and 20 deletions

View File

@ -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 {
// }
// }
}

View File

@ -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();

View File

@ -571,7 +571,5 @@ StatsBase {
}
}
}
}
}

View File

@ -1,2 +1,2 @@
1.10.2
662
663