1
0
Fork 0

[UI] Fixed cache bar and added screenshotting keybinds.

This commit is contained in:
Kitteh 2018-10-26 17:02:07 +01:00
parent bda712a4ce
commit bd3995d4f4
2 changed files with 70 additions and 23 deletions

View file

@ -126,7 +126,8 @@ MpvObject::MpvObject(QQuickItem * parent)
//mpp_set_option_string(mpv, "no-sub-ass", "yes) //mpp_set_option_string(mpv, "no-sub-ass", "yes)
mpv_set_option_string(mpv, "slang", "en"); mpv_set_option_string(mpv, "slang", "en");
/*mpv_set_option_string(mpv, "sub-font", "Noto Sans"); mpv_set_option_string(mpv, "sub-font", "Noto Sans");
mpv_set_option_string(mpv, "sub-font-size", "24");
mpv_set_option_string(mpv, "sub-ass-override", "force"); mpv_set_option_string(mpv, "sub-ass-override", "force");
mpv_set_option_string(mpv, "sub-ass", "off"); mpv_set_option_string(mpv, "sub-ass", "off");
mpv_set_option_string(mpv, "sub-border-size", "0"); mpv_set_option_string(mpv, "sub-border-size", "0");
@ -134,7 +135,7 @@ MpvObject::MpvObject(QQuickItem * parent)
mpv_set_option_string(mpv, "sub-scale-by-window", "on"); mpv_set_option_string(mpv, "sub-scale-by-window", "on");
mpv_set_option_string(mpv, "sub-scale-with-window", "on"); mpv_set_option_string(mpv, "sub-scale-with-window", "on");
mpv_set_option_string(mpv, "sub-back-color", "#C0080808");*/ mpv_set_option_string(mpv, "sub-back-color", "0.0/0.0/0.0/0.0");
mpv_set_option_string(mpv, "config", "yes"); mpv_set_option_string(mpv, "config", "yes");
//mpv_set_option_string(mpv, "sub-visibility", "no"); //mpv_set_option_string(mpv, "sub-visibility", "no");

View file

@ -153,11 +153,6 @@ ApplicationWindow {
progressBar.value = val progressBar.value = val
} }
function setCachedDuration(val) {
cachedLength.width = progressBar.width / progressBar.to
* (val - progressBar.value) - (progressBar.handle.width / 2)
}
function skipToNinth(val) { function skipToNinth(val) {
console.log(val) console.log(val)
var skipto = 0 var skipto = 0
@ -219,10 +214,11 @@ ApplicationWindow {
return subtitlesMenu.visible || settingsMenu.visible return subtitlesMenu.visible || settingsMenu.visible
|| fileMenuBarItem.opened || playbackMenuBarItem.opened || fileMenuBarItem.opened || playbackMenuBarItem.opened
|| viewMenuBarItem.opened || tracksMenuBarItem.opened || viewMenuBarItem.opened || tracksMenuBarItem.opened
|| screenshotSaveDialog.visible
} }
function hideControls() { function hideControls(force) {
if (!isAnyMenuOpen()) { if (!isAnyMenuOpen() || force) {
//player.setOption("sub-margin-y", "22") //player.setOption("sub-margin-y", "22")
controlsBar.visible = false controlsBar.visible = false
controlsBackground.visible = false controlsBackground.visible = false
@ -243,6 +239,22 @@ ApplicationWindow {
} }
} }
Dialog {
id: screenshotSaveDialog
title: "Save Screenshot To"
standardButtons: StandardButton.Cancel | StandardButton.Open
onAccepted: {
player.grabToImage(function (result) {
result.saveToFile(screenshotFile.text)
nativeSubs.visible = true
})
}
TextField {
id: screenshotFile
placeholderText: qsTr("~/screenshot.jpg")
}
}
FileDialog { FileDialog {
id: fileDialog id: fileDialog
title: "Please choose a file" title: "Please choose a file"
@ -331,11 +343,14 @@ ApplicationWindow {
property string statsForNerds: "I" property string statsForNerds: "I"
property string forwardFrame: "." property string forwardFrame: "."
property string backwardFrame: "," property string backwardFrame: ","
property string cycleSub: "S" property string cycleSub: "Alt+S"
property string cycleSubBackwards: "Shift+S" property string cycleSubBackwards: "Alt+Shift+S"
property string cycleAudio: "A" property string cycleAudio: "A"
property string cycleVideo: "V" property string cycleVideo: "V"
property string cycleVideoAspect: "Shift+A" property string cycleVideoAspect: "Shift+A"
property string screenshot: "S"
property string screenshotWithoutSubtitles: "Shift+S"
property string fullScreenshot: "Ctrl+S"
} }
MenuBar { MenuBar {
@ -395,6 +410,30 @@ ApplicationWindow {
onTriggered: loadDialog.open() onTriggered: loadDialog.open()
shortcut: keybinds.openURI shortcut: keybinds.openURI
} }
Action {
text: "Screenshot"
onTriggered: {
player.hideControls(true)
screenshotSaveDialog.open()
}
shortcut: keybinds.screenshot
}
Action {
text: "Screenshot w/o subtitles"
onTriggered: {
player.hideControls(true)
nativeSubs.visible = false
screenshotSaveDialog.open()
}
shortcut: keybinds.screenshotWithoutSubtitles
}
Action {
text: "Full Screenshot"
onTriggered: {
screenshotSaveDialog.open()
}
shortcut: keybinds.fullScreenshot
}
Action { Action {
text: "Exit" text: "Exit"
onTriggered: Qt.quit() onTriggered: Qt.quit()
@ -793,13 +832,18 @@ ApplicationWindow {
color: Qt.rgba(0, 0, 0, 0.6) color: Qt.rgba(0, 0, 0, 0.6)
width: t_metrics.tightBoundingRect.width + 8 width: t_metrics.tightBoundingRect.width + 8
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: (nativeSubtitles.width - t_metrics.tightBoundingRect.width) / 2 anchors.leftMargin: (nativeSubtitles.width
- t_metrics.tightBoundingRect.width) / 2
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: anchors.leftMargin anchors.rightMargin: anchors.leftMargin
} }
} }
} }
function setCachedDuration(val) {
cachedLength.width = (progressBar.width / progressBar.to) * val
}
Rectangle { Rectangle {
id: controlsBar id: controlsBar
height: controlsBar.visible ? Screen.height / 24 : 0 height: controlsBar.visible ? Screen.height / 24 : 0
@ -872,22 +916,24 @@ ApplicationWindow {
color: Qt.rgba(255, 255, 255, 0.4) color: Qt.rgba(255, 255, 255, 0.4)
Rectangle { Rectangle {
id: progressLength
width: progressBar.visualPosition * parent.width width: progressBar.visualPosition * parent.width
height: parent.height height: parent.height
color: "red" color: "red"
opacity: 1 opacity: 1
} }
} Rectangle {
Rectangle { id: cachedLength
id: cachedLength z: 1
z: 1 anchors.left: progressLength.right
//anchors.left: progressBar.handle.right anchors.leftMargin: progressBar.handle.width / 2
anchors.left: progressBar.handle.horizontalCenter //anchors.left: progressBar.handle.horizontalCenter
anchors.bottom: progressBar.background.bottom anchors.bottom: progressBar.background.bottom
anchors.top: progressBar.background.top anchors.top: progressBar.background.top
height: progressBar.background.height height: progressBar.background.height
color: "white" color: "white"
opacity: 0.8 opacity: 0.8
}
} }
handle: Rectangle { handle: Rectangle {