[vlc-devel] [PATCH 05/15] qml: Make DND view for Editor

Rohan Rajpal rohan17089 at iiitd.ac.in
Mon Aug 12 15:24:19 CEST 2019


Separate DND view from editor into a file.
---
 modules/gui/qt/Makefile.am                   |  1 +
 modules/gui/qt/qml/dialogs/EditorDNDView.qml | 95 ++++++++++++++++++++
 modules/gui/qt/vlc.qrc                       |  1 +
 3 files changed, 97 insertions(+)
 create mode 100644 modules/gui/qt/qml/dialogs/EditorDNDView.qml

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 75c310a9ed..1b543eac8e 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -564,6 +564,7 @@ libqt_plugin_la_QML = \
 	gui/qt/qml/dialogs/ModalDialog.qml \
 	gui/qt/qml/dialogs/EditorDummyButton.qml \
 	gui/qt/qml/dialogs/EditorDNDDelegate.qml \
+	gui/qt/qml/dialogs/EditorDNDView.qml\
 	gui/qt/qml/dialogs/ToolbarEditorButtonList.qml \
 	gui/qt/qml/dialogs/ToolbarEditor.qml \
 	gui/qt/qml/utils/DNDLabel.qml \
diff --git a/modules/gui/qt/qml/dialogs/EditorDNDView.qml b/modules/gui/qt/qml/dialogs/EditorDNDView.qml
new file mode 100644
index 0000000000..ed34f2fc16
--- /dev/null
+++ b/modules/gui/qt/qml/dialogs/EditorDNDView.qml
@@ -0,0 +1,95 @@
+/*****************************************************************************
+ * 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 QtQml.Models 2.11
+
+import org.videolan.vlc 0.1
+
+import "qrc:///style/"
+
+ListView {
+    id: playerBtnDND
+    spacing: VLCStyle.margin_xxsmall
+    orientation: Qt.Horizontal
+    clip: true
+    property bool deleteBtn: false
+    property bool addBtn: false
+    onDeleteBtnChanged: {
+        if(deleteBtn)
+            toolbareditor.deleteCursor()
+        else
+            toolbareditor.restoreCursor()
+    }
+
+    ScrollBar.horizontal: ScrollBar {}
+
+    footer: Item {
+        height: VLCStyle.icon_medium
+        width: height
+        anchors.verticalCenter: parent.verticalCenter
+        property bool dropVisible: false
+        Rectangle {
+            z: 2
+            width: 2 * scale
+            height: parent.height
+            anchors {
+                left: parent.left
+            }
+            antialiasing: true
+            visible: dropVisible
+            color: VLCStyle.colors.accent
+        }
+        DropArea {
+            anchors.fill: parent
+
+            onEntered: {
+                dropVisible = true
+                playerBtnDND.deleteBtn = false
+            }
+
+            onExited: {
+                dropVisible = false
+                playerBtnDND.deleteBtn = true
+            }
+
+            onDropped: {
+                if (drag.source.objectName == "buttonsList"){
+                    playerBtnDND.model.insert(playerBtnDND.count,
+                                             {"id" : drag.source.mIndex,
+                                                 "size": bigButton.checked ?
+                                                             PlayerControlBarModel.WIDGET_BIG :
+                                                             PlayerControlBarModel.WIDGET_NORMAL})
+                }
+                else
+                    playerBtnDND.model.move(
+                                drag.source.DelegateModel.itemsIndex,
+                                playerBtnDND.count-1)
+                dropVisible = false
+            }
+        }
+
+    }
+
+    delegate: EditorDNDDelegate {
+        dndView: playerBtnDND
+    }
+    displaced: Transition {
+        NumberAnimation { properties: "x,y"; easing.type: Easing.OutQuad }
+    }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 2d9839e0b1..cd51446389 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -269,5 +269,6 @@
         <file alias="EditorDNDDelegate.qml">qml/dialogs/EditorDNDDelegate.qml</file>
         <file alias="ToolbarEditorButtonList.qml">qml/dialogs/ToolbarEditorButtonList.qml</file>
         <file alias="ToolbarEditor.qml">qml/dialogs/ToolbarEditor.qml</file>
+        <file alias="EditorDNDView.qml">qml/dialogs/EditorDNDView.qml</file>
     </qresource>
 </RCC>
-- 
2.17.1



More information about the vlc-devel mailing list