fix: only update media position on slider release

This commit is contained in:
2 * r + 2 * t 2026-06-08 16:05:32 +10:00
parent 25a9d28a51
commit 24816fb0d9
2 changed files with 16 additions and 1 deletions

View file

@ -16,6 +16,8 @@ Slider {
property real waveFrequency: 6
property int waveDuration: 1000
property int radius: Tokens.rounding.medium
property bool interactionOnMove: true
readonly property bool dragging: mouse.pressed
property color fgColour: enabled ? Colours.palette.m3primary : Qt.alpha(Colours.palette.m3onSurface, 0.38)
property color bgColour: enabled ? Colours.palette.m3secondaryContainer : Qt.alpha(Colours.palette.m3onSurface, 0.1)
@ -171,6 +173,7 @@ Slider {
}
onPositionChanged: e => {
dragMovement = (e.x - pressStartX) / width;
if (root.interactionOnMove)
root.interaction(posBinding.value);
}
onReleased: e => {

View file

@ -72,6 +72,8 @@ ColumnLayout {
}
StyledText {
id: positionLabel
Layout.preferredWidth: timeMetrics.width
text: root.lengthStr(Players.active?.position ?? -1)
color: Colours.palette.m3onSurfaceVariant
@ -80,6 +82,8 @@ ColumnLayout {
}
StyledSlider {
id: positionSlider
Layout.fillWidth: true
value: Players.active ? Players.active.position / (Players.active.length || 1) : 0
enabled: Players.active?.canSeek ?? false
@ -87,11 +91,19 @@ ColumnLayout {
animateWave: Players.active?.isPlaying ?? false
waveFrequency: 5
waveDuration: 2000
interactionOnMove: false
onInteraction: value => {
const active = Players.active;
if (active?.canSeek && active?.positionSupported)
active.position = value * active.length;
}
Binding {
target: positionLabel
property: "text"
value: root.lengthStr(positionSlider.pos * (Players.active?.length ?? 0))
when: positionSlider.dragging
}
}
StyledText {