Files
quickdots/widgets/sidebar/mpris/MediaSlider.qml

50 lines
1.2 KiB
QML

import QtQuick
import "../../../config" as Cfg
Item {
id: root
property real fraction: 0
property bool interactive: true
signal seeked(real fraction)
readonly property var t: Cfg.Config.theme
implicitHeight: 14
function seek(posX) {
seeked(Math.max(0, Math.min(1, posX / width)))
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: 3
radius: 2
color: root.t.mprisTrackColor
Rectangle {
width: parent.width * root.fraction
height: parent.height
radius: parent.radius
color: root.t.mprisAccent
}
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
x: Math.max(0, Math.min(parent.width - width, (parent.width - width) * root.fraction))
width: 10
height: 10
radius: 5
color: root.t.mprisAccent
}
MouseArea {
anchors.fill: parent
cursorShape: root.interactive ? Qt.PointingHandCursor : Qt.ArrowCursor
onPressed: pos => root.seek(pos.x)
onPositionChanged: pos => { if (pressed) root.seek(pos.x) }
}
}