From 3e0360401bbbb0f640958998f6625495e5b3fdff Mon Sep 17 00:00:00 2001 From: Robin Seger Date: Tue, 10 Mar 2026 15:22:23 +0100 Subject: dashboard: dynamic dashboard tabs + fix performance settings updating (#1253) * [CI] chore: update flake * Dashboard perf settings save, visibility on none enabled * Dashboard heigh stutter fixed, persist current tab * restore binding * wrapper async=false * ScriptModel, centralized tabs/panes, individual toggle * fixes, missed mediaUpdateInterval, passing values --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- modules/dashboard/Content.qml | 108 +++++++++++++++++++++++++++++------------- 1 file changed, 74 insertions(+), 34 deletions(-) (limited to 'modules/dashboard/Content.qml') diff --git a/modules/dashboard/Content.qml b/modules/dashboard/Content.qml index 1cc960a..bbb4272 100644 --- a/modules/dashboard/Content.qml +++ b/modules/dashboard/Content.qml @@ -14,6 +14,37 @@ Item { required property PersistentProperties visibilities required property PersistentProperties state required property FileDialog facePicker + + readonly property var dashboardTabs: { + const allTabs = [ + { + component: dashComponent, + iconName: "dashboard", + text: qsTr("Dashboard"), + enabled: Config.dashboard.showDashboard + }, + { + component: mediaComponent, + iconName: "queue_music", + text: qsTr("Media"), + enabled: Config.dashboard.showMedia + }, + { + component: performanceComponent, + iconName: "speed", + text: qsTr("Performance"), + enabled: Config.dashboard.showPerformance && (Config.dashboard.performance.showCpu || Config.dashboard.performance.showGpu || Config.dashboard.performance.showMemory || Config.dashboard.performance.showStorage || Config.dashboard.performance.showNetwork || Config.dashboard.performance.showBattery) + }, + { + component: weatherComponent, + iconName: "cloud", + text: qsTr("Weather"), + enabled: Config.dashboard.showWeather + } + ]; + return allTabs.filter(tab => tab.enabled); + } + readonly property real nonAnimWidth: view.implicitWidth + viewWrapper.anchors.margins * 2 readonly property real nonAnimHeight: tabs.implicitHeight + tabs.anchors.topMargin + view.implicitHeight + viewWrapper.anchors.margins * 2 @@ -31,6 +62,7 @@ Item { nonAnimWidth: root.nonAnimWidth - anchors.margins * 2 state: root.state + tabs: root.dashboardTabs } ClippingRectangle { @@ -86,33 +118,58 @@ Item { RowLayout { id: row - Pane { - index: 0 - sourceComponent: Dash { - visibilities: root.visibilities - state: root.state - facePicker: root.facePicker + Repeater { + model: ScriptModel { + values: root.dashboardTabs } - } - Pane { - index: 1 - sourceComponent: Media { - visibilities: root.visibilities + delegate: Loader { + id: paneLoader + + required property int index + required property var modelData + + Layout.alignment: Qt.AlignTop + + sourceComponent: modelData.component + + Component.onCompleted: active = Qt.binding(() => { + if (index === view.currentIndex) + return true; + const vx = Math.floor(view.visibleArea.xPosition * view.contentWidth); + const vex = Math.floor(vx + view.visibleArea.widthRatio * view.contentWidth); + return (vx >= x && vx <= x + implicitWidth) || (vex >= x && vex <= x + implicitWidth); + }) } } + } - Pane { - index: 2 - sourceComponent: Performance {} + Component { + id: dashComponent + Dash { + visibilities: root.visibilities + state: root.state + facePicker: root.facePicker } + } - Pane { - index: 3 - sourceComponent: Weather {} + Component { + id: mediaComponent + Media { + visibilities: root.visibilities } } + Component { + id: performanceComponent + Performance {} + } + + Component { + id: weatherComponent + Weather {} + } + Behavior on contentX { Anim {} } @@ -132,21 +189,4 @@ Item { easing.bezierCurve: Appearance.anim.curves.emphasized } } - - component Pane: Loader { - id: pane - - required property int index - - Layout.alignment: Qt.AlignTop - - Component.onCompleted: active = Qt.binding(() => { - // Always keep current tab loaded - if (pane.index === view.currentIndex) - return true; - const vx = Math.floor(view.visibleArea.xPosition * view.contentWidth); - const vex = Math.floor(vx + view.visibleArea.widthRatio * view.contentWidth); - return (vx >= x && vx <= x + implicitWidth) || (vex >= x && vex <= x + implicitWidth); - }) - } } -- cgit v1.2.3-freya