fix: only update media position on slider release
This commit is contained in:
parent
25a9d28a51
commit
24816fb0d9
2 changed files with 16 additions and 1 deletions
|
|
@ -16,6 +16,8 @@ Slider {
|
||||||
property real waveFrequency: 6
|
property real waveFrequency: 6
|
||||||
property int waveDuration: 1000
|
property int waveDuration: 1000
|
||||||
property int radius: Tokens.rounding.medium
|
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 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)
|
property color bgColour: enabled ? Colours.palette.m3secondaryContainer : Qt.alpha(Colours.palette.m3onSurface, 0.1)
|
||||||
|
|
@ -171,7 +173,8 @@ Slider {
|
||||||
}
|
}
|
||||||
onPositionChanged: e => {
|
onPositionChanged: e => {
|
||||||
dragMovement = (e.x - pressStartX) / width;
|
dragMovement = (e.x - pressStartX) / width;
|
||||||
root.interaction(posBinding.value);
|
if (root.interactionOnMove)
|
||||||
|
root.interaction(posBinding.value);
|
||||||
}
|
}
|
||||||
onReleased: e => {
|
onReleased: e => {
|
||||||
root.interaction(posBinding.value);
|
root.interaction(posBinding.value);
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,8 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
id: positionLabel
|
||||||
|
|
||||||
Layout.preferredWidth: timeMetrics.width
|
Layout.preferredWidth: timeMetrics.width
|
||||||
text: root.lengthStr(Players.active?.position ?? -1)
|
text: root.lengthStr(Players.active?.position ?? -1)
|
||||||
color: Colours.palette.m3onSurfaceVariant
|
color: Colours.palette.m3onSurfaceVariant
|
||||||
|
|
@ -80,6 +82,8 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledSlider {
|
StyledSlider {
|
||||||
|
id: positionSlider
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
value: Players.active ? Players.active.position / (Players.active.length || 1) : 0
|
value: Players.active ? Players.active.position / (Players.active.length || 1) : 0
|
||||||
enabled: Players.active?.canSeek ?? false
|
enabled: Players.active?.canSeek ?? false
|
||||||
|
|
@ -87,11 +91,19 @@ ColumnLayout {
|
||||||
animateWave: Players.active?.isPlaying ?? false
|
animateWave: Players.active?.isPlaying ?? false
|
||||||
waveFrequency: 5
|
waveFrequency: 5
|
||||||
waveDuration: 2000
|
waveDuration: 2000
|
||||||
|
interactionOnMove: false
|
||||||
onInteraction: value => {
|
onInteraction: value => {
|
||||||
const active = Players.active;
|
const active = Players.active;
|
||||||
if (active?.canSeek && active?.positionSupported)
|
if (active?.canSeek && active?.positionSupported)
|
||||||
active.position = value * active.length;
|
active.position = value * active.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binding {
|
||||||
|
target: positionLabel
|
||||||
|
property: "text"
|
||||||
|
value: root.lengthStr(positionSlider.pos * (Players.active?.length ?? 0))
|
||||||
|
when: positionSlider.dragging
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue