[UI] Native subtitles, info keybind, mouse hide.
This commit is contained in:
parent
36b01f31bc
commit
9093cdc2c6
|
@ -124,7 +124,7 @@ MpvObject::MpvObject(QQuickItem * parent)
|
||||||
//mpv_set_option_string(mpv, "ytdl", "yes");
|
//mpv_set_option_string(mpv, "ytdl", "yes");
|
||||||
mpv_set_option_string(mpv, "vo", "libmpv");
|
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-font", "Noto Sans");
|
||||||
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");
|
||||||
|
@ -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-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", "#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, "duration", MPV_FORMAT_DOUBLE);
|
||||||
mpv_observe_property(mpv, 0, "media-title", MPV_FORMAT_STRING);
|
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_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
|
||||||
|
|
||||||
mpv_set_wakeup_callback(mpv, wakeup, this);
|
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) {
|
if (prop->format == MPV_FORMAT_STRING) {
|
||||||
QMetaObject::invokeMethod(this,"setTitle");
|
QMetaObject::invokeMethod(this,"setTitle");
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(prop->name, "sub-text") == 0) {
|
||||||
|
QMetaObject::invokeMethod(this,"setSubtitles");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateControls() {
|
function updateControls() {
|
||||||
|
keybinds.focus = true
|
||||||
updatePrev()
|
updatePrev()
|
||||||
updatePlayPauseIcon()
|
updatePlayPauseIcon()
|
||||||
updateVolume()
|
updateVolume()
|
||||||
|
@ -201,8 +202,12 @@ Window {
|
||||||
titleLabel.text = player.getProperty("media-title")
|
titleLabel.text = player.getProperty("media-title")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setSubtitles() {
|
||||||
|
nativeSubs.text = player.getProperty("sub-text")
|
||||||
|
}
|
||||||
|
|
||||||
function hideControls() {
|
function hideControls() {
|
||||||
if ( (!subtitlesMenu.visible) || (!settingsMenu.visible) ) {
|
if ( ! (subtitlesMenu.visible || settingsMenu.visible) ) {
|
||||||
player.setOption("sub-margin-y", "22")
|
player.setOption("sub-margin-y", "22")
|
||||||
controlsBar.visible = false
|
controlsBar.visible = false
|
||||||
controlsBackground.visible = false
|
controlsBackground.visible = false
|
||||||
|
@ -212,14 +217,15 @@ Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showControls() {
|
function showControls() {
|
||||||
|
if (! controlsBar.visible) {
|
||||||
updateControls()
|
updateControls()
|
||||||
player.setOption("sub-margin-y",
|
//player.setOption("sub-margin-y", String(controlsBar.height + progressBar.height))
|
||||||
String(controlsBar.height + progressBar.height))
|
|
||||||
controlsBar.visible = true
|
controlsBar.visible = true
|
||||||
controlsBackground.visible = true
|
controlsBackground.visible = true
|
||||||
titleBar.visible = true
|
titleBar.visible = true
|
||||||
titleBackground.visible = true
|
titleBackground.visible = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FileDialog {
|
FileDialog {
|
||||||
id: fileDialog
|
id: fileDialog
|
||||||
|
@ -274,6 +280,7 @@ Window {
|
||||||
anchors.top: titleBar.bottom
|
anchors.top: titleBar.bottom
|
||||||
anchors.topMargin: 0
|
anchors.topMargin: 0
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
cursorShape: controlsBar.visible ? Qt.ArrowCursor : Qt.BlankCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
player.command(["cycle", "pause"])
|
player.command(["cycle", "pause"])
|
||||||
updateControls()
|
updateControls()
|
||||||
|
@ -340,8 +347,8 @@ Window {
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: controlsBackground
|
id: controlsBackground
|
||||||
height: controlsBar.height + (progressBar.topPadding * 2)
|
height: controlsBar.visible ? controlsBar.height + (progressBar.topPadding * 2)
|
||||||
- (progressBackground.height * 2)
|
- (progressBackground.height * 2) : 0
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
@ -351,9 +358,41 @@ Window {
|
||||||
opacity: 0.6
|
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 {
|
Rectangle {
|
||||||
id: controlsBar
|
id: controlsBar
|
||||||
height: Screen.height / 24
|
height: controlsBar.visible ? Screen.height / 24 : 0
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: parent.width / 128
|
anchors.rightMargin: parent.width / 128
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
@ -395,6 +434,7 @@ Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: subtitlesMenuBackground
|
id: subtitlesMenuBackground
|
||||||
anchors.fill: subtitlesMenu
|
anchors.fill: subtitlesMenu
|
||||||
|
@ -737,6 +777,7 @@ Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
id: keybinds
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
focus: true
|
focus: true
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
|
@ -746,6 +787,8 @@ Window {
|
||||||
player.command(["seek", "-10"])
|
player.command(["seek", "-10"])
|
||||||
} else if (event.key == Qt.Key_L) {
|
} else if (event.key == Qt.Key_L) {
|
||||||
player.command(["seek", "10"])
|
player.command(["seek", "10"])
|
||||||
|
} else if (event.key == Qt.Key_I) {
|
||||||
|
player.command(["script-binding", "stats/display-stats-toggle"])
|
||||||
}
|
}
|
||||||
updateControls()
|
updateControls()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue