2018-12-22 14:07:44 +00:00
|
|
|
import QtQuick 2.0
|
2018-12-22 14:13:53 +00:00
|
|
|
import QtQuick.Controls 2.3
|
2018-11-28 18:41:54 +00:00
|
|
|
import QtQuick.Dialogs 1.3
|
|
|
|
import QtQuick.Layouts 1.11
|
2018-12-22 14:21:42 +00:00
|
|
|
import QtQuick.Window 2.2
|
2018-11-28 18:41:54 +00:00
|
|
|
import Qt.labs.settings 1.0
|
|
|
|
import Qt.labs.platform 1.0 as LabsPlatform
|
|
|
|
import player 1.0
|
|
|
|
|
2018-11-29 08:25:54 +00:00
|
|
|
Slider {
|
|
|
|
id: progressBar
|
|
|
|
objectName: "progressBar"
|
2018-12-12 08:28:53 +00:00
|
|
|
property string currentMediaURL: ""
|
2018-11-29 08:25:54 +00:00
|
|
|
to: 1
|
|
|
|
value: 0.0
|
|
|
|
Connections {
|
|
|
|
target: player
|
|
|
|
onPositionChanged: function (position) {
|
|
|
|
if (!pressed) {
|
|
|
|
progressBar.value = position
|
2018-11-28 18:41:54 +00:00
|
|
|
}
|
2018-11-29 08:25:54 +00:00
|
|
|
}
|
|
|
|
onDurationChanged: function (duration) {
|
|
|
|
progressBar.to = duration
|
|
|
|
}
|
|
|
|
onCachedDurationChanged: function (duration) {
|
|
|
|
cachedLength.duration = duration
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onMoved: {
|
|
|
|
player.playerCommand(Enums.Commands.SeekAbsolute, value)
|
|
|
|
}
|
2018-11-28 18:41:54 +00:00
|
|
|
|
2018-11-29 08:25:54 +00:00
|
|
|
function getProgressBarHeight(nyan, isMouse) {
|
2018-12-10 08:25:52 +00:00
|
|
|
var x = fun.nyanCat ? mainWindow.virtualHeight / 64 : mainWindow.virtualHeight / 380
|
2018-11-29 08:25:54 +00:00
|
|
|
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
|
2018-12-12 08:28:53 +00:00
|
|
|
width: progressBar.width
|
2018-11-29 08:25:54 +00:00
|
|
|
height: parent.height
|
|
|
|
anchors.fill: parent
|
2018-12-12 08:28:53 +00:00
|
|
|
|
2018-11-29 08:25:54 +00:00
|
|
|
hoverEnabled: true
|
|
|
|
propagateComposedEvents: false
|
|
|
|
acceptedButtons: Qt.NoButton
|
2018-12-12 08:28:53 +00:00
|
|
|
z: 100
|
|
|
|
property string currentTime: ""
|
|
|
|
|
|
|
|
onEntered: progressBarTimePreview.visible = true
|
|
|
|
onExited: progressBarTimePreview.visible = false
|
2018-11-28 18:41:54 +00:00
|
|
|
|
2018-11-29 08:25:54 +00:00
|
|
|
onPositionChanged: {
|
2018-12-12 08:28:53 +00:00
|
|
|
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
|
2018-11-29 08:25:54 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-28 18:41:54 +00:00
|
|
|
|
2018-11-29 08:25:54 +00:00
|
|
|
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)
|
2018-12-12 08:28:53 +00:00
|
|
|
color: getAppearanceValueForTheme(appearance.themeName,"progressBackgroundColor")
|
2018-11-28 18:41:54 +00:00
|
|
|
|
2018-11-29 08:25:54 +00:00
|
|
|
ProgressBar {
|
|
|
|
id: cachedLength
|
|
|
|
background: Item {
|
|
|
|
}
|
|
|
|
contentItem: Item {
|
2018-11-28 18:41:54 +00:00
|
|
|
Rectangle {
|
2018-11-29 08:25:54 +00:00
|
|
|
width: cachedLength.visualPosition * parent.width
|
2018-11-28 18:41:54 +00:00
|
|
|
height: parent.height
|
2018-12-01 12:10:52 +00:00
|
|
|
color: getAppearanceValueForTheme(appearance.themeName,
|
|
|
|
"progressCachedColor")
|
2018-11-28 18:41:54 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-29 08:25:54 +00:00
|
|
|
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"]
|
|
|
|
})
|
|
|
|
}
|
2018-11-28 18:41:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-29 08:25:54 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: progressLength
|
|
|
|
z: 50
|
|
|
|
anchors.left: progressBackground.left
|
|
|
|
width: progressBar.visualPosition * parent.width
|
|
|
|
height: parent.height
|
2018-12-01 12:10:52 +00:00
|
|
|
color: getAppearanceValueForTheme(appearance.themeName,
|
|
|
|
"progressSliderColor")
|
2018-11-29 08:25:54 +00:00
|
|
|
Image {
|
|
|
|
visible: fun.nyanCat
|
|
|
|
id: rainbow
|
|
|
|
anchors.fill: parent
|
|
|
|
height: parent.height
|
|
|
|
width: parent.width
|
|
|
|
source: "qrc:/icons/rainbow.png"
|
|
|
|
fillMode: Image.TileHorizontally
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-12 08:28:53 +00:00
|
|
|
|
2018-11-29 08:25:54 +00:00
|
|
|
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
|
2018-12-10 08:25:52 +00:00
|
|
|
radius: mainWindow.virtualHeight / 59
|
2018-12-03 08:17:57 +00:00
|
|
|
color: appearance.themeName
|
|
|
|
== "RoosterTeeth" ? "white" : fun.nyanCat ? "transparent" : getAppearanceValueForTheme(
|
|
|
|
appearance.themeName,
|
|
|
|
"progressSliderColor")
|
2018-11-29 08:25:54 +00:00
|
|
|
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
|
2018-11-29 08:25:54 +00:00
|
|
|
id: nyanimation
|
|
|
|
anchors.centerIn: parent
|
|
|
|
source: "qrc:/icons/nyancat.gif"
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|