Browse Source

Plugins can now also be installed by dropping them onto the application

CURA-3712
Jaime van Kessel 7 years ago
parent
commit
ccec148243
1 changed files with 34 additions and 0 deletions
  1. 34 0
      resources/qml/Cura.qml

+ 34 - 0
resources/qml/Cura.qml

@@ -260,6 +260,32 @@ UM.MainWindow
                 {
                     if (drop.urls.length > 0)
                     {
+                        // As the drop area also supports plugins, first check if it's a plugin that was dropped.
+                        if(drop.urls.length == 1)
+                        {
+                            if(PluginRegistry.isPluginFile(drop.urls[0]))
+                            {
+                                // Try to install plugin & close.
+                                var result = PluginRegistry.installPlugin(drop.urls[0]);
+                                pluginInstallDialog.text = result.message
+                                if(result.status == "ok")
+                                {
+                                    pluginInstallDialog.icon = StandardIcon.Information
+                                }
+                                else if(result.status == "duplicate")
+                                {
+                                    pluginInstallDialog.icon = StandardIcon.Warning
+                                }
+                                else
+                                {
+                                    pluginInstallDialog.icon = StandardIcon.Critical
+                                }
+                                pluginInstallDialog.open();
+                                return;
+                            }
+
+                        }
+
                         openDialog.handleOpenFileUrls(drop.urls);
                     }
                 }
@@ -687,6 +713,14 @@ UM.MainWindow
         }
     }
 
+    MessageDialog
+    {
+        id: pluginInstallDialog
+        title: catalog.i18nc("@window:title", "Install Plugin");
+        standardButtons: StandardButton.Ok
+        modality: Qt.ApplicationModal
+    }
+
     MessageDialog {
         id: infoMultipleFilesWithGcodeDialog
         title: catalog.i18nc("@title:window", "Open File(s)")