[vlc-devel] [PATCH 08/16] qml: Add Editor DND delegate
Rohan Rajpal
rohan17089 at iiitd.ac.in
Wed Jul 31 14:30:48 CEST 2019
Add the DND delegate for playercontrolbar buttons
---
modules/gui/qt/Makefile.am | 1 +
.../gui/qt/qml/dialogs/EditorDNDDelegate.qml | 124 ++++++++++++++++++
modules/gui/qt/vlc.qrc | 1 +
3 files changed, 126 insertions(+)
create mode 100644 modules/gui/qt/qml/dialogs/EditorDNDDelegate.qml
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index d049d80859..427c7533fc 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -560,6 +560,7 @@ libqt_plugin_la_QML = \
gui/qt/qml/dialogs/Dialogs.qml \
gui/qt/qml/dialogs/ModalDialog.qml \
gui/qt/qml/dialogs/EditorDummyButton.qml \
+ gui/qt/qml/dialogs/EditorDNDDelegate.qml \
gui/qt/qml/utils/DNDLabel.qml \
gui/qt/qml/utils/ToolTipArea.qml \
gui/qt/qml/utils/DrawerExt.qml \
diff --git a/modules/gui/qt/qml/dialogs/EditorDNDDelegate.qml b/modules/gui/qt/qml/dialogs/EditorDNDDelegate.qml
new file mode 100644
index 0000000000..675df13941
--- /dev/null
+++ b/modules/gui/qt/qml/dialogs/EditorDNDDelegate.qml
@@ -0,0 +1,124 @@
+/*****************************************************************************
+ * 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 QtQml.Models 2.11
+
+import org.videolan.vlc 0.1
+
+import "qrc:///utils/" as Utils
+import "qrc:///style/"
+
+MouseArea {
+ id: dragArea
+
+ property bool held: false
+ property bool dropVisible: false
+ anchors.verticalCenter: parent.verticalCenter
+ cursorShape: dropVisible ? Qt.DragMoveCursor : Qt.OpenHandCursor
+ drag.target: held ? content : undefined
+ width: buttonloader.width
+ height: VLCStyle.icon_medium
+
+ Rectangle {
+ z: 1
+ width: 2 * scale
+ height: parent.height
+ anchors {
+ left: parent.left
+ verticalCenter: parent.verticalCenter
+ }
+ antialiasing: true
+ visible: dropVisible
+ color: VLCStyle.colors.accent
+ }
+ onPressed: held = true
+
+ onExited: {
+ if(containsPress)
+ playerBtnDND.deleteBtn = true
+ }
+
+ onReleased: {
+ drag.target.Drag.drop()
+ held = false
+ if(playerBtnDND.deleteBtn){
+ playerBtnDND.deleteBtn = false
+ playerBtnDND.model.remove(
+ dragArea.DelegateModel.itemsIndex)
+ }
+ }
+
+ Rectangle {
+ id: content
+ Drag.active: dragArea.held
+ Drag.source: dragArea
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ Loader{
+ id: buttonloader
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+ sourceComponent: controlButtons.returnbuttondelegate(model.id)
+ onLoaded: buttonloader.item.paintOnly = true
+
+ }
+
+ states: State {
+ when: dragArea.held
+
+ ParentChange { target: content; parent: root }
+ AnchorChanges {
+ target: content
+ anchors { horizontalCenter: undefined; verticalCenter: undefined }
+ }
+ }
+ }
+ DropArea {
+ anchors.fill: parent
+
+ onEntered: {
+ dropVisible = true
+ playerBtnDND.deleteBtn = false
+ }
+
+ onExited: {
+ dropVisible = false
+ if(!playerBtnDND.addBtn)
+ playerBtnDND.deleteBtn = true
+ }
+
+ onDropped: {
+ if (drag.source.objectName == "buttonsList")
+ playerBtnDND.model.insert(parent.DelegateModel.itemsIndex,
+ {"id" : drag.source.mIndex,
+ "size": bigButton.checked ?
+ PlayerControlBarModel.WIDGET_BIG :
+ PlayerControlBarModel.WIDGET_NORMAL})
+ else
+ playerBtnDND.model.move(
+ drag.source.DelegateModel.itemsIndex,
+ parent.DelegateModel.itemsIndex)
+ dropVisible = false
+ }
+ }
+}
diff --git a/modules/gui/qt/vlc.qrc b/modules/gui/qt/vlc.qrc
index 73898ccc04..734a340459 100644
--- a/modules/gui/qt/vlc.qrc
+++ b/modules/gui/qt/vlc.qrc
@@ -265,5 +265,6 @@
<file alias="Dialogs.qml">qml/dialogs/Dialogs.qml</file>
<file alias="ModalDialog.qml">qml/dialogs/ModalDialog.qml</file>
<file alias="EditorDummyButton.qml">qml/dialogs/EditorDummyButton.qml</file>
+ <file alias="EditorDNDDelegate.qml">qml/dialogs/EditorDNDDelegate.qml</file>
</qresource>
</RCC>
--
2.17.1
More information about the vlc-devel
mailing list