From 76942f710e5c518f77f7bc427f417dacb6207155 Mon Sep 17 00:00:00 2001 From: Benjamin Arnaud Date: Tue, 5 Apr 2022 16:45:37 +0200 Subject: [PATCH] qml/controlbarcontrols: Create NavigationWidget --- modules/gui/qt/Makefile.am | 1 + modules/gui/qt/player/control_list_model.hpp | 1 + .../controlbarcontrols/NavigationWidget.qml | 114 ++++++++++++++++++ modules/gui/qt/vlc.qrc | 1 + 4 files changed, 117 insertions(+) create mode 100644 modules/gui/qt/player/qml/controlbarcontrols/NavigationWidget.qml diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am index dc6988ad3b..8b220e41df 100644 --- a/modules/gui/qt/Makefile.am +++ b/modules/gui/qt/Makefile.am @@ -836,6 +836,7 @@ libqt_plugin_la_QML = \ gui/qt/player/qml/controlbarcontrols/LangButton.qml \ gui/qt/player/qml/controlbarcontrols/LoopButton.qml \ gui/qt/player/qml/controlbarcontrols/MenuButton.qml \ + gui/qt/player/qml/controlbarcontrols/NavigationWidget.qml \ gui/qt/player/qml/controlbarcontrols/NextButton.qml \ gui/qt/player/qml/controlbarcontrols/OpenButton.qml \ gui/qt/player/qml/controlbarcontrols/PlaybackSpeedButton.qml \ diff --git a/modules/gui/qt/player/control_list_model.hpp b/modules/gui/qt/player/control_list_model.hpp index 7e993ea0ba..a1b7343b4a 100644 --- a/modules/gui/qt/player/control_list_model.hpp +++ b/modules/gui/qt/player/control_list_model.hpp @@ -75,6 +75,7 @@ public: REVERSE_BUTTON, BOOKMARK_BUTTON, RENDERER_BUTTON, + NAVIGATION_BUTTONS, SPECIAL_MAX, WIDGET_SPACER = 0x40, diff --git a/modules/gui/qt/player/qml/controlbarcontrols/NavigationWidget.qml b/modules/gui/qt/player/qml/controlbarcontrols/NavigationWidget.qml new file mode 100644 index 0000000000..c4ac0e0f3e --- /dev/null +++ b/modules/gui/qt/player/qml/controlbarcontrols/NavigationWidget.qml @@ -0,0 +1,114 @@ +/***************************************************************************** + * Copyright (C) 2022 VLC authors and VideoLAN + * + * Authors: Benjamin Arnaud + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * ( at your option ) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +import QtQuick 2.11 +import QtQuick.Templates 2.4 as Templates + +import org.videolan.vlc 0.1 + +import "qrc:///widgets/" as Widgets +import "qrc:///style/" + +Templates.Pane { + id: root + + // Properties + + property int size: VLCStyle.icon_medium + + property VLCColors colors: VLCStyle.colors + + property bool paintOnly: false + + // Private + + readonly property string _controlPath : "qrc:///player/controlbarcontrols/" + + // Settings + + implicitWidth: contentWidth + leftPadding + rightPadding + implicitHeight: contentHeight + topPadding + bottomPadding + + contentWidth: row.implicitWidth + contentHeight: row.implicitHeight + + // Keys + + Keys.priority: Keys.AfterItem + Keys.onPressed: Navigation.defaultKeyAction(event) + + // Functions private + + function _applyItem(loader, item) { + item.focus = true + + item.colors = Qt.binding(function() { return colors }) + item.paintOnly = Qt.binding(function() { return paintOnly }) + + item.Navigation.parentItem = Qt.binding(function() { return loader }) + } + + // Children + + Row { + id: row + + anchors.fill: parent + + Loader { + id: loaderA + + anchors.verticalCenter: parent.verticalCenter + + focus: (item && item.enabled) + + // NOTE: We display the 'menu button' as a placeholder for the customize dialog. + source: (Player.hasMenu || root.paintOnly) ? _controlPath + "DvdMenuButton.qml" : "" + + Navigation.parentItem: root + Navigation.rightItem: loaderB.item + + onLoaded: { + if (item === null) return + + _applyItem(loaderA, item) + + item.size = Qt.binding(function() { return root.size }) + } + } + + Loader { + id: loaderB + + anchors.verticalCenter: parent.verticalCenter + + focus: (item && item.enabled && loaderA.focus === false) + + source: (Player.isTeletextAvailable + && + root.paintOnly == false) ? _controlPath + "TeletextWidget.qml" : "" + + Navigation.parentItem: root + Navigation.leftItem: loaderA.item + + onLoaded: if (item) _applyItem(loaderB, item) + } + } +} diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc index 1fefb47483..b6ef758ea3 100644 --- a/modules/gui/qt/vlc.qrc +++ b/modules/gui/qt/vlc.qrc @@ -373,6 +373,7 @@ player/qml/controlbarcontrols/LangButton.qml player/qml/controlbarcontrols/LoopButton.qml player/qml/controlbarcontrols/MenuButton.qml + player/qml/controlbarcontrols/NavigationWidget.qml player/qml/controlbarcontrols/NextButton.qml player/qml/controlbarcontrols/OpenButton.qml player/qml/controlbarcontrols/PlaybackSpeedButton.qml