1
0
Fork 0
VideoPlayer/src/qml/UIComponents/VideoProgress.qml

168 lines
5.8 KiB
QML
Raw Normal View History

import QtQuick 2.0
2018-12-22 14:13:53 +00:00
import QtQuick.Controls 2.3
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.11
import QtQuick.Window 2.11
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0
Slider {
id: progressBar
objectName: "progressBar"
property string currentMediaURL: ""
to: 1
value: 0.0
Connections {
target: player
onPositionChanged: function (position) {
if (!pressed) {
progressBar.value = position
}
}
onDurationChanged: function (duration) {
progressBar.to = duration
}
onCachedDurationChanged: function (duration) {
cachedLength.duration = duration
}
}
onMoved: {
player.playerCommand(Enums.Commands.SeekAbsolute, value)
}
function getProgressBarHeight(nyan, isMouse) {
var x = fun.nyanCat ? mainWindow.virtualHeight / 64 : mainWindow.virtualHeight / 380
if (appearance.themeName == "Niconico" && !fun.nyanCat) {
return x * 2
} else if (isMouse & !fun.nyanCat) {
return x * 2
} else {
return x
}
}
function getHandleVisibility(themeName, isMouse) {
if (appearance.themeName == "Niconico" && isMouse) {
return true
} else if (appearance.themeName == "Niconico") {
return false
} else {
return true
}
}
MouseArea {
id: mouseAreaProgressBar
width: progressBar.width
height: parent.height
anchors.fill: parent
hoverEnabled: true
propagateComposedEvents: false
acceptedButtons: Qt.NoButton
z: 100
property string currentTime: ""
onEntered: progressBarTimePreview.visible = true
onExited: progressBarTimePreview.visible = false
onPositionChanged: {
var a = (progressBar.to / progressBar.availableWidth) * (mouseAreaProgressBar.mapToItem(progressBar, mouseAreaProgressBar.mouseX, 0).x - 2)
progressBarTimePreview.playerCommand(Enums.Commands.SeekAbsolute, a)
progressBarTimePreview.x = mouseAreaProgressBar.mapToItem(controlsOverlay, mouseAreaProgressBar.mouseX, 0).x - progressBarTimePreview.width / 2
progressBarTimePreview.y = progressBackground.y - progressBarTimePreview.height - controlsBar.height * 2
}
}
background: Rectangle {
id: progressBackground
x: progressBar.leftPadding
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
width: progressBar.availableWidth
height: progressBar.getProgressBarHeight(
fun.nyanCat, mouseAreaProgressBar.containsMouse)
color: getAppearanceValueForTheme(appearance.themeName,"progressBackgroundColor")
ProgressBar {
id: cachedLength
background: Item {
}
contentItem: Item {
Rectangle {
width: cachedLength.visualPosition * parent.width
height: parent.height
color: getAppearanceValueForTheme(appearance.themeName,
"progressCachedColor")
}
}
z: 40
to: progressBar.to
property int duration
value: progressBar.value + duration
anchors.fill: parent
}
Item {
anchors.fill: parent
id: chapterMarkers
Connections {
target: player
onChaptersChanged: function (chapters) {
for (var i = 0, len = chapters.length; i < len; i++) {
var component = Qt.createComponent("ChapterMarker.qml")
var marker = component.createObject(chapterMarkers, {
time: chapters[i]["time"]
})
}
}
}
}
Rectangle {
id: progressLength
z: 50
anchors.left: progressBackground.left
width: progressBar.visualPosition * parent.width
height: parent.height
color: getAppearanceValueForTheme(appearance.themeName,
"progressSliderColor")
Image {
visible: fun.nyanCat
id: rainbow
anchors.fill: parent
height: parent.height
width: parent.width
source: "qrc:/icons/rainbow.png"
fillMode: Image.TileHorizontally
}
}
}
handle: Rectangle {
z: 70
id: handleRect
x: progressBar.leftPadding + progressBar.visualPosition
* (progressBar.availableWidth - width)
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
implicitHeight: radius
implicitWidth: radius
radius: mainWindow.virtualHeight / 59
color: appearance.themeName
== "RoosterTeeth" ? "white" : fun.nyanCat ? "transparent" : getAppearanceValueForTheme(
appearance.themeName,
"progressSliderColor")
visible: getHandleVisibility(appearance.themeName,
mouseAreaProgressBar.containsMouse)
AnimatedImage {
z: 80
visible: fun.nyanCat
paused: progressBar.pressed
2018-11-30 16:42:19 +00:00
height: mainWindow.virtualHeight / 28
id: nyanimation
anchors.centerIn: parent
source: "qrc:/icons/nyancat.gif"
fillMode: Image.PreserveAspectFit
}
}
}