From 1f8b14f72edb44b225afb03a562864a5b9f17c0f Mon Sep 17 00:00:00 2001 From: namedkitten Date: Tue, 12 May 2020 14:57:26 +0100 Subject: [PATCH] Remove QML based subtitles. --- src/Backends/MPV/MPVBackend.cpp | 1 - src/Backends/MPV/MPVBackend.hpp | 1 - src/Backends/MPVCommon/MPVCommon.cpp | 5 -- src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp | 1 - src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp | 1 - src/backendinterface.hpp | 1 - src/qml/Dialogs/SettingsDialog.qml | 25 ------- src/qml/SubtitlesBar.qml | 67 ------------------- .../UIComponents/ControlsBar/ControlsBar.qml | 4 -- src/qml/UIComponents/MenuBar/MainMenu.qml | 7 -- src/qml/Utils/translations.js | 10 --- src/qml/main.qml | 11 --- src/qml/qml.qrc | 1 - 13 files changed, 135 deletions(-) delete mode 100644 src/qml/SubtitlesBar.qml diff --git a/src/Backends/MPV/MPVBackend.cpp b/src/Backends/MPV/MPVBackend.cpp index 3f295d9..8eeb78e 100644 --- a/src/Backends/MPV/MPVBackend.cpp +++ b/src/Backends/MPV/MPVBackend.cpp @@ -171,7 +171,6 @@ MPVBackend::MPVBackend(QQuickItem* parent) mpv_observe_property(mpv, 0, "mute", MPV_FORMAT_NONE); 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_observe_property(mpv, 0, "demuxer-cache-duration", MPV_FORMAT_DOUBLE); mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_NODE); diff --git a/src/Backends/MPV/MPVBackend.hpp b/src/Backends/MPV/MPVBackend.hpp index 6b1c5b6..ed2907d 100644 --- a/src/Backends/MPV/MPVBackend.hpp +++ b/src/Backends/MPV/MPVBackend.hpp @@ -80,7 +80,6 @@ signals: void cachedDurationChanged(const double& duration); void playlistPositionChanged(const double& position); void titleChanged(const QString& title); - void subtitlesChanged(const QString& subtitles); void durationStringChanged(const QString& string); void tracksChanged(const QVariantList& tracks); void audioDevicesChanged(const QVariantMap& devices); diff --git a/src/Backends/MPVCommon/MPVCommon.cpp b/src/Backends/MPVCommon/MPVCommon.cpp index f56c251..f5c889a 100644 --- a/src/Backends/MPVCommon/MPVCommon.cpp +++ b/src/Backends/MPVCommon/MPVCommon.cpp @@ -476,11 +476,6 @@ void handle_mpv_event(BackendInterface* b, mpv_event* event) char* title = *(char**)prop->data; emit b->titleChanged(QString(title)); } - } else if (strcmp(prop->name, "sub-text") == 0) { - if (prop->format == MPV_FORMAT_STRING) { - char* subs = *(char**)prop->data; - emit b->subtitlesChanged(QString(subs)); - } } else if (strcmp(prop->name, "demuxer-cache-duration") == 0) { if (prop->format == MPV_FORMAT_DOUBLE) { double duration = *(double*)prop->data; diff --git a/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp b/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp index cda0adb..3763a11 100644 --- a/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp +++ b/src/Backends/MPVNoFBO/MPVNoFBOBackend.cpp @@ -94,7 +94,6 @@ MPVNoFBOBackend::MPVNoFBOBackend(QQuickItem* parent) mpv_observe_property(mpv, 0, "mute", MPV_FORMAT_NONE); 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_observe_property(mpv, 0, "demuxer-cache-duration", MPV_FORMAT_DOUBLE); mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_NODE); diff --git a/src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp b/src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp index 7d015c7..b83dec0 100644 --- a/src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp +++ b/src/Backends/MPVNoFBO/MPVNoFBOBackend.hpp @@ -98,7 +98,6 @@ signals: void cachedDurationChanged(const double& duration); void playlistPositionChanged(const double& position); void titleChanged(const QString& title); - void subtitlesChanged(const QString& subtitles); void durationStringChanged(const QString& string); void tracksChanged(const QVariantList& tracks); void audioDevicesChanged(const QVariantMap& devices); diff --git a/src/backendinterface.hpp b/src/backendinterface.hpp index aace662..48ee5f7 100644 --- a/src/backendinterface.hpp +++ b/src/backendinterface.hpp @@ -34,7 +34,6 @@ signals: virtual void cachedDurationChanged(const double& duration) = 0; virtual void playlistPositionChanged(const double& position) = 0; virtual void titleChanged(const QString& title) = 0; - virtual void subtitlesChanged(const QString& subtitles) = 0; virtual void durationStringChanged(const QString& string) = 0; virtual void tracksChanged(const QVariantList& tracks) = 0; virtual void audioDevicesChanged(const QVariantMap& devices) = 0; diff --git a/src/qml/Dialogs/SettingsDialog.qml b/src/qml/Dialogs/SettingsDialog.qml index 930de7a..e02840c 100644 --- a/src/qml/Dialogs/SettingsDialog.qml +++ b/src/qml/Dialogs/SettingsDialog.qml @@ -96,30 +96,6 @@ Dialog { onEditingFinished: setFont() } } - Item { - Layout.leftMargin: 30 - Layout.bottomMargin: 10 - height: 30 - Text { - id: subtitlesFontSizeLabel - height: 30 - text: translate.getTranslation("SUBTITLES_FONT_SIZE", i18n.language) - verticalAlignment: Text.AlignVCenter - } - TextField { - id: subtitlesFontSizeInput - anchors.left: subtitlesFontSizeLabel.right - anchors.leftMargin: 10 - validator: IntValidator {} - inputMethodHints: Qt.ImhFormattedNumbersOnly - text: appearance.subtitlesFontSize - function setSubtitlesFontSize() { - appearance.subtitlesFontSize = parseInt( - subtitlesFontSizeInput.text) - } - onEditingFinished: setSubtitlesFontSize() - } - } Item { Layout.leftMargin: 30 Layout.bottomMargin: 10 @@ -154,7 +130,6 @@ Dialog { onAccepted: { seekBy.setSeekBy() fontInput.setFont() - subtitlesFontSizeInput.setSubtitlesFontSize() uiFadeTimeInput.setUIFadeTime() settingsDialog.done() } diff --git a/src/qml/SubtitlesBar.qml b/src/qml/SubtitlesBar.qml deleted file mode 100644 index 2a5e737..0000000 --- a/src/qml/SubtitlesBar.qml +++ /dev/null @@ -1,67 +0,0 @@ -import QtQuick 2.0 -import QtQuick.Controls 2.3 -import QtQuick.Layouts 1.2 -import player 1.0 - -Item { - id: subtitlesBar - visible: !appearance.useMpvSubs - height: player.height / 8 - anchors { - bottomMargin: 5 - right: parent.right - left: parent.left - } - RowLayout { - id: nativeSubtitles - height: childrenRect.height - visible: true - anchors { - left: subtitlesBar.left - right: subtitlesBar.right - bottom: parent.bottom - bottomMargin: 10 - } - Item { - id: subsContainer - height: childrenRect.height - Layout.fillWidth: true - Layout.fillHeight: true - Layout.rightMargin: 0 - Layout.leftMargin: 0 - Layout.maximumWidth: nativeSubtitles.width - Label { - id: nativeSubs - objectName: "nativeSubs" - anchors.horizontalCenter: parent.horizontalCenter - color: "white" - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - horizontalAlignment: Text.AlignHCenter - opacity: 1 - font { - pixelSize: appearance.subtitlesFontSize - family: appearance.fontName - } - background: Rectangle { - id: subsBackground - color: getAppearanceValueForTheme(appearance.themeName, - "mainBackground") - width: subsContainer.childrenRect.width - height: subsContainer.childrenRect.height - } - onWidthChanged: { - if (width > parent.width - 10) - width = parent.width - 10 - } - onTextChanged: if (width <= parent.width - 10) - width = undefined - Connections { - target: player - onSubtitlesChanged: function (subtitles) { - nativeSubs.text = subtitles - } - } - } - } - } -} diff --git a/src/qml/UIComponents/ControlsBar/ControlsBar.qml b/src/qml/UIComponents/ControlsBar/ControlsBar.qml index 11fd250..a54520d 100644 --- a/src/qml/UIComponents/ControlsBar/ControlsBar.qml +++ b/src/qml/UIComponents/ControlsBar/ControlsBar.qml @@ -31,10 +31,6 @@ Item { component.createObject(controlsBar, {}) } - SubtitlesBar { - anchors.bottom: controlsBackground.top - } - VideoProgress { id: progressBar visible: mainWindow.controlsShowing diff --git a/src/qml/UIComponents/MenuBar/MainMenu.qml b/src/qml/UIComponents/MenuBar/MainMenu.qml index cead35d..60a7f5f 100644 --- a/src/qml/UIComponents/MenuBar/MainMenu.qml +++ b/src/qml/UIComponents/MenuBar/MainMenu.qml @@ -393,13 +393,6 @@ MenuBar { } shortcut: keybinds.cycleSub } - Action { - text: translate.getTranslation("TOGGLE_MPV_SUBS", i18n.language) - onTriggered: { - appearance.useMpvSubs = !appearance.useMpvSubs - } - shortcut: keybinds.cycleSubBackwards - } MenuSeparator {} CustomMenu { diff --git a/src/qml/Utils/translations.js b/src/qml/Utils/translations.js index 124a674..b2099d7 100644 --- a/src/qml/Utils/translations.js +++ b/src/qml/Utils/translations.js @@ -39,7 +39,6 @@ var translations = { SUBTITLES: "Subtitles", CYCLE_SUB_TRACK: "Cycle Subtitle Track", CYCLE_AUDIO_TRACK: "Cycle Audio Track", - TOGGLE_MPV_SUBS: "Toggle MPV Subtitles", VIEW: "View", FULLSCREEN: "Fullscreen", STATS: "Statistics", @@ -91,7 +90,6 @@ var translations = { SUBTITLES: "Subtítulos", CYCLE_SUB_TRACK: "Siguientes subtítulos", CYCLE_AUDIO_TRACK: "Siguiente pista de audio", - TOGGLE_MPV_SUBS: "Activar subtítulos MPV", VIEW: "Ver", FULLSCREEN: "Pantalla completa", STATS: "Estadísticas", @@ -129,7 +127,6 @@ var translations = { SUBTITLES: "Untertitel", CYCLE_SUB_TRACK: "Wechsle Untertitel-Spur", CYCLE_AUDIO_TRACK: "Wechsle Audiospur", - TOGGLE_MPV_SUBS: "Schalte MPV Untertitel An/Aus", VIEW: "Ansicht", FULLSCREEN: "Vollbild", STATS: "Statistiken", @@ -180,7 +177,6 @@ var translations = { CYCLE_VIDEO: "Changer de vidéo", SUBTITLES: "Sous-titres", CYCLE_SUB_TRACK: "Changer de piste de sous-titres", - TOGGLE_MPV_SUBS: "Basculer les sous-titres MPV", VIEW: "Voir", FULLSCREEN: "Plein écran", STATS: "Statistiques", @@ -221,7 +217,6 @@ var translations = { SUBTITLES: "Sottotitoli", CYCLE_SUB_TRACK: "Ripeti traccia sottotitoli", CYCLE_AUDIO_TRACK: "Ripeti traccia audio", - TOGGLE_MPV_SUBS: "Attiva MPV Sottotitoli", VIEW: "Vedi", FULLSCREEN: "Schermo intero", STATS: "Statistiche", @@ -272,7 +267,6 @@ var translations = { SUBTITLES: "Субтитры", CYCLE_SUB_TRACK: "Зациклить дорожку субтитров", CYCLE_AUDIO_TRACK: "Зациклить аудиодорожку", - TOGGLE_MPV_SUBS: "Переключить MPV-субтитры", VIEW: "Вид", FULLSCREEN: "Во весь экран", STATS: "Статистика", @@ -309,7 +303,6 @@ var translations = { SUBTITLES: "Undertekster", CYCLE_SUB_TRACK: "Sirkuler Gjennom Undertekster", CYCLE_AUDIO_TRACK: "Sirkuler Gjennom Lydspor", - TOGGLE_MPV_SUBS: "Skru Av/På MPV Undertekster", VIEW: "Vis", FULLSCREEN: "Fullskjerm", STATS: "Statistikk", @@ -347,7 +340,6 @@ var translations = { SUBTITLES: "sitelen anpa", CYCLE_SUB_TRACK: "ante e sitelen anpa", CYCLE_AUDIO_TRACK: "ante e kalama", - TOGGLE_MPV_SUBS: "open anu awen e sitelen MPV", VIEW: "lukin", FULLSCREEN: "lupa lukin ale", STATS: "nanpa", @@ -399,7 +391,6 @@ var translations = { SUBTITLES: "ఉపశీర్షిక/subtitles", CYCLE_SUB_TRACK: "ఉపశీర్షిక ట్రాక్ ని సైకిల్ చేయి", CYCLE_AUDIO_TRACK: "ఆడియో ట్రాక్ ని సైకిల్ చేయి", - TOGGLE_MPV_SUBS: "ఉపశీర్షిక MPV నుండి/కు మార్చు", VIEW: "దర్శన", FULLSCREEN: "స్క్రీన్ నింపు", STATS: "గణాంకాలు", @@ -451,7 +442,6 @@ var translations = { SUBTITLES: "Phụ đề", CYCLE_SUB_TRACK: "Đảo Subtitle Track", CYCLE_AUDIO_TRACK: "Đảo Audio Track", - TOGGLE_MPV_SUBS: "Bật/Tắt phụ đề MPV", VIEW: "Nhìn", FULLSCREEN: "Toàn màn hình", STATS: "Thống kê", diff --git a/src/qml/main.qml b/src/qml/main.qml index 63e738e..cd3c46e 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -62,7 +62,6 @@ Window { id: appearance category: "Appearance" property bool titleOnlyOnFullscreen: true - property bool useMpvSubs: false property string themeName: "YouTube" property string fontName: "Roboto" property double scaleFactor: 1.0 @@ -237,16 +236,6 @@ Window { var args = Qt.application.arguments var len = Qt.application.arguments.length var argNo = 0 - - if (!appearance.useMpvSubs) { - player.setOption("sub-ass-override", "force") - player.setOption("sub-ass", "off") - player.setOption("sub-border-size", "0") - player.setOption("sub-color", "0.0/0.0/0.0/0.0") - player.setOption("sub-border-color", "0.0/0.0/0.0/0.0") - player.setOption("sub-back-color", "0.0/0.0/0.0/0.0") - } - if (len > 1) { for (argNo = 1; argNo < len; argNo++) { var argument = args[argNo] diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc index 102bd95..f3e0072 100644 --- a/src/qml/qml.qrc +++ b/src/qml/qml.qrc @@ -2,7 +2,6 @@ icon.png main.qml - SubtitlesBar.qml UIComponents/ControlsLayouts/YouTubeButtonLayout.qml UIComponents/ControlsLayouts/NiconicoButtonLayout.qml UIComponents/ControlsLayouts/RoosterTeethButtonLayout.qml