[UI] Added a option to only seek on preview whilst paused.
This commit is contained in:
parent
f63b72ba55
commit
d81680220d
|
@ -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
|
||||||
|
|
|
@ -23,7 +23,7 @@ Window {
|
||||||
QMLDebugger {
|
QMLDebugger {
|
||||||
id: qmlDebugger
|
id: qmlDebugger
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAppearanceValueForTheme(themeName, name) {
|
function getAppearanceValueForTheme(themeName, name) {
|
||||||
if (themeName == "YouTube") {
|
if (themeName == "YouTube") {
|
||||||
return youTubeAppearance[name]
|
return youTubeAppearance[name]
|
||||||
|
@ -37,7 +37,7 @@ Window {
|
||||||
Translator {
|
Translator {
|
||||||
id: translate
|
id: translate
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings {
|
Settings {
|
||||||
id: loggingSettings
|
id: loggingSettings
|
||||||
category: "Logging"
|
category: "Logging"
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,7 +382,7 @@ Window {
|
||||||
mouseAreaPlayerTimer.restart()
|
mouseAreaPlayerTimer.restart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: statsUpdater
|
id: statsUpdater
|
||||||
interval: 1000
|
interval: 1000
|
||||||
|
@ -389,7 +394,7 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: statsForNerdsText
|
id: statsForNerdsText
|
||||||
text: ""
|
text: ""
|
||||||
|
@ -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,41 +463,54 @@ 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
|
||||||
logging: loggingSettings.logPreview
|
|
||||||
|
|
||||||
onDurationStringChanged: function (durationString) {
|
Rectangle {
|
||||||
hoverProgressLabel.text = durationString
|
|
||||||
}
|
|
||||||
function startPlayer() {
|
|
||||||
update()
|
|
||||||
progressBarTimePreview.playerCommand(Enums.Commands.SetTrack, ["aid", "no"])
|
|
||||||
progressBarTimePreview.playerCommand(Enums.Commands.SetTrack, ["sid", "no"])
|
|
||||||
progressBarTimePreview.setOption("ytdl-format", "worstvideo[height<=?" + String(height) + "]/worst")
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.right: parent.right
|
||||||
width: hoverProgressLabel.width
|
width: hoverProgressLabel.width
|
||||||
height: hoverProgressLabel.height
|
height: hoverProgressLabel.height
|
||||||
anchors.right: parent.right
|
z: 100
|
||||||
color: getAppearanceValueForTheme(appearance.themeName, "mainBackground")
|
color: getAppearanceValueForTheme(appearance.themeName,
|
||||||
|
"mainBackground")
|
||||||
Text {
|
Text {
|
||||||
id: hoverProgressLabel
|
id: hoverProgressLabel
|
||||||
text: "0:00"
|
text: "0:00"
|
||||||
color: "white"
|
color: "white"
|
||||||
z: 90
|
|
||||||
font.family: appearance.fontName
|
font.family: appearance.fontName
|
||||||
font.pixelSize: mainWindow.virtualHeight / 50
|
font.pixelSize: mainWindow.virtualHeight / 50
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerBackend {
|
||||||
|
z: 90
|
||||||
|
id: progressBarTimePreview
|
||||||
|
height: parent.height
|
||||||
|
width: parent.width
|
||||||
|
logging: loggingSettings.logPreview
|
||||||
|
|
||||||
|
onDurationStringChanged: function (durationString) {
|
||||||
|
hoverProgressLabel.text = durationString
|
||||||
|
}
|
||||||
|
function startPlayer() {
|
||||||
|
update()
|
||||||
|
progressBarTimePreview.playerCommand(
|
||||||
|
Enums.Commands.SetTrack, ["aid", "no"])
|
||||||
|
progressBarTimePreview.playerCommand(
|
||||||
|
Enums.Commands.SetTrack, ["sid", "no"])
|
||||||
|
progressBarTimePreview.setOption(
|
||||||
|
"ytdl-format",
|
||||||
|
"worstvideo[height<=?" + String(
|
||||||
|
height) + "]/worst")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue