mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 16:27:51 -06:00
CURA-5357 Drag & dribble multiple packages like a plugable trickle, yo
Also improved interfacing with `CuraVersion.py`
This commit is contained in:
parent
80d4989843
commit
13b3e4afa5
2 changed files with 46 additions and 31 deletions
|
@ -28,7 +28,8 @@ i18n_catalog = i18nCatalog("cura")
|
||||||
## The Toolbox class is responsible of communicating with the server through the API
|
## The Toolbox class is responsible of communicating with the server through the API
|
||||||
class Toolbox(QObject, Extension):
|
class Toolbox(QObject, Extension):
|
||||||
|
|
||||||
DEFAULT_PACKAGES_API_ROOT = "https://api.ultimaker.com"
|
DEFAULT_CLOUD_API_ROOT = "https://api.ultimaker.com"
|
||||||
|
DEFAULT_CLOUD_API_VERSION = 1
|
||||||
|
|
||||||
def __init__(self, parent=None) -> None:
|
def __init__(self, parent=None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
@ -37,16 +38,10 @@ class Toolbox(QObject, Extension):
|
||||||
self._package_manager = None
|
self._package_manager = None
|
||||||
self._plugin_registry = Application.getInstance().getPluginRegistry()
|
self._plugin_registry = Application.getInstance().getPluginRegistry()
|
||||||
|
|
||||||
self._sdk_version = self._getPackagesVersion()
|
self._sdk_version = None
|
||||||
|
self._cloud_api_version = None
|
||||||
self._cloud_api_version = 1
|
self._cloud_api_root = None
|
||||||
self._cloud_api_root = self._getPackagesApiRoot()
|
self._api_url = None
|
||||||
|
|
||||||
self._api_url = "{cloud_api_root}/cura-packages/v{cloud_api_version}/cura/v{sdk_version}".format(
|
|
||||||
cloud_api_root = self._cloud_api_root,
|
|
||||||
cloud_api_version = self._cloud_api_version,
|
|
||||||
sdk_version = self._sdk_version
|
|
||||||
)
|
|
||||||
|
|
||||||
# Network:
|
# Network:
|
||||||
self._get_packages_request = None
|
self._get_packages_request = None
|
||||||
|
@ -67,12 +62,7 @@ class Toolbox(QObject, Extension):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
self._request_urls = {
|
self._request_urls = {}
|
||||||
"authors": QUrl("{base_url}/authors".format(base_url = self._api_url)),
|
|
||||||
"packages": QUrl("{base_url}/packages".format(base_url = self._api_url)),
|
|
||||||
"plugins_showcase": QUrl("{base_url}/showcase".format(base_url = self._api_url)),
|
|
||||||
"materials_showcase": QUrl("{base_url}/showcase".format(base_url = self._api_url))
|
|
||||||
}
|
|
||||||
self._to_update = [] # Package_ids that are waiting to be updated
|
self._to_update = [] # Package_ids that are waiting to be updated
|
||||||
|
|
||||||
# Data:
|
# Data:
|
||||||
|
@ -164,22 +154,44 @@ class Toolbox(QObject, Extension):
|
||||||
# this is initialized. Therefore, we wait until the application is ready.
|
# this is initialized. Therefore, we wait until the application is ready.
|
||||||
def _onAppInitialized(self) -> None:
|
def _onAppInitialized(self) -> None:
|
||||||
self._package_manager = Application.getInstance().getCuraPackageManager()
|
self._package_manager = Application.getInstance().getCuraPackageManager()
|
||||||
|
self._sdk_version = self._getSDKVersion()
|
||||||
|
self._cloud_api_version = self._getCloudAPIVersion()
|
||||||
|
self._cloud_api_root = self._getCloudAPIRoot()
|
||||||
|
self._api_url = "{cloud_api_root}/cura-packages/v{cloud_api_version}/cura/v{sdk_version}".format(
|
||||||
|
cloud_api_root=self._cloud_api_root,
|
||||||
|
cloud_api_version=self._cloud_api_version,
|
||||||
|
sdk_version=self._sdk_version
|
||||||
|
)
|
||||||
|
self._request_urls = {
|
||||||
|
"authors": QUrl("{base_url}/authors".format(base_url=self._api_url)),
|
||||||
|
"packages": QUrl("{base_url}/packages".format(base_url=self._api_url)),
|
||||||
|
"plugins_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url)),
|
||||||
|
"materials_showcase": QUrl("{base_url}/showcase".format(base_url=self._api_url))
|
||||||
|
}
|
||||||
|
|
||||||
# Get the API root for the packages API depending on Cura version settings.
|
# Get the API root for the packages API depending on Cura version settings.
|
||||||
def _getPackagesApiRoot(self) -> str:
|
def _getCloudAPIRoot(self) -> str:
|
||||||
if not hasattr(cura, "CuraVersion"):
|
if not hasattr(cura, "CuraVersion"):
|
||||||
return self.DEFAULT_PACKAGES_API_ROOT
|
return self.DEFAULT_CLOUD_API_ROOT
|
||||||
if not hasattr(cura.CuraVersion, "CuraPackagesApiRoot"):
|
if not hasattr(cura.CuraVersion, "CuraCloudAPIRoot"):
|
||||||
return self.DEFAULT_PACKAGES_API_ROOT
|
return self.DEFAULT_CLOUD_API_ROOT
|
||||||
return cura.CuraVersion.CuraPackagesApiRoot
|
return cura.CuraVersion.CuraCloudAPIRoot
|
||||||
|
|
||||||
|
# Get the cloud API version from CuraVersion
|
||||||
|
def _getCloudAPIVersion(self) -> int:
|
||||||
|
if not hasattr(cura, "CuraVersion"):
|
||||||
|
return self.DEFAULT_CLOUD_API_VERSION
|
||||||
|
if not hasattr(cura.CuraVersion, "CuraCloudAPIVersion"):
|
||||||
|
return self.DEFAULT_CLOUD_API_VERSION
|
||||||
|
return cura.CuraVersion.CuraCloudAPIVersion
|
||||||
|
|
||||||
# Get the packages version depending on Cura version settings.
|
# Get the packages version depending on Cura version settings.
|
||||||
def _getPackagesVersion(self) -> int:
|
def _getSDKVersion(self) -> int:
|
||||||
if not hasattr(cura, "CuraVersion"):
|
if not hasattr(cura, "CuraVersion"):
|
||||||
return self._plugin_registry.APIVersion
|
return self._plugin_registry.APIVersion
|
||||||
if not hasattr(cura.CuraVersion, "CuraPackagesVersion"):
|
if not hasattr(cura.CuraVersion, "CuraSDKVersion"):
|
||||||
return self._plugin_registry.APIVersion
|
return self._plugin_registry.APIVersion
|
||||||
return cura.CuraVersion.CuraPackagesVersion
|
return cura.CuraVersion.CuraSDKVersion
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def browsePackages(self) -> None:
|
def browsePackages(self) -> None:
|
||||||
|
|
|
@ -323,10 +323,11 @@ UM.MainWindow
|
||||||
{
|
{
|
||||||
if (drop.urls.length > 0)
|
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 nonPackages = [];
|
||||||
|
for (var i = 0; i < drop.urls.length; i++)
|
||||||
{
|
{
|
||||||
var filename = drop.urls[0];
|
var filename = drop.urls[i];
|
||||||
if (filename.endsWith(".curapackage"))
|
if (filename.endsWith(".curapackage"))
|
||||||
{
|
{
|
||||||
// Try to install plugin & close.
|
// Try to install plugin & close.
|
||||||
|
@ -334,11 +335,13 @@ UM.MainWindow
|
||||||
packageInstallDialog.text = catalog.i18nc("@label", "This package will be installed after restarting.");
|
packageInstallDialog.text = catalog.i18nc("@label", "This package will be installed after restarting.");
|
||||||
packageInstallDialog.icon = StandardIcon.Information;
|
packageInstallDialog.icon = StandardIcon.Information;
|
||||||
packageInstallDialog.open();
|
packageInstallDialog.open();
|
||||||
return;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
others.push(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
openDialog.handleOpenFileUrls(nonPackages);
|
||||||
openDialog.handleOpenFileUrls(drop.urls);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue