diff options
author | Jelle Spijker <spijker.jelle@gmail.com> | 2021-12-07 11:48:48 +0300 |
---|---|---|
committer | Jelle Spijker <spijker.jelle@gmail.com> | 2021-12-07 11:48:48 +0300 |
commit | f6966c25fb28214cedaf9ff84a22624fb013c11b (patch) | |
tree | abcefed3eefaf90d8882e8207fdcdba10015257b | |
parent | 0fefe85fca7518d4fa22992511d884d02e40ac28 (diff) |
Some final tweaks and added missing documentation
Contributes to: CURA-8587
-rw-r--r-- | cura/CuraPackageManager.py | 8 | ||||
-rw-r--r-- | plugins/Marketplace/Constants.py | 1 | ||||
-rw-r--r-- | plugins/Marketplace/Marketplace.py | 2 | ||||
-rw-r--r-- | plugins/Marketplace/PackageList.py | 35 | ||||
-rw-r--r-- | plugins/Marketplace/PackageModel.py | 19 | ||||
-rw-r--r-- | plugins/Marketplace/resources/qml/LicenseDialog.qml | 22 | ||||
-rw-r--r-- | plugins/Toolbox/src/CloudSync/CloudApiClient.py | 2 |
7 files changed, 65 insertions, 24 deletions
diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index e3595ef4bb..bca6494f37 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -1,13 +1,13 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from typing import Any, cast, Dict, List, Tuple, TYPE_CHECKING, Optional, Generator +from typing import Any, cast, Dict, List, Tuple, TYPE_CHECKING, Optional -from cura.CuraApplication import CuraApplication #To find some resource types. +from cura.CuraApplication import CuraApplication # To find some resource types. from cura.Settings.GlobalStack import GlobalStack -from UM.PackageManager import PackageManager #The class we're extending. -from UM.Resources import Resources #To find storage paths for some resource types. +from UM.PackageManager import PackageManager # The class we're extending. +from UM.Resources import Resources # To find storage paths for some resource types. from UM.i18n import i18nCatalog catalog = i18nCatalog("cura") diff --git a/plugins/Marketplace/Constants.py b/plugins/Marketplace/Constants.py index bc6d1f05fa..9f0f78b966 100644 --- a/plugins/Marketplace/Constants.py +++ b/plugins/Marketplace/Constants.py @@ -1,5 +1,6 @@ # Copyright (c) 2021 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. + from cura.UltimakerCloud import UltimakerCloudConstants from cura.ApplicationMetadata import CuraSDKVersion diff --git a/plugins/Marketplace/Marketplace.py b/plugins/Marketplace/Marketplace.py index 228ee1e506..d55e538f6c 100644 --- a/plugins/Marketplace/Marketplace.py +++ b/plugins/Marketplace/Marketplace.py @@ -2,7 +2,7 @@ # Cura is released under the terms of the LGPLv3 or higher. import os.path -from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject +from PyQt5.QtCore import pyqtSlot, QObject from PyQt5.QtQml import qmlRegisterType from typing import Optional, TYPE_CHECKING diff --git a/plugins/Marketplace/PackageList.py b/plugins/Marketplace/PackageList.py index f0a6d1de06..346b7a2b67 100644 --- a/plugins/Marketplace/PackageList.py +++ b/plugins/Marketplace/PackageList.py @@ -192,6 +192,12 @@ class PackageList(ListModel): self.subscribeUserToPackage(package_id, str(package.sdk_version)) def download(self, package_id: str, url: str, update: bool = False) -> None: + """Initiate the download request + + :param package_id: the package identification string + :param url: the URL from which the package needs to be obtained + :param update: A flag if this is download request is an update process + """ def downloadFinished(reply: "QNetworkReply") -> None: self._downloadFinished(package_id, reply, update) @@ -232,6 +238,11 @@ class PackageList(ListModel): package.is_installing = False def subscribeUserToPackage(self, package_id: str, sdk_version: str) -> None: + """Subscribe the user (if logged in) to the package for a given SDK + + :param package_id: the package identification string + :param sdk_version: the SDK version + """ if self._account.isLoggedIn: Logger.debug(f"Subscribing the user for package: {package_id}") HttpRequestManager.getInstance().put( @@ -241,6 +252,10 @@ class PackageList(ListModel): ) def unsunscribeUserFromPackage(self, package_id: str) -> None: + """Unsubscribe the user (if logged in) from the package + + :param package_id: the package identification string + """ if self._account.isLoggedIn: Logger.debug(f"Unsubscribing the user for package: {package_id}") HttpRequestManager.getInstance().delete(url = f"{USER_PACKAGES_URL}/{package_id}", scope = self._scope) @@ -256,6 +271,10 @@ class PackageList(ListModel): @pyqtSlot(str) def installPackage(self, package_id: str) -> None: + """Install a package from the Marketplace + + :param package_id: the package identification string + """ package = self.getPackageModel(package_id) package.is_installing = True url = package.download_url @@ -264,6 +283,10 @@ class PackageList(ListModel): @pyqtSlot(str) def uninstallPackage(self, package_id: str) -> None: + """Uninstall a package from the Marketplace + + :param package_id: the package identification string + """ Logger.debug(f"Uninstalling {package_id}") package = self.getPackageModel(package_id) package.is_installing = True @@ -274,6 +297,10 @@ class PackageList(ListModel): @pyqtSlot(str) def updatePackage(self, package_id: str) -> None: + """Update a package from the Marketplace + + :param package_id: the package identification string + """ package = self.getPackageModel(package_id) package.is_updating = True self._manager.removePackage(package_id, force_add = True) @@ -283,6 +310,10 @@ class PackageList(ListModel): @pyqtSlot(str) def enablePackage(self, package_id: str) -> None: + """Enable a package in the plugin registry + + :param package_id: the package identification string + """ package = self.getPackageModel(package_id) package.is_enabling = True Logger.debug(f"Enabling {package_id}") @@ -292,6 +323,10 @@ class PackageList(ListModel): @pyqtSlot(str) def disablePackage(self, package_id: str) -> None: + """Disable a package in the plugin registry + + :param package_id: the package identification string + """ package = self.getPackageModel(package_id) package.is_enabling = True Logger.debug(f"Disabling {package_id}") diff --git a/plugins/Marketplace/PackageModel.py b/plugins/Marketplace/PackageModel.py index f7682340c9..2231f6adbd 100644 --- a/plugins/Marketplace/PackageModel.py +++ b/plugins/Marketplace/PackageModel.py @@ -3,10 +3,9 @@ from PyQt5.QtCore import pyqtProperty, QObject, pyqtSignal import re -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional from cura.Settings.CuraContainerRegistry import CuraContainerRegistry # To get names of materials we're compatible with. -from UM.Logger import Logger from UM.i18n import i18nCatalog # To translate placeholder names if data is not present. catalog = i18nCatalog("cura") @@ -285,13 +284,10 @@ class PackageModel(QObject): @pyqtProperty(str, notify = stateManageButtonChanged) def stateManageEnableButton(self) -> str: + """The state of the manage Enable Button of this package""" if self._is_enabling: return "busy" - if self._is_recently_managed: - return "hidden" - if self._package_type == "material": - return "hidden" - if not self._is_installed: + if self._is_recently_managed or self._package_type == "material" or not self._is_installed: return "hidden" if self._is_installed and self._is_active: return "secondary" @@ -299,6 +295,7 @@ class PackageModel(QObject): @property def is_enabling(self) -> bool: + """Flag if the package is being enabled/disabled""" return self._is_enabling @is_enabling.setter @@ -309,6 +306,7 @@ class PackageModel(QObject): @property def is_active(self) -> bool: + """Flag if the package is currently active""" return self._is_active @is_active.setter @@ -321,6 +319,7 @@ class PackageModel(QObject): @pyqtProperty(str, notify = stateManageButtonChanged) def stateManageInstallButton(self) -> str: + """The state of the Manage Install package card""" if self._is_installing: return "busy" if self._is_recently_managed: @@ -335,6 +334,7 @@ class PackageModel(QObject): @property def is_recently_managed(self) -> bool: + """Flag if the package has been recently managed by the user, either un-/installed updated etc""" return self._is_recently_managed @is_recently_managed.setter @@ -345,6 +345,7 @@ class PackageModel(QObject): @property def is_installing(self) -> bool: + """Flag is we're currently installing""" return self._is_installing @is_installing.setter @@ -355,6 +356,7 @@ class PackageModel(QObject): @property def can_downgrade(self) -> bool: + """Flag if the installed package can be downgraded to a bundled version""" return self._can_downgrade @can_downgrade.setter @@ -367,6 +369,7 @@ class PackageModel(QObject): @pyqtProperty(str, notify = stateManageButtonChanged) def stateManageUpdateButton(self) -> str: + """The state of the manage Update button for this card """ if self._is_updating: return "busy" if self._can_update: @@ -375,6 +378,7 @@ class PackageModel(QObject): @property def is_updating(self) -> bool: + """Flag indicating if the package is being updated""" return self._is_updating @is_updating.setter @@ -385,6 +389,7 @@ class PackageModel(QObject): @property def can_update(self) -> bool: + """Flag indicating if the package can be updated""" return self._can_update @can_update.setter diff --git a/plugins/Marketplace/resources/qml/LicenseDialog.qml b/plugins/Marketplace/resources/qml/LicenseDialog.qml index d37fe38bd9..d44ef335eb 100644 --- a/plugins/Marketplace/resources/qml/LicenseDialog.qml +++ b/plugins/Marketplace/resources/qml/LicenseDialog.qml @@ -8,7 +8,7 @@ import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 import QtQuick.Controls.Styles 1.4 -import UM 1.1 as UM +import UM 1.6 as UM import Cura 1.6 as Cura UM.Dialog @@ -21,14 +21,15 @@ UM.Dialog height: minimumHeight backgroundColor: UM.Theme.getColor("main_background") + property variant catalog: UM.I18nCatalog { name: "cura" } + ColumnLayout { anchors.fill: parent spacing: UM.Theme.getSize("thick_margin").height - UM.I18nCatalog{id: catalog; name: "cura"} - - Row { + Row + { Layout.fillWidth: true height: childrenRect.height spacing: UM.Theme.getSize("default_margin").width @@ -36,6 +37,7 @@ UM.Dialog UM.RecolorImage { + id: icon width: UM.Theme.getSize("marketplace_large_icon").width height: UM.Theme.getSize("marketplace_large_icon").height color: UM.Theme.getColor("text") @@ -53,12 +55,10 @@ UM.Dialog wrapMode: Text.Wrap renderType: Text.NativeRendering } - } Cura.ScrollableTextArea { - Layout.fillWidth: true Layout.fillHeight: true anchors.topMargin: UM.Theme.getSize("default_margin").height @@ -73,7 +73,7 @@ UM.Dialog Cura.PrimaryButton { text: catalog.i18nc("@button", "Accept") - onClicked: { handler.onLicenseAccepted(packageId) } + onClicked: handler.onLicenseAccepted(packageId) } ] @@ -82,11 +82,11 @@ UM.Dialog Cura.SecondaryButton { text: catalog.i18nc("@button", "Decline") - onClicked: { handler.onLicenseDeclined(packageId) } + onClicked: handler.onLicenseDeclined(packageId) } ] - onAccepted: { handler.onLicenseAccepted(packageId) } - onRejected: { handler.onLicenseDeclined(packageId) } - onClosing: { handler.onLicenseDeclined(packageId) } + onAccepted: handler.onLicenseAccepted(packageId) + onRejected: handler.onLicenseDeclined(packageId) + onClosing: handler.onLicenseDeclined(packageId) } diff --git a/plugins/Toolbox/src/CloudSync/CloudApiClient.py b/plugins/Toolbox/src/CloudSync/CloudApiClient.py index 21eb1bdbd2..9543ec012e 100644 --- a/plugins/Toolbox/src/CloudSync/CloudApiClient.py +++ b/plugins/Toolbox/src/CloudSync/CloudApiClient.py @@ -38,7 +38,7 @@ class CloudApiClient: def _subscribe(self, package_id: str) -> None: """You probably don't want to use this directly. All installed packages will be automatically subscribed.""" - Logger.debug("Subscribing to {}", package_id) + Logger.debug("Subscribing to using the Old Toolbox {}", package_id) data = "{\"data\": {\"package_id\": \"%s\", \"sdk_version\": \"%s\"}}" % (package_id, CloudApiModel.sdk_version) HttpRequestManager.getInstance().put( url = CloudApiModel.api_url_user_packages, |