[vlc-devel] [PATCH 43/49] qml: replace the inline track/subtitle selection with a menu in the player
Pierre Lamot
pierre at videolabs.io
Fri Oct 11 15:18:07 CEST 2019
---
modules/gui/qt/qml/player/ControlButtons.qml | 81 +++++++++++++++++++-
modules/gui/qt/qml/player/Player.qml | 8 ++
2 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/modules/gui/qt/qml/player/ControlButtons.qml b/modules/gui/qt/qml/player/ControlButtons.qml
index 5f7da1c3b9..c75abf3301 100644
--- a/modules/gui/qt/qml/player/ControlButtons.qml
+++ b/modules/gui/qt/qml/player/ControlButtons.qml
@@ -206,7 +206,86 @@ Item{
id: langBtn
size: VLCStyle.icon_medium
text: VLCIcons.audiosub
- onClicked: root.showTrackBar()
+
+ onClicked: {
+ root._lockAutoHide += 1
+ langMenu.open()
+ }
+
+ PlayerMenu {
+ id: langMenu
+ parent: rootPlayer
+ onOpened: rootPlayer._menu = langMenu
+ onMenuClosed: {
+ root._lockAutoHide -= 1
+ langBtn.forceActiveFocus()
+ rootPlayer._menu = undefined
+ }
+ focus: true
+
+ title: qsTr("Languages and Tracks")
+
+ PlayerMenu {
+ id: subtrackMenu
+ onOpened: rootPlayer._menu = subtrackMenu
+ parentMenu: langMenu
+ title: qsTr("Subtitle Track")
+ enabled: player.isPlaying && player.subtitleTracks.count > 0
+ Repeater {
+ model: player.subtitleTracks
+ PlayerMenuItem {
+ parentMenu: subtrackMenu
+ text: model.display
+ checkable: true
+ checked: model.checked
+ onTriggered: model.checked = !model.checked
+ }
+ }
+ onMenuClosed: langMenu.menuClosed()
+ }
+
+ PlayerMenu {
+ id: audiotrackMenu
+ title: qsTr("Audio Track")
+
+ parentMenu: langMenu
+ onOpened: rootPlayer._menu = audiotrackMenu
+
+ enabled: player.isPlaying && player.audioTracks.count > 0
+ Repeater {
+ model: player.audioTracks
+ PlayerMenuItem {
+ parentMenu: audiotrackMenu
+
+ text: model.display
+ checkable: true
+ checked: model.checked
+ onTriggered: model.checked = !model.checked
+ }
+ }
+ onMenuClosed: langMenu.menuClosed()
+ }
+
+ PlayerMenu {
+ id: videotrackMenu
+ title: qsTr("Video Track")
+ parentMenu: langMenu
+ onOpened: rootPlayer._menu = videotrackMenu
+ enabled: player.isPlaying && player.videoTracks.count > 0
+ Repeater {
+ model: player.videoTracks
+ PlayerMenuItem {
+ parentMenu: videotrackMenu
+ text: model.display
+ checkable: true
+ checked: model.checked
+ onTriggered: model.checked = !model.checked
+ }
+ }
+ onMenuClosed: langMenu.menuClosed()
+ }
+ }
+
property bool acceptFocus: true
}
}
diff --git a/modules/gui/qt/qml/player/Player.qml b/modules/gui/qt/qml/player/Player.qml
index d91298ae3f..6e73684e7f 100644
--- a/modules/gui/qt/qml/player/Player.qml
+++ b/modules/gui/qt/qml/player/Player.qml
@@ -30,6 +30,14 @@ import "qrc:///menus/" as Menus
Utils.NavigableFocusScope {
id: rootPlayer
+ //menu/overlay to dismiss
+ property var _menu: undefined
+
+ function dismiss() {
+ if (_menu)
+ _menu.dismiss()
+ }
+
//center image
Rectangle {
visible: !rootWindow.hasEmbededVideo
--
2.20.1
More information about the vlc-devel
mailing list