mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 07:28:59 +08:00
Merge pull request #3845 from Ultimaker/CURA-5357_drag_n_drop_curapackage_hack_no2
CURA-5357 Drag-n-drop for curapackages
This commit is contained in:
commit
d4c5be0455
@ -8,13 +8,14 @@ import shutil
|
||||
import zipfile
|
||||
import tempfile
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, QObject, pyqtSignal
|
||||
from PyQt5.QtCore import pyqtSlot, QObject, pyqtSignal, QUrl
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Logger import Logger
|
||||
from UM.Resources import Resources
|
||||
from UM.Version import Version
|
||||
|
||||
|
||||
class CuraPackageManager(QObject):
|
||||
Version = 1
|
||||
|
||||
@ -184,6 +185,12 @@ class CuraPackageManager(QObject):
|
||||
def isPackageInstalled(self, package_id: str) -> bool:
|
||||
return self.getInstalledPackageInfo(package_id) is not None
|
||||
|
||||
# This is called by drag-and-dropping curapackage files.
|
||||
@pyqtSlot(QUrl)
|
||||
def installPackageViaDragAndDrop(self, file_url: str) -> None:
|
||||
filename = QUrl(file_url).toLocalFile()
|
||||
return self.installPackage(filename)
|
||||
|
||||
# Schedules the given package file to be installed upon the next start.
|
||||
@pyqtSlot(str)
|
||||
def installPackage(self, filename: str) -> None:
|
||||
|
@ -323,6 +323,21 @@ 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)
|
||||
{
|
||||
var filename = drop.urls[0];
|
||||
if (filename.endsWith(".curapackage"))
|
||||
{
|
||||
// Try to install plugin & close.
|
||||
CuraApplication.getCuraPackageManager().installPackageViaDragAndDrop(filename);
|
||||
packageInstallDialog.text = catalog.i18nc("@label", "This package will be installed after restarting.");
|
||||
packageInstallDialog.icon = StandardIcon.Information;
|
||||
packageInstallDialog.open();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
openDialog.handleOpenFileUrls(drop.urls);
|
||||
}
|
||||
}
|
||||
@ -789,6 +804,14 @@ UM.MainWindow
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog
|
||||
{
|
||||
id: packageInstallDialog
|
||||
title: catalog.i18nc("@window:title", "Install Package");
|
||||
standardButtons: StandardButton.Ok
|
||||
modality: Qt.ApplicationModal
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
id: infoMultipleFilesWithGcodeDialog
|
||||
title: catalog.i18nc("@title:window", "Open File(s)")
|
||||
|
Loading…
x
Reference in New Issue
Block a user