1
0
Fork 0

[UI] Native subtitles, info keybind, mouse hide.

This commit is contained in:
Kitteh 2018-10-23 21:03:06 +01:00
parent 36b01f31bc
commit 9093cdc2c6
2 changed files with 61 additions and 14 deletions

View file

@ -124,7 +124,7 @@ MpvObject::MpvObject(QQuickItem * parent)
//mpv_set_option_string(mpv, "ytdl", "yes");
mpv_set_option_string(mpv, "vo", "libmpv");
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-ass-override", "force");
mpv_set_option_string(mpv, "sub-ass", "off");
@ -133,7 +133,9 @@ MpvObject::MpvObject(QQuickItem * parent)
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-back-color", "#C0080808");
mpv_set_option_string(mpv, "sub-back-color", "#C0080808");*/
mpv_set_option_string(mpv, "sub-color", "0.0/0.0/0.0/0.0");
mpv_set_option_string(mpv, "sub-scale", "0");
@ -143,7 +145,7 @@ MpvObject::MpvObject(QQuickItem * parent)
mpv_observe_property(mpv, 0, "duration", MPV_FORMAT_DOUBLE);
mpv_observe_property(mpv, 0, "media-title", MPV_FORMAT_STRING);
mpv_observe_property(mpv, 0, "sub-text", MPV_FORMAT_STRING);
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
mpv_set_wakeup_callback(mpv, wakeup, this);
@ -236,6 +238,8 @@ void MpvObject::handle_mpv_event(mpv_event *event)
if (prop->format == MPV_FORMAT_STRING) {
QMetaObject::invokeMethod(this,"setTitle");
}
} else if (strcmp(prop->name, "sub-text") == 0) {
QMetaObject::invokeMethod(this,"setSubtitles");
}
break;
}

View file

@ -61,6 +61,7 @@ Window {
}
function updateControls() {
keybinds.focus = true
updatePrev()
updatePlayPauseIcon()
updateVolume()
@ -201,8 +202,12 @@ Window {
titleLabel.text = player.getProperty("media-title")
}
function setSubtitles() {
nativeSubs.text = player.getProperty("sub-text")
}
function hideControls() {
if ( (!subtitlesMenu.visible) || (!settingsMenu.visible) ) {
if ( ! (subtitlesMenu.visible || settingsMenu.visible) ) {
player.setOption("sub-margin-y", "22")
controlsBar.visible = false
controlsBackground.visible = false
@ -212,14 +217,15 @@ Window {
}
function showControls() {
if (! controlsBar.visible) {
updateControls()
player.setOption("sub-margin-y",
String(controlsBar.height + progressBar.height))
//player.setOption("sub-margin-y", String(controlsBar.height + progressBar.height))
controlsBar.visible = true
controlsBackground.visible = true
titleBar.visible = true
titleBackground.visible = true
}
}
FileDialog {
id: fileDialog
@ -274,6 +280,7 @@ Window {
anchors.top: titleBar.bottom
anchors.topMargin: 0
hoverEnabled: true
cursorShape: controlsBar.visible ? Qt.ArrowCursor : Qt.BlankCursor
onClicked: {
player.command(["cycle", "pause"])
updateControls()
@ -340,8 +347,8 @@ Window {
Rectangle {
id: controlsBackground
height: controlsBar.height + (progressBar.topPadding * 2)
- (progressBackground.height * 2)
height: controlsBar.visible ? controlsBar.height + (progressBar.topPadding * 2)
- (progressBackground.height * 2) : 0
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
@ -351,9 +358,41 @@ Window {
opacity: 0.6
}
Rectangle {
id: nativeSubtitles
height: nativeSubs.font.pixelSize + 4
visible: nativeSubs.text == "" ? false : true
anchors.left: controlsBar.left
anchors.right: controlsBar.right
anchors.bottom: controlsBackground.top
radius: 5
color: "transparent"
Label {
id: nativeSubs
width: parent.width
text: ""
color: "white"
font.family: notoFont.name
font.pixelSize: 24
renderType: Text.NativeRendering
horizontalAlignment: Text.AlignHCenter
anchors.bottom: parent.top
opacity: 1
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
background: Rectangle {
color: Qt.rgba(0, 0, 0, 0.6)
anchors.left: parent.left
anchors.right: parent.right
}
}
}
Rectangle {
id: controlsBar
height: Screen.height / 24
height: controlsBar.visible ? Screen.height / 24 : 0
anchors.right: parent.right
anchors.rightMargin: parent.width / 128
anchors.left: parent.left
@ -395,6 +434,7 @@ Window {
}
}
}
Rectangle {
id: subtitlesMenuBackground
anchors.fill: subtitlesMenu
@ -737,6 +777,7 @@ Window {
}
Item {
id: keybinds
anchors.fill: parent
focus: true
Keys.onPressed: {
@ -746,6 +787,8 @@ Window {
player.command(["seek", "-10"])
} else if (event.key == Qt.Key_L) {
player.command(["seek", "10"])
} else if (event.key == Qt.Key_I) {
player.command(["script-binding", "stats/display-stats-toggle"])
}
updateControls()
}