]> Some of my projects - aniplayer.git/commitdiff
Allow files to be opened by drag&drop
authorAPTX <marek321@gmail.com>
Sun, 12 Mar 2017 16:56:43 +0000 (17:56 +0100)
committerAPTX <marek321@gmail.com>
Sun, 12 Mar 2017 16:56:43 +0000 (17:56 +0100)
uiplugins/ui_desktop_qml_default/qml/main.qml

index 4834bfbb1999fc19a52bd4da6c9f8408f8e5f5df..973e198a439ff3e8894f15cdc660ec4b07f33e95 100644 (file)
@@ -106,6 +106,26 @@ Window {
         cursorShape: !controls.visible && window.visibility === Window.FullScreen ? Qt.BlankCursor : Qt.ArrowCursor;
     }
 
+    DropArea {
+        anchors.fill: parent
+        onEntered:  {
+            if (!drag.hasUrls) {
+                drag.accepted = false;
+                return false;
+            }
+            return true;
+        }
+
+        onDropped: {
+            if (!drop.hasUrls) {
+                drop.accepted = false;
+                return false;
+            }
+            var file = drop.urls[0];
+            player.loadAndPlay(file);
+        }
+    }
+
     PlayerControls {
         id: controls
         controlledPlayer: player