[vlc-commits] qml: Make DND view for Editor

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


vlc | branch: master | Rohan Rajpal <rohan17089 at iiitd.ac.in> | Sat Aug  3 16:00:34 2019 +0530| [1ffaae6d14a3b7944cc6be52b05bcfd564c7902e] | committer: Jean-Baptiste Kempf

qml: Make DND view for Editor

Separate DND view from editor into a file.

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

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

 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(+)

diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 4a97fb661e..9a9b8ca412 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -570,6 +570,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 d87f0bbd23..74037963ba 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -278,5 +278,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>



More information about the vlc-commits mailing list