dashboard: loader panes

This commit is contained in:
2 * r + 2 * t 2025-06-28 22:08:17 +10:00
parent 5c4de3016b
commit 45ebf3c70e
4 changed files with 27 additions and 22 deletions

View file

@ -1,3 +1,5 @@
pragma ComponentBehavior: Bound
import "root:/widgets" import "root:/widgets"
import "root:/services" import "root:/services"
import "root:/config" import "root:/config"
@ -82,20 +84,20 @@ Item {
RowLayout { RowLayout {
id: row id: row
Dash { Pane {
Layout.alignment: Qt.AlignTop sourceComponent: Dash {
shouldUpdate: visible && this === view.currentItem visibilities: root.visibilities
visibilities: root.visibilities }
} }
Media { Pane {
Layout.alignment: Qt.AlignTop sourceComponent: Media {
shouldUpdate: visible && this === view.currentItem visibilities: root.visibilities
visibilities: root.visibilities }
} }
Performance { Pane {
Layout.alignment: Qt.AlignTop sourceComponent: Performance {}
} }
} }
@ -124,4 +126,14 @@ Item {
easing.bezierCurve: Appearance.anim.curves.emphasized easing.bezierCurve: Appearance.anim.curves.emphasized
} }
} }
component Pane: Loader {
Layout.alignment: Qt.AlignTop
Component.onCompleted: active = Qt.binding(() => {
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);
})
}
} }

View file

@ -7,7 +7,6 @@ import QtQuick.Layouts
GridLayout { GridLayout {
id: root id: root
required property bool shouldUpdate
required property var visibilities required property var visibilities
rowSpacing: Appearance.spacing.normal rowSpacing: Appearance.spacing.normal
@ -77,8 +76,6 @@ GridLayout {
Media { Media {
id: media id: media
shouldUpdate: root.shouldUpdate
} }
} }

View file

@ -15,7 +15,6 @@ import QtQuick.Layouts
Item { Item {
id: root id: root
required property bool shouldUpdate
required property PersistentProperties visibilities required property PersistentProperties visibilities
property real playerProgress: { property real playerProgress: {
@ -41,7 +40,7 @@ Item {
} }
Timer { Timer {
running: root.shouldUpdate && (Players.active?.isPlaying ?? false) running: Players.active?.isPlaying ?? false
interval: Config.dashboard.mediaUpdateInterval interval: Config.dashboard.mediaUpdateInterval
triggeredOnStart: true triggeredOnStart: true
repeat: true repeat: true
@ -52,8 +51,7 @@ Item {
target: Cava target: Cava
function onValuesChanged(): void { function onValuesChanged(): void {
if (root.shouldUpdate) visualiser.requestPaint();
visualiser.requestPaint();
} }
} }
@ -523,7 +521,7 @@ Item {
width: visualiser.width * 0.75 width: visualiser.width * 0.75
height: visualiser.height * 0.75 height: visualiser.height * 0.75
playing: root.shouldUpdate && (Players.active?.isPlaying ?? false) playing: Players.active?.isPlaying ?? false
speed: BeatDetector.bpm / 300 speed: BeatDetector.bpm / 300
source: Paths.expandTilde(Config.paths.mediaGif) source: Paths.expandTilde(Config.paths.mediaGif)
asynchronous: true asynchronous: true

View file

@ -8,8 +8,6 @@ import QtQuick.Shapes
Item { Item {
id: root id: root
required property bool shouldUpdate
property real playerProgress: { property real playerProgress: {
const active = Players.active; const active = Players.active;
return active?.length ? active.position / active.length : 0; return active?.length ? active.position / active.length : 0;
@ -28,7 +26,7 @@ Item {
} }
Timer { Timer {
running: root.shouldUpdate && (Players.active?.isPlaying ?? false) running: Players.active?.isPlaying ?? false
interval: Config.dashboard.mediaUpdateInterval interval: Config.dashboard.mediaUpdateInterval
triggeredOnStart: true triggeredOnStart: true
repeat: true repeat: true
@ -219,7 +217,7 @@ Item {
anchors.bottomMargin: Appearance.padding.large anchors.bottomMargin: Appearance.padding.large
anchors.margins: Appearance.padding.large * 2 anchors.margins: Appearance.padding.large * 2
playing: root.shouldUpdate && (Players.active?.isPlaying ?? false) playing: Players.active?.isPlaying ?? false
speed: BeatDetector.bpm / 300 speed: BeatDetector.bpm / 300
source: Paths.expandTilde(Config.paths.mediaGif) source: Paths.expandTilde(Config.paths.mediaGif)
asynchronous: true asynchronous: true