1
0
Fork 0

[UI] Use ProgressBar as it is more suited for this task rather than changing the width of a rectangle.

This commit is contained in:
NamedKitten 2018-11-22 11:49:51 +00:00
parent c5606041e1
commit 14116cb507

View file

@ -120,7 +120,7 @@ Item {
progressBar.to = duration progressBar.to = duration
}) })
player.cachedDurationChanged.connect(function(duration) { player.cachedDurationChanged.connect(function(duration) {
cachedLength.width = progressBackground.width / progressBar.to * duration cachedLength.value = progressBar.value + duration
}) })
} }
onMoved: { onMoved: {
@ -153,42 +153,51 @@ Item {
width: progressBar.availableWidth width: progressBar.availableWidth
height: implicitHeight height: implicitHeight
color: Qt.rgba(255, 255, 255, 0.6) color: Qt.rgba(255, 255, 255, 0.6)
radius: height ProgressBar {
Rectangle {
id: progressLength
width: progressBar.visualPosition * parent.width
height: parent.height
color: appearance.progressSliderColor
opacity: 1
radius: height
anchors.leftMargin: 100
Image {
visible: fun.nyanCat
id: rainbow
anchors.fill: parent
height: parent.height
width: parent.width
source: "qrc:/player/icons/rainbow.png"
fillMode: Image.TileHorizontally
}
}
Rectangle {
id: cachedLength id: cachedLength
z: 100 background: Item {}
radius: height contentItem: Item {
anchors.left: progressLength.right Rectangle {
anchors.leftMargin: 2 width: cachedLength.visualPosition * parent.width
//anchors.left: progressBar.handle.horizontalCenter height: parent.height
anchors.bottom: progressBar.background.bottom color: "white"
anchors.top: progressBar.background.top }
height: progressBar.background.height }
color: "white" z: 40
opacity: 0.8 to: progressBar.to
anchors.fill: parent
}
ProgressBar {
z: 50
id: progressLength
width: parent.width
height: parent.height
to: progressBar.to
value: progressBar.value
opacity: 1
anchors.leftMargin: 0
background: Item {}
contentItem: Item {
Rectangle {
width: progressLength.visualPosition * parent.width + progressBar.handle.width / 2
height: parent.height
color: appearance.progressSliderColor
Image {
visible: fun.nyanCat
id: rainbow
anchors.fill: parent
height: parent.height
width: parent.width
source: "qrc:/player/icons/rainbow.png"
fillMode: Image.TileHorizontally
}
}
}
} }
} }
handle: Rectangle { handle: Rectangle {
z: 70
id: handleRect id: handleRect
x: progressBar.leftPadding + progressBar.visualPosition x: progressBar.leftPadding + progressBar.visualPosition
* (progressBar.availableWidth - width) * (progressBar.availableWidth - width)
@ -198,6 +207,7 @@ Item {
radius: 12 + (progressBackground.height / 2) radius: 12 + (progressBackground.height / 2)
color: fun.nyanCat ? "transparent" : appearance.progressSliderColor color: fun.nyanCat ? "transparent" : appearance.progressSliderColor
AnimatedImage { AnimatedImage {
z: 80
visible: fun.nyanCat visible: fun.nyanCat
paused: progressBar.pressed paused: progressBar.pressed
height: 30 height: 30