[vlc-commits] qml: Move player buttons layout to another qml

Rohan Rajpal git at videolan.org
Wed Aug 21 16:26:56 CEST 2019


vlc | branch: master | Rohan Rajpal <rohan17089 at iiitd.ac.in> | Sat Aug  3 16:28:53 2019 +0530| [056dd332ca90228f772df5d859fa531b5c72121e] | committer: Jean-Baptiste Kempf

qml: Move player buttons layout to another qml

Move player buttons layout to another qml file to use it in
future by miniplayer.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=056dd332ca90228f772df5d859fa531b5c72121e
---

 modules/gui/qt/Makefile.am                        |  1 +
 modules/gui/qt/qml/player/ControlBar.qml          | 34 +------------
 modules/gui/qt/qml/player/PlayerButtonsLayout.qml | 62 +++++++++++++++++++++++
 modules/gui/qt/vlc.qrc                            |  1 +
 4 files changed, 66 insertions(+), 32 deletions(-)

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index a79ba9c718..4a97fb661e 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -559,6 +559,7 @@ libqt_plugin_la_QML = \
 	gui/qt/qml/player/TrackSelector.qml \
 	gui/qt/qml/player/ControlBar.qml \
 	gui/qt/qml/player/ControlButtons.qml \
+	gui/qt/qml/player/PlayerButtonsLayout.qml \
 	gui/qt/qml/player/VolumeWidget.qml \
 	gui/qt/qml/player/ModalControlBar.qml \
 	gui/qt/qml/player/SliderBar.qml \
diff --git a/modules/gui/qt/qml/player/ControlBar.qml b/modules/gui/qt/qml/player/ControlBar.qml
index a02cde9e6c..e65dfac186 100644
--- a/modules/gui/qt/qml/player/ControlBar.qml
+++ b/modules/gui/qt/qml/player/ControlBar.qml
@@ -85,40 +85,10 @@ Utils.NavigableFocusScope {
                     color: "transparent"
                 }
 
-                RowLayout{
-                    id: buttonrow
-                    property bool _focusGiven: false
+                PlayerButtonsLayout {
                     focus: true
                     anchors.fill: parent
-                    Repeater{
-                        model: playerControlBarModel
-                        delegate: Loader{
-                            id: buttonloader
-
-                            sourceComponent: controlmodelbuttons.returnbuttondelegate(model.id)
-                            onLoaded: {
-                                if (! buttonloader.item.acceptFocus)
-                                    return
-                                else
-                                    if (!buttonrow._focusGiven){
-                                        buttonloader.item.forceActiveFocus()
-                                        buttonrow._focusGiven = true
-                                    }
-                                if(buttonloader.item instanceof Utils.IconToolButton)
-                                    buttonloader.item.size = model.size === PlayerControlBarModel.WIDGET_BIG ?
-                                                VLCStyle.icon_large : VLCStyle.icon_medium
-
-                                var buttonindex = DelegateModel.itemsIndex
-                                while(buttonindex > 0 && !(buttonrow.children[buttonindex-1].item.acceptFocus))
-                                    buttonindex = buttonindex-1
-
-                                if (buttonindex > 0)
-                                    buttonloader.item.KeyNavigation.left = buttonrow.children[buttonindex-1].item
-
-
-                            }
-                        }
-                    }
+                    model: playerControlBarModel
                 }
             }
         }
diff --git a/modules/gui/qt/qml/player/PlayerButtonsLayout.qml b/modules/gui/qt/qml/player/PlayerButtonsLayout.qml
new file mode 100644
index 0000000000..04f2a676f5
--- /dev/null
+++ b/modules/gui/qt/qml/player/PlayerButtonsLayout.qml
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * 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.Controls 2.4
+import QtQuick.Layouts 1.3
+import QtQml.Models 2.11
+
+import org.videolan.vlc 0.1
+
+import "qrc:///style/"
+import "qrc:///utils/" as Utils
+
+RowLayout{
+    id: buttonrow
+    property bool _focusGiven: false
+    property alias model: buttonsRepeater.model
+    property var defaultSize: VLCStyle.icon_medium
+
+    Repeater{
+        id: buttonsRepeater
+        delegate: Loader{
+            id: buttonloader
+
+            sourceComponent: controlmodelbuttons.returnbuttondelegate(model.id)
+            onLoaded: {
+                if (! buttonloader.item.acceptFocus)
+                    return
+                else
+                    if (!buttonrow._focusGiven){
+                        buttonloader.item.forceActiveFocus()
+                        buttonrow._focusGiven = true
+                    }
+                if(buttonloader.item instanceof Utils.IconToolButton)
+                    buttonloader.item.size = model.size === PlayerControlBarModel.WIDGET_BIG ?
+                                VLCStyle.icon_large : defaultSize
+
+                var buttonindex = DelegateModel.itemsIndex
+                while(buttonindex > 0 && !(buttonrow.children[buttonindex-1].item.acceptFocus))
+                    buttonindex = buttonindex-1
+
+                if (buttonindex > 0)
+                    buttonloader.item.KeyNavigation.left = buttonrow.children[buttonindex-1].item
+            }
+        }
+    }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 7c2ef849f3..d87f0bbd23 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -266,6 +266,7 @@
         <file alias="TeletextWidget.qml">qml/player/TeletextWidget.qml</file>
         <file alias="MiniPlayer.qml">qml/player/MiniPlayer.qml</file>
         <file alias="TopBar.qml">qml/player/TopBar.qml</file>
+        <file alias="PlayerButtonsLayout.qml">qml/player/PlayerButtonsLayout.qml</file>
     </qresource>
     <qresource prefix="/about">
         <file alias="About.qml">qml/about/About.qml</file>



More information about the vlc-commits mailing list