Add main menu custom entry possibility

This commit is contained in:
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 property ConfiguredHostsModel configuredHosts: null
readonly property Engine currentEngine: configuredHosts.count > 0 ? configuredHosts.get(configuredHosts.currentIndex).engine : null readonly property Engine currentEngine: configuredHosts.count > 0 ? configuredHosts.get(configuredHosts.currentIndex).engine : null
signal openThingSettings(); signal openThingSettings()
signal openMagicSettings(); signal openMagicSettings()
signal openAppSettings(); signal openAppSettings()
signal openSystemSettings(); signal openSystemSettings()
signal openCustomPage(string page); signal openCustomPage(string page)
signal configureMainView(); signal configureMainView()
signal startWirelessSetup(); signal startWirelessSetup()
signal startManualConnection(); signal startManualConnection()
background: Rectangle { background: Rectangle {
color: Style.backgroundColor color: Style.backgroundColor
@ -29,6 +29,12 @@ Drawer {
onClosed: topSectionLayout.configureConnections = false; 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 { Settings {
id: tokenSettings id: tokenSettings
category: "jsonTokens" category: "jsonTokens"
@ -341,18 +347,51 @@ Drawer {
root.openSystemSettings(); root.openSystemSettings();
root.close(); 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 { Repeater {
id: configurationRepeater
model: Configuration.mainMenuLinks model: Configuration.mainMenuLinks
delegate: NymeaItemDelegate { delegate: NymeaItemDelegate {
property var entry: Configuration.mainMenuLinks[index] property var entry: Configuration.mainMenuLinks[index]
Layout.fillWidth: true Layout.fillWidth: true
text: entry.text text: entry.text
iconName: entry.iconName iconName: entry.iconName
visible: entry.requiresEngine === true ? root.currentEngine && root.currentEngine.jsonRpcClient.currentHost && root.currentEngine.jsonRpcClient.connected : true
progressive: false progressive: false
onClicked: { onClicked: {
if (entry.page !== undefined) { if (entry.page !== undefined) {
@ -372,12 +411,5 @@ Drawer {
} }
} }
} }
// Component {
// id: hostConnectionInfoComponent
// MeaDialog {
// }
// }
} }

View File

@ -115,7 +115,6 @@ ApplicationWindow {
id: m id: m
height: app.height height: app.height
width: Math.min(300, app.width) width: Math.min(300, app.width)
// z: 1000
configuredHosts: configuredHostsModel configuredHosts: configuredHostsModel
onOpenThingSettings: rootItem.openThingSettings(); onOpenThingSettings: rootItem.openThingSettings();
onOpenMagicSettings: rootItem.openMagicSettings(); onOpenMagicSettings: rootItem.openMagicSettings();

View File

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

View File

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