[vlc-devel] [PATCH] qml: Create topBar for player

rohan17089 at iiitd.ac.in rohan17089 at iiitd.ac.in
Fri Jul 12 12:38:28 CEST 2019


From: Rohan Rajpal <rohan17089 at iiitd.ac.in>

Move non-customizable buttons to the top
of the player
---
 modules/gui/qt/Makefile.am                    |  1 +
 .../qt/components/playercontrolbarmodel.cpp   |  2 +-
 .../qt/components/playercontrolbarmodel.hpp   | 83 +++++++---------
 modules/gui/qt/qml/player/ControlBar.qml      |  1 +
 modules/gui/qt/qml/player/ControlButtons.qml  | 95 +++++++++----------
 modules/gui/qt/qml/player/Player.qml          | 40 ++++++--
 modules/gui/qt/qml/player/TopBar.qml          | 84 ++++++++++++++++
 modules/gui/qt/vlc.qrc                        |  1 +
 8 files changed, 201 insertions(+), 106 deletions(-)
 create mode 100644 modules/gui/qt/qml/player/TopBar.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index e8673b327d..49344f4629 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -543,6 +543,7 @@ libqt_plugin_la_QML = \
 	gui/qt/qml/player/ModalControlBar.qml \
 	gui/qt/qml/player/SliderBar.qml \
 	gui/qt/qml/player/TeletextWidget.qml \
+	gui/qt/qml/player/TopBar.qml \
 	gui/qt/qml/dialogs/Dialogs.qml \
 	gui/qt/qml/dialogs/ModalDialog.qml \
 	gui/qt/qml/utils/DNDLabel.qml \
diff --git a/modules/gui/qt/components/playercontrolbarmodel.cpp b/modules/gui/qt/components/playercontrolbarmodel.cpp
index 2fd1df9682..101507d0c6 100644
--- a/modules/gui/qt/components/playercontrolbarmodel.cpp
+++ b/modules/gui/qt/components/playercontrolbarmodel.cpp
@@ -20,7 +20,7 @@
 #include "qt.hpp"
 #include "playercontrolbarmodel.hpp"
 
-#define MAIN_TB1_DEFAULT "67;68;37;65;19;22;0-2;23;20;65;35;7"
+#define MAIN_TB1_DEFAULT "20;65;17;3;0-2;4;18;65;7"
 
 PlayerControlBarModel::PlayerControlBarModel(QObject *_parent) : QAbstractListModel(_parent)
 {
diff --git a/modules/gui/qt/components/playercontrolbarmodel.hpp b/modules/gui/qt/components/playercontrolbarmodel.hpp
index f10f29ce0e..23320d0c46 100644
--- a/modules/gui/qt/components/playercontrolbarmodel.hpp
+++ b/modules/gui/qt/components/playercontrolbarmodel.hpp
@@ -42,55 +42,40 @@ public:
     };
     enum ButtonType_e
     {
-
-        PLAY_BUTTON,            //0
-        STOP_BUTTON,            //1
-        OPEN_BUTTON,            //2
-        PREV_SLOW_BUTTON,       //3
-        NEXT_FAST_BUTTON,       //4
-        SLOWER_BUTTON,          //5
-        FASTER_BUTTON,          //6
-        FULLSCREEN_BUTTON,      //7
-        DEFULLSCREEN_BUTTON,    //8
-        EXTENDED_BUTTON,        //9
-        PLAYLIST_BUTTON,        //10
-        SNAPSHOT_BUTTON,        //11
-        RECORD_BUTTON,          //12
-        ATOB_BUTTON,            //13
-        FRAME_BUTTON,           //14
-        REVERSE_BUTTON,         //15
-        SKIP_BACK_BUTTON,       //16
-        SKIP_FW_BUTTON,         //17
-        QUIT_BUTTON,            //18
-        RANDOM_BUTTON,          //19
-        LOOP_BUTTON,            //20
-        INFO_BUTTON,            //21
-        PREVIOUS_BUTTON,        //22
-        NEXT_BUTTON,            //23
-        OPEN_SUB_BUTTON,        //24
-        FULLWIDTH_BUTTON,       //25
-        BUTTON_MAX,             //26
-
-        SPLITTER = 0x20,        //32
-        INPUT_SLIDER,           //33
-        TIME_LABEL,             //34
-        VOLUME,                 //35
-        VOLUME_SPECIAL,         //36
-        MENU_BUTTONS,           //37
-        TELETEXT_BUTTONS,       //38
-        ADVANCED_CONTROLLER,    //39
-        PLAYBACK_BUTTONS,       //40
-        ASPECT_RATIO_COMBOBOX,  //41
-        SPEED_LABEL,            //42
-        TIME_LABEL_ELAPSED,     //43
-        TIME_LABEL_REMAINING,   //44
-        SPECIAL_MAX,            //45
-
-        WIDGET_SPACER = 0x40,   //64
-        WIDGET_SPACER_EXTEND,   //65
-        WIDGET_MAX,             //66
-        GOBACK_BUTTON,          //67
-        LANG_BUTTON             //68
+        PLAY_BUTTON,
+        STOP_BUTTON,
+        OPEN_BUTTON,
+        PREVIOUS_BUTTON,
+        NEXT_BUTTON,
+        SLOWER_BUTTON,
+        FASTER_BUTTON,
+        FULLSCREEN_BUTTON,
+        EXTENDED_BUTTON,
+        PLAYLIST_BUTTON,
+        SNAPSHOT_BUTTON,
+        RECORD_BUTTON,
+        ATOB_BUTTON,
+        FRAME_BUTTON,
+        SKIP_BACK_BUTTON,
+        SKIP_FW_BUTTON,
+        QUIT_BUTTON,
+        RANDOM_BUTTON,
+        LOOP_BUTTON,
+        INFO_BUTTON,
+        LANG_BUTTON,
+        MENU_BUTTON,
+        BACK_BUTTON,
+        BUTTON_MAX,
+
+        SPLITTER = 0x20,
+        VOLUME,
+        TELETEXT_BUTTONS,
+        ASPECT_RATIO_COMBOBOX,
+        SPECIAL_MAX,
+
+        WIDGET_SPACER = 0x40,
+        WIDGET_SPACER_EXTEND,
+        WIDGET_MAX
     };
     Q_ENUM(ButtonType_e)
 
diff --git a/modules/gui/qt/qml/player/ControlBar.qml b/modules/gui/qt/qml/player/ControlBar.qml
index 9fd47d6823..f427122eb5 100644
--- a/modules/gui/qt/qml/player/ControlBar.qml
+++ b/modules/gui/qt/qml/player/ControlBar.qml
@@ -53,6 +53,7 @@ Utils.NavigableFocusScope {
             Layout.fillWidth: true
             enabled: player.playingState == PlayerController.PLAYING_STATE_PLAYING || player.playingState == PlayerController.PLAYING_STATE_PAUSED
             Keys.onDownPressed: buttons.focus = true
+            KeyNavigation.up: topcontrolView.contentItem
         }
 
         Utils.NavigableFocusScope {
diff --git a/modules/gui/qt/qml/player/ControlButtons.qml b/modules/gui/qt/qml/player/ControlButtons.qml
index 8fe7424f40..df22fbb2d8 100644
--- a/modules/gui/qt/qml/player/ControlButtons.qml
+++ b/modules/gui/qt/qml/player/ControlButtons.qml
@@ -36,9 +36,7 @@ Item{
         case PlayerControlBarModel.NEXT_BUTTON: return nextBtnDelegate
         case PlayerControlBarModel.LOOP_BUTTON: return repeatBtnDelegate
         case PlayerControlBarModel.LANG_BUTTON: return langBtnDelegate
-        case PlayerControlBarModel.PLAYLIST_BUTTON:return playlistBtnDelegate
-        case PlayerControlBarModel.MENU_BUTTONS:return  menuBtnDelegate
-        case PlayerControlBarModel.GOBACK_BUTTON:return  backBtnDelegate
+        case PlayerControlBarModel.MENU_BUTTON:return  menuBtnDelegate
         case PlayerControlBarModel.WIDGET_SPACER:return  spacerDelegate
         case PlayerControlBarModel.WIDGET_SPACER_EXTEND:return  extendiblespacerDelegate
         case PlayerControlBarModel.RECORD_BUTTON: return recordBtnDelegate
@@ -49,12 +47,14 @@ Item{
         case PlayerControlBarModel.INFO_BUTTON: return mediainfoBtnDelegate
         case PlayerControlBarModel.FRAME_BUTTON: return framebyframeDelegate
         case PlayerControlBarModel.FASTER_BUTTON: return fasterBtnDelegate
+        case PlayerControlBarModel.PLAYLIST_BUTTON:return playlistBtnDelegate
         case PlayerControlBarModel.SLOWER_BUTTON: return slowerBtnDelegate
         case PlayerControlBarModel.OPEN_BUTTON: return openmediaBtnDelegate
         case PlayerControlBarModel.EXTENDED_BUTTON: return extdSettingsBtnDelegate
         case PlayerControlBarModel.SKIP_FW_BUTTON: return stepFwdBtnDelegate
         case PlayerControlBarModel.SKIP_BACK_BUTTON: return stepBackBtnDelegate
         case PlayerControlBarModel.QUIT_BUTTON: return quitBtnDelegate
+        case PlayerControlBarModel.BACK_BUTTON:return  backBtnDelegate
         case PlayerControlBarModel.VOLUME: return volumeBtnDelegate
         case PlayerControlBarModel.ASPECT_RATIO_COMBOBOX: return aspectRatioDelegate
         case PlayerControlBarModel.TELETEXT_BUTTONS: return teletextdelegate
@@ -63,33 +63,68 @@ Item{
         return spacerDelegate
     }
 
+    Component{
+        id: randomBtnDelegate
+        Utils.IconToolButton {
+            id: randomBtn
+            objectName: "IconToolButton"
+            size: VLCStyle.icon_medium
+            checked: mainPlaylistController.random
+            text: VLCIcons.shuffle_on
+            onClicked: mainPlaylistController.toggleRandom()
+            property bool acceptFocus: true
+        }
+    }
+
     Component{
         id: backBtnDelegate
         Utils.IconToolButton {
             id: backBtn
             objectName: "IconToolButton"
-            anchors.left: parent.left
-            anchors.verticalCenter: parent.verticalCenter
-            size: VLCStyle.icon_medium
+            size: VLCStyle.icon_normal
             text: VLCIcons.exit
             onClicked: mainPlaylistController.stop()
+            focus: true
             property bool acceptFocus: true
         }
     }
 
     Component{
-        id: randomBtnDelegate
+        id: menuBtnDelegate
         Utils.IconToolButton {
-            id: randomBtn
+            id: menuBtn
             objectName: "IconToolButton"
             size: VLCStyle.icon_medium
-            checked: mainPlaylistController.random
-            text: VLCIcons.shuffle_on
-            onClicked: mainPlaylistController.toggleRandom()
+            text: VLCIcons.menu
+            onClicked: {
+                root._lockAutoHide += 1
+                mainMenu.openAbove(this)
+            }
+            property alias mainMenuExt: mainMenu
+            Menus.MainDropdownMenu {
+                id: mainMenu
+                onClosed: {
+                    root._lockAutoHide -= 1
+                    menuBtn.forceActiveFocus()
+                }
+            }
             property bool acceptFocus: true
         }
     }
 
+    Component{
+        id:playlistBtnDelegate
+        Utils.IconToolButton {
+            id: playlistBtn
+            objectName: "IconToolButton"
+            size: VLCStyle.icon_medium
+            text: VLCIcons.playlist
+            onClicked:  showPlaylist()
+            property bool acceptFocus: true
+        }
+
+    }
+
     Component{
         id: prevBtnDelegate
         Utils.IconToolButton {
@@ -156,43 +191,6 @@ Item{
         }
     }
 
-    Component{
-        id:playlistBtnDelegate
-        Utils.IconToolButton {
-            id: playlistBtn
-            objectName: "IconToolButton"
-            visible: showPlaylistButton
-            size: VLCStyle.icon_medium
-            text: VLCIcons.playlist
-            onClicked: root.showPlaylist()
-            property bool acceptFocus: true
-        }
-
-    }
-
-    Component{
-        id: menuBtnDelegate
-        Utils.IconToolButton {
-            id: menuBtn
-            objectName: "IconToolButton"
-            size: VLCStyle.icon_medium
-            text: VLCIcons.menu
-            onClicked: {
-                root._lockAutoHide += 1
-                mainMenu.openAbove(this)
-            }
-            property alias mainMenuExt: mainMenu
-            Menus.MainDropdownMenu {
-                id: mainMenu
-                onClosed: {
-                    root._lockAutoHide -= 1
-                    menuBtn.forceActiveFocus()
-                }
-            }
-            property bool acceptFocus: true
-        }
-    }
-
     Component{
         id:spacerDelegate
         Item {
@@ -395,7 +393,6 @@ Item{
     Component{
         id: aspectRatioDelegate
         Utils.ComboBoxExt {
-            id: combo
             property bool acceptFocus: true
             Layout.alignment: Qt.AlignVCenter
             height: 28 * scale
diff --git a/modules/gui/qt/qml/player/Player.qml b/modules/gui/qt/qml/player/Player.qml
index 7beb818947..977823ee79 100644
--- a/modules/gui/qt/qml/player/Player.qml
+++ b/modules/gui/qt/qml/player/Player.qml
@@ -116,10 +116,27 @@ Utils.NavigableFocusScope {
         }
     }
 
+    Utils.Drawer{
+        id: topcontrolView
+        anchors{
+            left: parent.left
+            right: parent.right
+            top: parent.top
+        }
+        property var noAutoHide: topcontrolView.contentItem.noAutoHide
+
+        state: "visible"
+
+        expandHorizontally: false
+
+        component: TopBar{}
+
+    }
+
     Utils.Drawer {
         id: playlistpopup
         anchors {
-            top: parent.top
+            top: topcontrolView.bottom
             right: parent.right
             bottom: controlBarView.top
         }
@@ -157,7 +174,6 @@ Utils.NavigableFocusScope {
         }
     }
 
-
     Utils.Drawer {
         id: controlBarView
         focus: true
@@ -178,7 +194,6 @@ Utils.NavigableFocusScope {
             height: 90 * VLCStyle.scale
             property alias noAutoHide: controllerId.noAutoHide
 
-
             MouseArea {
                 id: controllerMouseArea
                 hoverEnabled: true
@@ -224,10 +239,21 @@ Utils.NavigableFocusScope {
         repeat: false
         interval: 3000
         onTriggered: {
-            _setVisible(false)
+            _setVisibleControlBar(false)
+            _setVisibleTopView(false)
+        }
+
+        function _setVisibleTopView(visible) {
+            if(visible)
+                topcontrolView.state = "visible"
+            else{
+                if (topcontrolView.noAutoHide)
+                    return;
+                topcontrolView.state = "hidden"
+            }
         }
 
-        function _setVisible(visible) {
+        function _setVisibleControlBar(visible) {
             if (visible)
             {
                 controlBarView.state = "visible"
@@ -245,13 +271,13 @@ Utils.NavigableFocusScope {
         }
 
         function setVisible(duration) {
-            _setVisible(true)
+            _setVisibleControlBar(true)
             toolbarAutoHide.interval = duration
             toolbarAutoHide.restart()
         }
 
         function toggleForceVisible() {
-            _setVisible(controlBarView.state !== "visible")
+            _setVisibleControlBar(controlBarView.state !== "visible")
             toolbarAutoHide.stop()
         }
     }
diff --git a/modules/gui/qt/qml/player/TopBar.qml b/modules/gui/qt/qml/player/TopBar.qml
new file mode 100644
index 0000000000..b9b75b8d1c
--- /dev/null
+++ b/modules/gui/qt/qml/player/TopBar.qml
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * 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.Layouts 1.3
+
+import org.videolan.vlc 0.1
+
+import "qrc:///style/"
+import "qrc:///utils/" as Utils
+
+Utils.NavigableFocusScope{
+    id: topFocusScope
+    width: topcontrolContent.width
+    height: topcontrolContent.height
+
+    property bool noAutoHide: playlistpopup.state === "visible"
+                              || !player.hasVideoOutput
+                              || !rootWindow.hasEmbededVideo
+                              || topcontrollerMouseArea.containsMouse || lockAutoHide
+    property bool lockAutoHide: false
+    onNoAutoHideChanged: {
+        if (!noAutoHide)
+            toolbarAutoHide.restart()
+    }
+    Rectangle{
+        id : topcontrolContent
+        color: VLCStyle.colors.setColorAlpha(VLCStyle.colors.banner, 0.8)
+        width: topcontrolView.width
+        height: 32 * VLCStyle.scale
+
+        MouseArea {
+            id: topcontrollerMouseArea
+            hoverEnabled: true
+            anchors.fill: parent
+
+            RowLayout{
+                anchors.fill: parent
+                Utils.IconToolButton {
+                    id: backBtn
+                    objectName: "IconToolButton"
+                    Layout.leftMargin: 5
+                    size: VLCStyle.icon_normal
+                    text: VLCIcons.exit
+                    onClicked: mainPlaylistController.stop()
+                    KeyNavigation.right: playlistBtn
+                    focus: true
+                }
+                Item{
+                    Layout.fillWidth: true
+                }
+
+                Utils.IconToolButton {
+                    id: playlistBtn
+                    objectName: PlayerControlBarModel.PLAYLIST_BUTTON
+                    size: VLCStyle.icon_normal
+                    text: VLCIcons.playlist
+                    onClicked: if (playlistpopup.state === "visible") {
+                                   playlistpopup.state = "hidden"
+                               } else {
+                                   playlistpopup.state = "visible"
+                                   playlistpopup.focus = true
+                               }
+                    property bool acceptFocus: true
+                }
+            }
+        }
+    }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index cb5cbcc926..9ea6f50f83 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -254,6 +254,7 @@
         <file alias="ControlButtons.qml">qml/player/ControlButtons.qml</file>
         <file alias="VolumeWidget.qml">qml/player/VolumeWidget.qml</file>
         <file alias="TeletextWidget.qml">qml/player/TeletextWidget.qml</file>
+        <file alias="TopBar.qml">qml/player/TopBar.qml</file>
     </qresource>
     <qresource prefix="/about">
         <file alias="About.qml">qml/about/About.qml</file>
-- 
2.17.1



More information about the vlc-devel mailing list