[vlc-devel] [RFC 68/82] qml: provide custom "Drawer" component, usable with key navigation

Pierre Lamot pierre at videolabs.io
Fri Feb 1 14:02:12 CET 2019


---
 modules/gui/qt/Makefile.am          |  1 +
 modules/gui/qt/qml/utils/Drawer.qml | 80 +++++++++++++++++++++++++++++
 modules/gui/qt/vlc.qrc              |  1 +
 3 files changed, 82 insertions(+)
 create mode 100644 modules/gui/qt/qml/utils/Drawer.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 0e8124c19a..1c58dae8d1 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -524,6 +524,7 @@ libqt_plugin_la_RES = \
 	gui/qt/pixmaps/lock.svg \
 	gui/qt/qml/utils/DNDLabel.qml \
 	gui/qt/qml/utils/ToolTipArea.qml \
+	gui/qt/qml/utils/Drawer.qml \
 	gui/qt/qml/utils/ExpandGridView.qml \
 	gui/qt/qml/utils/GridItem.qml \
 	gui/qt/qml/utils/IconToolButton.qml \
diff --git a/modules/gui/qt/qml/utils/Drawer.qml b/modules/gui/qt/qml/utils/Drawer.qml
new file mode 100644
index 0000000000..5ed467be87
--- /dev/null
+++ b/modules/gui/qt/qml/utils/Drawer.qml
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * 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
+
+NavigableFocusScope {
+    id: root
+
+    property Component component: undefined
+
+    //readonly property int horizontal: 0
+    //readonly property int vertical: 1
+
+    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
+
+    Flickable {
+        anchors.fill: parent
+        Loader {
+            focus: true
+            id: content
+            sourceComponent: root.component
+        }
+    }
+
+    state: "hidden"
+    states: [
+        State {
+            name: "visible"
+            PropertyChanges {
+                target: root
+                _size: (root.expandHorizontally) ?  content.item.width : content.item.height
+                visible: true
+            }
+        },
+        State {
+            name: "hidden"
+            PropertyChanges {
+                target: root
+                _size: 0
+                visible: false
+            }
+        }
+    ]
+    transitions: [
+        Transition {
+            to: "hidden"
+            SequentialAnimation {
+                NumberAnimation { target: root; property: "_size"; duration: 200 }
+                PropertyAction{ target: root; property: "visible" }
+            }
+        },
+        Transition {
+            to: "visible"
+            SequentialAnimation {
+                PropertyAction{ target: root; property: "visible" }
+                NumberAnimation { target: root; property: "_size"; duration: 200 }
+            }
+        }
+    ]
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 1a12e86b13..183d52e8a5 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -162,6 +162,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="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.19.1



More information about the vlc-devel mailing list