update mpris with slider
This commit is contained in:
parent
399f69a68a
commit
e01096691f
1 changed files with 47 additions and 18 deletions
|
|
@ -1,13 +1,17 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
|
||||
import qs.components
|
||||
import qs.config
|
||||
import qs.services
|
||||
import qs.widgets
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
StyledButton {
|
||||
id: root
|
||||
|
||||
padding: 6
|
||||
|
||||
onClicked: {
|
||||
if (!Mpris.active.canTogglePlaying) {
|
||||
return;
|
||||
|
|
@ -19,29 +23,54 @@ StyledButton {
|
|||
}
|
||||
}
|
||||
|
||||
content: StyledText {
|
||||
id: text
|
||||
text: `${Mpris.active?.isPlaying ? "" : ""} ${Mpris.active?.trackTitle} - ${Mpris.active?.trackArtist}`
|
||||
content: ColumnLayout {
|
||||
id: content
|
||||
|
||||
font.pixelSize: Dimensions.mpris.fontSize
|
||||
spacing: 0
|
||||
|
||||
states: State {
|
||||
name: "hovered"
|
||||
when: root.containsMouse
|
||||
PropertyChanges {
|
||||
text {
|
||||
color: Theme.palette.base300
|
||||
implicitWidth: text.width
|
||||
implicitHeight: text.height
|
||||
StyledText {
|
||||
id: text
|
||||
text: `${Mpris.active?.isPlaying ? "" : ""} ${Mpris.active?.trackTitle} - ${Mpris.active?.trackArtist}`
|
||||
|
||||
font.pixelSize: Dimensions.mpris.fontSize
|
||||
|
||||
states: State {
|
||||
name: "hovered"
|
||||
when: root.containsMouse
|
||||
PropertyChanges {
|
||||
text {
|
||||
color: Theme.palette.primarycontent
|
||||
}
|
||||
}
|
||||
}
|
||||
transitions: Transition {
|
||||
from: ""
|
||||
to: "hovered"
|
||||
reversible: true
|
||||
ColorAnimation {
|
||||
properties: "color"
|
||||
duration: 100
|
||||
easing.type: Easing.InOutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
transitions: Transition {
|
||||
from: ""
|
||||
to: "hovered"
|
||||
reversible: true
|
||||
ColorAnimation {
|
||||
properties: "color"
|
||||
duration: 200
|
||||
easing.type: Easing.InOutCubic
|
||||
StyledSlider {
|
||||
from: 0
|
||||
to: Mpris.active?.length ?? 0
|
||||
value: Mpris.active?.position
|
||||
implicitHeight: 6
|
||||
Layout.fillWidth: true
|
||||
onMoved: {
|
||||
Mpris.active.position = value;
|
||||
}
|
||||
|
||||
Timer {
|
||||
running: Mpris.active?.isPlaying
|
||||
interval: 1000
|
||||
repeat: true
|
||||
onTriggered: Mpris.active?.positionChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue