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:/services"
import "root:/config"
@ -82,20 +84,20 @@ Item {
RowLayout {
id: row
Dash {
Layout.alignment: Qt.AlignTop
shouldUpdate: visible && this === view.currentItem
Pane {
sourceComponent: Dash {
visibilities: root.visibilities
}
Media {
Layout.alignment: Qt.AlignTop
shouldUpdate: visible && this === view.currentItem
visibilities: root.visibilities
}
Performance {
Layout.alignment: Qt.AlignTop
Pane {
sourceComponent: Media {
visibilities: root.visibilities
}
}
Pane {
sourceComponent: Performance {}
}
}
@ -124,4 +126,14 @@ Item {
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 {
id: root
required property bool shouldUpdate
required property var visibilities
rowSpacing: Appearance.spacing.normal
@ -77,8 +76,6 @@ GridLayout {
Media {
id: media
shouldUpdate: root.shouldUpdate
}
}

View file

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

View file

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