[vlc-devel] [PATCH 1/3] qml: Utils Drawer changes

Rohan Rajpal rohan17089 at iiitd.ac.in
Fri Jul 19 13:46:45 CEST 2019


-Add animation support if you
 anchor the drawer anywhere
-Change name to support enum
---
 modules/gui/qt/Makefile.am                    |  2 +-
 modules/gui/qt/qml/dialogs/Dialogs.qml        |  4 +-
 .../gui/qt/qml/mediacenter/MCMainDisplay.qml  |  4 +-
 modules/gui/qt/qml/player/Player.qml          |  8 +--
 .../qml/utils/{Drawer.qml => DrawerExt.qml}   | 52 +++++++++++++------
 modules/gui/qt/vlc.qrc                        |  2 +-
 6 files changed, 46 insertions(+), 26 deletions(-)
 rename modules/gui/qt/qml/utils/{Drawer.qml => DrawerExt.qml} (55%)

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 0e41ca2ddf..d8e311ac72 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -550,7 +550,7 @@ libqt_plugin_la_QML = \
 	gui/qt/qml/dialogs/ModalDialog.qml \
 	gui/qt/qml/utils/DNDLabel.qml \
 	gui/qt/qml/utils/ToolTipArea.qml \
-	gui/qt/qml/utils/Drawer.qml \
+	gui/qt/qml/utils/DrawerExt.qml \
 	gui/qt/qml/utils/GridItem.qml \
 	gui/qt/qml/utils/IconToolButton.qml \
 	gui/qt/qml/utils/ImageToolButton.qml \
diff --git a/modules/gui/qt/qml/dialogs/Dialogs.qml b/modules/gui/qt/qml/dialogs/Dialogs.qml
index 5f207058f6..275bed370d 100644
--- a/modules/gui/qt/qml/dialogs/Dialogs.qml
+++ b/modules/gui/qt/qml/dialogs/Dialogs.qml
@@ -30,13 +30,13 @@ Item {
     signal restoreFocus();
     property var bgContent: undefined
 
-    Utils.Drawer {
+    Utils.DrawerExt {
         id: errorPopup
         anchors {
             bottom: parent.bottom
             horizontalCenter: parent.horizontalCenter
         }
-        expandHorizontally: false
+        edge: Utils.DrawerExt.Edges.Bottom
         width: parent.width * 0.8
         z: 10
 
diff --git a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
index e5ee8a6651..a3ba5470d1 100644
--- a/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
+++ b/modules/gui/qt/qml/mediacenter/MCMainDisplay.qml
@@ -191,7 +191,7 @@ Utils.NavigableFocusScope {
                                 })
                         }
 
-                        Utils.Drawer {
+                        Utils.DrawerExt {
                             z: 1
                             id: playlist
                             anchors {
@@ -200,7 +200,7 @@ Utils.NavigableFocusScope {
                                 bottom: parent.bottom
                             }
                             focus: false
-                            expandHorizontally: true
+                            edge: Utils.DrawerExt.Edges.Top
 
                             state: (rootWindow.playlistDocked && rootWindow.playlistVisible) ? "visible" : "hidden"
                             onVisibleChanged: {
diff --git a/modules/gui/qt/qml/player/Player.qml b/modules/gui/qt/qml/player/Player.qml
index 83eb46e98f..0a5e749ddb 100644
--- a/modules/gui/qt/qml/player/Player.qml
+++ b/modules/gui/qt/qml/player/Player.qml
@@ -116,7 +116,7 @@ Utils.NavigableFocusScope {
         }
     }
 
-    Utils.Drawer {
+    Utils.DrawerExt {
         id: playlistpopup
         anchors {
             top: parent.top
@@ -124,7 +124,7 @@ Utils.NavigableFocusScope {
             bottom: controlBarView.top
         }
         focus: false
-        expandHorizontally: true
+        edge: Utils.DrawerExt.Edges.Right
         state: (rootWindow.playlistDocked && rootWindow.playlistVisible) ? "visible" : "hidden"
         onVisibleChanged: {
             if (playlistpopup.visible)
@@ -158,7 +158,7 @@ Utils.NavigableFocusScope {
     }
 
 
-    Utils.Drawer {
+    Utils.DrawerExt {
         id: controlBarView
         focus: true
         anchors {
@@ -169,7 +169,7 @@ Utils.NavigableFocusScope {
         property var  noAutoHide: controlBarView.contentItem.noAutoHide
 
         state: "visible"
-        expandHorizontally: false
+        edge: Utils.DrawerExt.Edges.Bottom
 
         component: Rectangle {
             id: controllerBarId
diff --git a/modules/gui/qt/qml/utils/Drawer.qml b/modules/gui/qt/qml/utils/DrawerExt.qml
similarity index 55%
rename from modules/gui/qt/qml/utils/Drawer.qml
rename to modules/gui/qt/qml/utils/DrawerExt.qml
index 5ed467be87..0f3cbac93c 100644
--- a/modules/gui/qt/qml/utils/Drawer.qml
+++ b/modules/gui/qt/qml/utils/DrawerExt.qml
@@ -23,17 +23,25 @@ NavigableFocusScope {
 
     property Component component: undefined
 
-    //readonly property int horizontal: 0
-    //readonly property int vertical: 1
+    enum Edges{
+        Top,
+        Bottom,
+        Left,
+        Right
+    }
+    property int edge: DrawerExt.Edges.Bottom
+    property bool expandHorizontally: edge === DrawerExt.Edges.Left || edge === DrawerExt.Edges.Right
+
+    property alias contentItem: content.item
 
-    property bool expandHorizontally: true
     width:  (root.expandHorizontally) ? root._size : undefined
     height: (!root.expandHorizontally) ? root._size : undefined
-    property int _size: 0
 
-    property alias contentItem: content.item
+    property int _size: (root.expandHorizontally) ?  content.item.width : content.item.height
+    property string toChange: expandHorizontally ? "contentX" : "contentY"
 
     Flickable {
+        id: container
         anchors.fill: parent
         Loader {
             focus: true
@@ -46,18 +54,30 @@ NavigableFocusScope {
     states: [
         State {
             name: "visible"
-            PropertyChanges {
-                target: root
-                _size: (root.expandHorizontally) ?  content.item.width : content.item.height
+            PropertyChanges{
+                target: container
+                contentY: 0
+                contentX: 0
                 visible: true
             }
         },
         State {
             name: "hidden"
-            PropertyChanges {
-                target: root
-                _size: 0
-                visible: false
+            PropertyChanges{
+                target: container
+                contentY: if(edge === DrawerExt.Edges.Top)
+                              _size
+                          else if (edge === DrawerExt.Edges.Bottom)
+                              -_size
+                          else
+                              0
+                contentX: if(edge === DrawerExt.Edges.Left)
+                              _size
+                          else if (edge === DrawerExt.Edges.Right)
+                              -_size
+                          else
+                              0
+                visible:false
             }
         }
     ]
@@ -65,15 +85,15 @@ NavigableFocusScope {
         Transition {
             to: "hidden"
             SequentialAnimation {
-                NumberAnimation { target: root; property: "_size"; duration: 200 }
-                PropertyAction{ target: root; property: "visible" }
+                NumberAnimation { target: container; property: toChange; duration: 200}
+                PropertyAction{ target: container; property: "visible" }
             }
         },
         Transition {
             to: "visible"
             SequentialAnimation {
-                PropertyAction{ target: root; property: "visible" }
-                NumberAnimation { target: root; property: "_size"; duration: 200 }
+                PropertyAction{ target: container; property: "visible" }
+                NumberAnimation { target: container; property: toChange; duration: 200 }
             }
         }
     ]
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 6ed9849c70..17cc661998 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -178,7 +178,7 @@
         <file alias="MultiCoverPreview.qml">qml/utils/MultiCoverPreview.qml</file>
         <file alias="GridItem.qml">qml/utils/GridItem.qml</file>
         <file alias="ListItem.qml">qml/utils/ListItem.qml</file>
-        <file alias="Drawer.qml">qml/utils/Drawer.qml</file>
+        <file alias="DrawerExt.qml">qml/utils/DrawerExt.qml</file>
         <file alias="SelectableDelegateModel.qml">qml/utils/SelectableDelegateModel.qml</file>
         <file alias="KeyNavigableGridView.qml">qml/utils/KeyNavigableGridView.qml</file>
         <file alias="KeyNavigableListView.qml">qml/utils/KeyNavigableListView.qml</file>
-- 
2.17.1



More information about the vlc-devel mailing list