1
0
Fork 0

[UI] Added a option to only seek on preview whilst paused.

This commit is contained in:
NamedKitten 2018-12-23 14:52:31 +00:00
parent f63b72ba55
commit d81680220d
2 changed files with 78 additions and 37 deletions

View file

@ -11,10 +11,18 @@ Slider {
id: progressBar id: progressBar
objectName: "progressBar" objectName: "progressBar"
property string currentMediaURL: "" property string currentMediaURL: ""
property bool playing: false
to: 1 to: 1
value: 0.0 value: 0.0
Connections { Connections {
target: player target: player
onPlayStatusChanged: function (status) {
if (status == Enums.PlayStatus.Playing) {
progressBar.playing = true
} else if (status == status == Enums.PlayStatus.Paused) {
progressBar.playing = false
}
}
onPositionChanged: function (position) { onPositionChanged: function (position) {
if (!pressed) { if (!pressed) {
progressBar.value = position progressBar.value = position
@ -62,14 +70,31 @@ Slider {
z: 100 z: 100
property string currentTime: "" property string currentTime: ""
onEntered: progressBarTimePreview.visible = true onEntered: previewRect.visible = true
onExited: progressBarTimePreview.visible = false onExited: previewRect.visible = false
onPositionChanged: { onPositionChanged: {
var a = (progressBar.to / progressBar.availableWidth) * (mouseAreaProgressBar.mapToItem(progressBar, mouseAreaProgressBar.mouseX, 0).x - 2) var a = (progressBar.to / progressBar.availableWidth)
progressBarTimePreview.playerCommand(Enums.Commands.SeekAbsolute, a) * (mouseAreaProgressBar.mapToItem(
progressBarTimePreview.x = mouseAreaProgressBar.mapToItem(controlsOverlay, mouseAreaProgressBar.mouseX, 0).x - progressBarTimePreview.width / 2 progressBar, mouseAreaProgressBar.mouseX, 0).x - 2)
progressBarTimePreview.y = progressBackground.y - progressBarTimePreview.height - controlsBar.height * 2 var shouldSeek = false
if (!appearance.updatePreviewWhilstPlaying) {
if (!progressBar.playing) {
shouldSeek = true
}
} else {
shouldSeek = true
}
if (shouldSeek) {
progressBarTimePreview.playerCommand(
Enums.Commands.SeekAbsolute, a)
} else {
hoverProgressLabel.text = utils.createTimestamp(a)
}
previewRect.x = mouseAreaProgressBar.mapToItem(
controlsOverlay, mouseAreaProgressBar.mouseX,
0).x - previewRect.width / 2
previewRect.y = progressBackground.y - previewRect.height - controlsBar.height * 2
} }
} }
@ -80,7 +105,8 @@ Slider {
width: progressBar.availableWidth width: progressBar.availableWidth
height: progressBar.getProgressBarHeight( height: progressBar.getProgressBarHeight(
fun.nyanCat, mouseAreaProgressBar.containsMouse) fun.nyanCat, mouseAreaProgressBar.containsMouse)
color: getAppearanceValueForTheme(appearance.themeName,"progressBackgroundColor") color: getAppearanceValueForTheme(appearance.themeName,
"progressBackgroundColor")
ProgressBar { ProgressBar {
id: cachedLength id: cachedLength
@ -137,7 +163,6 @@ Slider {
} }
} }
handle: Rectangle { handle: Rectangle {
z: 70 z: 70
id: handleRect id: handleRect

View file

@ -46,7 +46,6 @@ Window {
property bool logPreview: false property bool logPreview: false
} }
Settings { Settings {
id: backendSettings id: backendSettings
category: "Backend" category: "Backend"
@ -58,6 +57,7 @@ Window {
id: appearance id: appearance
category: "Appearance" category: "Appearance"
property bool titleOnlyOnFullscreen: true property bool titleOnlyOnFullscreen: true
property bool updatePreviewWhilstPlaying: true
property bool clickToPause: true property bool clickToPause: true
property bool useMpvSubs: false property bool useMpvSubs: false
property string themeName: "YouTube" property string themeName: "YouTube"
@ -176,15 +176,16 @@ Window {
property int lastScreenVisibility property int lastScreenVisibility
function toggleFullscreen() { function toggleFullscreen() {
console.error("a", mainWindow.visibility, Window.FullScreen, lastScreenVisibility) console.error("a", mainWindow.visibility, Window.FullScreen,
lastScreenVisibility)
if (mainWindow.visibility != Window.FullScreen) { if (mainWindow.visibility != Window.FullScreen) {
lastScreenVisibility = mainWindow.visibility lastScreenVisibility = mainWindow.visibility
mainWindow.visibility = Window.FullScreen mainWindow.visibility = Window.FullScreen
} else { } else {
mainWindow.visibility = lastScreenVisibility mainWindow.visibility = lastScreenVisibility
} }
console.error("b", mainWindow.visibility, Window.FullScreen, lastScreenVisibility) console.error("b", mainWindow.visibility, Window.FullScreen,
lastScreenVisibility)
} }
Utils { Utils {
@ -202,7 +203,11 @@ Window {
onPlaylistChanged: function (playlist) { onPlaylistChanged: function (playlist) {
for (var thing in playlist) { for (var thing in playlist) {
var item = playlist[thing] var item = playlist[thing]
if (playlist[thing]["current"]) {progressBarTimePreview.playerCommand(Enums.Commands.LoadFile, String(playlist[thing]["filename"]))} if (playlist[thing]["current"]) {
progressBarTimePreview.playerCommand(
Enums.Commands.LoadFile,
String(playlist[thing]["filename"]))
}
progressBarTimePreview.playerCommand(Enums.Commands.ForcePause) progressBarTimePreview.playerCommand(Enums.Commands.ForcePause)
} }
} }
@ -410,10 +415,8 @@ Window {
Component.onCompleted: { Component.onCompleted: {
console.error(statsForNerdsText.lineHeight, font.pixelSize) console.error(statsForNerdsText.lineHeight, font.pixelSize)
} }
} }
MainMenu { MainMenu {
id: menuBar id: menuBar
visible: controlsOverlay.controlsShowing visible: controlsOverlay.controlsShowing
@ -460,12 +463,37 @@ Window {
ControlsBar { ControlsBar {
id: controlsBar id: controlsBar
PlayerBackend { Item {
id: progressBarTimePreview id: previewRect
height: 144 height: 144
width: 256 width: 256
z: 80 z: 80
visible: true visible: false
Rectangle {
anchors.bottom: parent.bottom
anchors.right: parent.right
width: hoverProgressLabel.width
height: hoverProgressLabel.height
z: 100
color: getAppearanceValueForTheme(appearance.themeName,
"mainBackground")
Text {
id: hoverProgressLabel
text: "0:00"
color: "white"
font.family: appearance.fontName
font.pixelSize: mainWindow.virtualHeight / 50
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
}
}
PlayerBackend {
z: 90
id: progressBarTimePreview
height: parent.height
width: parent.width
logging: loggingSettings.logPreview logging: loggingSettings.logPreview
onDurationStringChanged: function (durationString) { onDurationStringChanged: function (durationString) {
@ -473,26 +501,14 @@ Window {
} }
function startPlayer() { function startPlayer() {
update() update()
progressBarTimePreview.playerCommand(Enums.Commands.SetTrack, ["aid", "no"]) progressBarTimePreview.playerCommand(
progressBarTimePreview.playerCommand(Enums.Commands.SetTrack, ["sid", "no"]) Enums.Commands.SetTrack, ["aid", "no"])
progressBarTimePreview.setOption("ytdl-format", "worstvideo[height<=?" + String(height) + "]/worst") progressBarTimePreview.playerCommand(
} Enums.Commands.SetTrack, ["sid", "no"])
progressBarTimePreview.setOption(
Rectangle { "ytdl-format",
anchors.bottom: parent.bottom "worstvideo[height<=?" + String(
width: hoverProgressLabel.width height) + "]/worst")
height: hoverProgressLabel.height
anchors.right: parent.right
color: getAppearanceValueForTheme(appearance.themeName, "mainBackground")
Text {
id: hoverProgressLabel
text: "0:00"
color: "white"
z: 90
font.family: appearance.fontName
font.pixelSize: mainWindow.virtualHeight / 50
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
} }
} }
} }