aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/externaldraganddrop
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/externaldraganddrop')
-rw-r--r--examples/quick/externaldraganddrop/DragAndDropTextItem.qml92
-rw-r--r--examples/quick/externaldraganddrop/doc/images/qml-dnd2-example.pngbin0 -> 48666 bytes
-rw-r--r--examples/quick/externaldraganddrop/doc/src/externaldraganddrop.qdoc38
-rw-r--r--examples/quick/externaldraganddrop/externaldraganddrop.pro11
-rw-r--r--examples/quick/externaldraganddrop/externaldraganddrop.qml79
-rw-r--r--examples/quick/externaldraganddrop/externaldraganddrop.qmlproject16
-rw-r--r--examples/quick/externaldraganddrop/externaldraganddrop.qrc6
-rw-r--r--examples/quick/externaldraganddrop/main.cpp41
8 files changed, 283 insertions, 0 deletions
diff --git a/examples/quick/externaldraganddrop/DragAndDropTextItem.qml b/examples/quick/externaldraganddrop/DragAndDropTextItem.qml
new file mode 100644
index 0000000000..390a4b3abe
--- /dev/null
+++ b/examples/quick/externaldraganddrop/DragAndDropTextItem.qml
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+Rectangle {
+ id: item
+ property string display
+ color: "#EEE"
+ Text {
+ anchors.fill: parent
+ text: item.display
+ wrapMode: Text.WordWrap
+ }
+ DropArea {
+ anchors.fill: parent
+ keys: ["text/plain"]
+ onEntered: {
+ item.color = "#FCC"
+ }
+ onExited: {
+ item.color = "#EEE"
+ }
+ onDropped: {
+ item.color = "#EEE"
+ if (drop.hasText) {
+ if (drop.proposedAction == Qt.MoveAction || drop.proposedAction == Qt.CopyAction) {
+ item.display = drop.text
+ drop.acceptProposedAction()
+ }
+ }
+ }
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ drag.target: draggable
+ }
+ Item {
+ id: draggable
+ anchors.fill: parent
+ Drag.active: mouseArea.drag.active
+ Drag.hotSpot.x: 0
+ Drag.hotSpot.y: 0
+ Drag.mimeData: { "text/plain": item.display }
+ Drag.dragType: Drag.Automatic
+ Drag.onDragStarted: {
+ }
+ Drag.onDragFinished: {
+ if (dropAction == Qt.MoveAction) {
+ item.display = ""
+ }
+ }
+ } // Item
+}
diff --git a/examples/quick/externaldraganddrop/doc/images/qml-dnd2-example.png b/examples/quick/externaldraganddrop/doc/images/qml-dnd2-example.png
new file mode 100644
index 0000000000..e657d81795
--- /dev/null
+++ b/examples/quick/externaldraganddrop/doc/images/qml-dnd2-example.png
Binary files differ
diff --git a/examples/quick/externaldraganddrop/doc/src/externaldraganddrop.qdoc b/examples/quick/externaldraganddrop/doc/src/externaldraganddrop.qdoc
new file mode 100644
index 0000000000..1251e6e1eb
--- /dev/null
+++ b/examples/quick/externaldraganddrop/doc/src/externaldraganddrop.qdoc
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+ \title Qt Quick Examples - externaldraganddrop
+ \example externaldraganddrop
+ \brief This is an example of drag and drop between Qml and other applications
+ \image qml-dnd2-example.png
+ \ingroup qtquickexamples
+
+ This example shows you how to respond to do drag and drop using MouseArea and DropArea.
+
+ Drag text between boxes, out of boxes into other applications, and from other applications into the boxes. Use option/ctrl to copy rather than move text when dragging between boxes.
+
+*/
diff --git a/examples/quick/externaldraganddrop/externaldraganddrop.pro b/examples/quick/externaldraganddrop/externaldraganddrop.pro
new file mode 100644
index 0000000000..646781e7d1
--- /dev/null
+++ b/examples/quick/externaldraganddrop/externaldraganddrop.pro
@@ -0,0 +1,11 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+RESOURCES += externaldraganddrop.qrc
+
+EXAMPLE_FILES = \
+ DragAndDropTextItem.qml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/externaldraganddrop
+INSTALLS += target
diff --git a/examples/quick/externaldraganddrop/externaldraganddrop.qml b/examples/quick/externaldraganddrop/externaldraganddrop.qml
new file mode 100644
index 0000000000..f39d33dda7
--- /dev/null
+++ b/examples/quick/externaldraganddrop/externaldraganddrop.qml
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Layouts 1.0
+
+Item {
+ id: root
+ width: 320
+ height: 480
+
+ ColumnLayout {
+
+ anchors.fill: parent
+ anchors.margins: 8
+
+ Text {
+ Layout.fillWidth: true
+ text: "Drag text into, out of, and between the boxes below."
+ wrapMode: Text.WordWrap
+ }
+
+ DragAndDropTextItem {
+ Layout.fillWidth: true
+ height: 142
+ display: "Sample Text"
+ }
+
+ DragAndDropTextItem {
+ Layout.fillWidth: true
+ height: 142
+ display: "Option/ctrl drag to copy instead of move text."
+ }
+
+ DragAndDropTextItem {
+ Layout.fillWidth: true
+ height: 142
+ display: "Drag out into other applications."
+ }
+
+ }
+}
diff --git a/examples/quick/externaldraganddrop/externaldraganddrop.qmlproject b/examples/quick/externaldraganddrop/externaldraganddrop.qmlproject
new file mode 100644
index 0000000000..359efae597
--- /dev/null
+++ b/examples/quick/externaldraganddrop/externaldraganddrop.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "externaldraganddrop.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/externaldraganddrop/externaldraganddrop.qrc b/examples/quick/externaldraganddrop/externaldraganddrop.qrc
new file mode 100644
index 0000000000..edac9820c9
--- /dev/null
+++ b/examples/quick/externaldraganddrop/externaldraganddrop.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/externaldraganddrop">
+ <file>externaldraganddrop.qml</file>
+ <file>DragAndDropTextItem.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/externaldraganddrop/main.cpp b/examples/quick/externaldraganddrop/main.cpp
new file mode 100644
index 0000000000..33600e7983
--- /dev/null
+++ b/examples/quick/externaldraganddrop/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(externaldraganddrop/externaldraganddrop)