[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
|
||||
objectName: "progressBar"
|
||||
property string currentMediaURL: ""
|
||||
property bool playing: false
|
||||
to: 1
|
||||
value: 0.0
|
||||
Connections {
|
||||
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) {
|
||||
if (!pressed) {
|
||||
progressBar.value = position
|
||||
|
@ -62,14 +70,31 @@ Slider {
|
|||
z: 100
|
||||
property string currentTime: ""
|
||||
|
||||
onEntered: progressBarTimePreview.visible = true
|
||||
onExited: progressBarTimePreview.visible = false
|
||||
onEntered: previewRect.visible = true
|
||||
onExited: previewRect.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
|
||||
var a = (progressBar.to / progressBar.availableWidth)
|
||||
* (mouseAreaProgressBar.mapToItem(
|
||||
progressBar, mouseAreaProgressBar.mouseX, 0).x - 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
|
||||
height: progressBar.getProgressBarHeight(
|
||||
fun.nyanCat, mouseAreaProgressBar.containsMouse)
|
||||
color: getAppearanceValueForTheme(appearance.themeName,"progressBackgroundColor")
|
||||
color: getAppearanceValueForTheme(appearance.themeName,
|
||||
"progressBackgroundColor")
|
||||
|
||||
ProgressBar {
|
||||
id: cachedLength
|
||||
|
@ -137,7 +163,6 @@ Slider {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
handle: Rectangle {
|
||||
z: 70
|
||||
id: handleRect
|
||||
|
|
|
@ -46,7 +46,6 @@ Window {
|
|||
property bool logPreview: false
|
||||
}
|
||||
|
||||
|
||||
Settings {
|
||||
id: backendSettings
|
||||
category: "Backend"
|
||||
|
@ -58,6 +57,7 @@ Window {
|
|||
id: appearance
|
||||
category: "Appearance"
|
||||
property bool titleOnlyOnFullscreen: true
|
||||
property bool updatePreviewWhilstPlaying: true
|
||||
property bool clickToPause: true
|
||||
property bool useMpvSubs: false
|
||||
property string themeName: "YouTube"
|
||||
|
@ -176,15 +176,16 @@ Window {
|
|||
property int lastScreenVisibility
|
||||
|
||||
function toggleFullscreen() {
|
||||
console.error("a", mainWindow.visibility, Window.FullScreen, lastScreenVisibility)
|
||||
console.error("a", mainWindow.visibility, Window.FullScreen,
|
||||
lastScreenVisibility)
|
||||
if (mainWindow.visibility != Window.FullScreen) {
|
||||
lastScreenVisibility = mainWindow.visibility
|
||||
mainWindow.visibility = Window.FullScreen
|
||||
} else {
|
||||
mainWindow.visibility = lastScreenVisibility
|
||||
}
|
||||
console.error("b", mainWindow.visibility, Window.FullScreen, lastScreenVisibility)
|
||||
|
||||
console.error("b", mainWindow.visibility, Window.FullScreen,
|
||||
lastScreenVisibility)
|
||||
}
|
||||
|
||||
Utils {
|
||||
|
@ -202,7 +203,11 @@ Window {
|
|||
onPlaylistChanged: function (playlist) {
|
||||
for (var thing in playlist) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -410,10 +415,8 @@ Window {
|
|||
Component.onCompleted: {
|
||||
console.error(statsForNerdsText.lineHeight, font.pixelSize)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
MainMenu {
|
||||
id: menuBar
|
||||
visible: controlsOverlay.controlsShowing
|
||||
|
@ -460,41 +463,54 @@ Window {
|
|||
|
||||
ControlsBar {
|
||||
id: controlsBar
|
||||
PlayerBackend {
|
||||
id: progressBarTimePreview
|
||||
Item {
|
||||
id: previewRect
|
||||
height: 144
|
||||
width: 256
|
||||
z: 80
|
||||
visible: true
|
||||
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")
|
||||
}
|
||||
visible: false
|
||||
|
||||
Rectangle {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
width: hoverProgressLabel.width
|
||||
height: hoverProgressLabel.height
|
||||
anchors.right: parent.right
|
||||
color: getAppearanceValueForTheme(appearance.themeName, "mainBackground")
|
||||
z: 100
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
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