Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelle Spijker <spijker.jelle@gmail.com>2021-12-07 17:06:46 +0300
committerJelle Spijker <spijker.jelle@gmail.com>2021-12-07 17:06:46 +0300
commitbb9696c39faf93197f1c4a6ca141437ea8789607 (patch)
tree391c1955acf1414a4306be8a6cc83ad1738792e6 /plugins
parent5b3e9079edfe7ef6722e7c3a17d9eb0fbf410958 (diff)
Reset button if user declines license
Contributes to: CURA-8587
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Marketplace/PackageList.py28
-rw-r--r--plugins/Marketplace/PackageModel.py49
-rw-r--r--plugins/Marketplace/resources/qml/ManageButton.qml34
-rw-r--r--plugins/Marketplace/resources/qml/PackageCard.qml2
4 files changed, 73 insertions, 40 deletions
diff --git a/plugins/Marketplace/PackageList.py b/plugins/Marketplace/PackageList.py
index 47b5e8ff4b..c83c5a7130 100644
--- a/plugins/Marketplace/PackageList.py
+++ b/plugins/Marketplace/PackageList.py
@@ -18,7 +18,7 @@ from cura.CuraApplication import CuraApplication
from cura.CuraPackageManager import CuraPackageManager
from cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope # To make requests to the Ultimaker API with correct authorization.
-from .PackageModel import PackageModel
+from .PackageModel import PackageModel, ManageState
from .Constants import USER_PACKAGES_URL
if TYPE_CHECKING:
@@ -161,7 +161,7 @@ class PackageList(ListModel):
dialog.deleteLater()
# reset package card
package = self.getPackageModel(package_id)
- package.is_installing = False
+ package.is_installing = ManageState.FAILED
def _requestInstall(self, package_id: str, update: bool = False) -> None:
Logger.debug(f"Request installing {package_id}")
@@ -185,9 +185,9 @@ class PackageList(ListModel):
if package.can_update and to_be_installed:
package.can_update = False
if update:
- package.is_updating = False
+ package.is_updating = ManageState.HALTED
else:
- package.is_installing = False
+ package.is_installing = ManageState.HALTED
self.subscribeUserToPackage(package_id, str(package.sdk_version))
def download(self, package_id: str, url: str, update: bool = False) -> None:
@@ -232,9 +232,9 @@ class PackageList(ListModel):
Logger.error(f"Failed to download package: {package_id} due to {reply_string}")
package = self.getPackageModel(package_id)
if update:
- package.is_updating = False
+ package.is_updating = ManageState.FAILED
else:
- package.is_installing = False
+ package.is_installing = ManageState.FAILED
def subscribeUserToPackage(self, package_id: str, sdk_version: str) -> None:
"""Subscribe the user (if logged in) to the package for a given SDK
@@ -275,7 +275,7 @@ class PackageList(ListModel):
:param package_id: the package identification string
"""
package = self.getPackageModel(package_id)
- package.is_installing = True
+ package.is_installing = ManageState.PROCESSING
url = package.download_url
Logger.debug(f"Trying to download and install {package_id} from {url}")
self.download(package_id, url, False)
@@ -288,10 +288,10 @@ class PackageList(ListModel):
"""
Logger.debug(f"Uninstalling {package_id}")
package = self.getPackageModel(package_id)
- package.is_installing = True
+ package.is_installing = ManageState.PROCESSING
self._manager.removePackage(package_id)
self.unsunscribeUserFromPackage(package_id)
- package.is_installing = False
+ package.is_installing = ManageState.HALTED
@pyqtSlot(str)
def updatePackage(self, package_id: str) -> None:
@@ -300,7 +300,7 @@ class PackageList(ListModel):
:param package_id: the package identification string
"""
package = self.getPackageModel(package_id)
- package.is_updating = True
+ package.is_updating = ManageState.PROCESSING
self._manager.removePackage(package_id, force_add = True)
url = package.download_url
Logger.debug(f"Trying to download and update {package_id} from {url}")
@@ -313,11 +313,11 @@ class PackageList(ListModel):
:param package_id: the package identification string
"""
package = self.getPackageModel(package_id)
- package.is_enabling = True
+ package.is_enabling = ManageState.PROCESSING
Logger.debug(f"Enabling {package_id}")
self._plugin_registry.enablePlugin(package_id)
package.is_active = True
- package.is_enabling = False
+ package.is_enabling = ManageState.HALTED
@pyqtSlot(str)
def disablePackage(self, package_id: str) -> None:
@@ -326,8 +326,8 @@ class PackageList(ListModel):
:param package_id: the package identification string
"""
package = self.getPackageModel(package_id)
- package.is_enabling = True
+ package.is_enabling = ManageState.PROCESSING
Logger.debug(f"Disabling {package_id}")
self._plugin_registry.disablePlugin(package_id)
package.is_active = False
- package.is_enabling = False
+ package.is_enabling = ManageState.HALTED
diff --git a/plugins/Marketplace/PackageModel.py b/plugins/Marketplace/PackageModel.py
index 6b313eb9a5..97e57cf951 100644
--- a/plugins/Marketplace/PackageModel.py
+++ b/plugins/Marketplace/PackageModel.py
@@ -1,16 +1,25 @@
# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
-from PyQt5.QtCore import pyqtProperty, QObject, pyqtSignal
import re
+from enum import Enum
from typing import Any, Dict, List, Optional
+from PyQt5.QtCore import pyqtProperty, QObject, pyqtSignal
+
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry # To get names of materials we're compatible with.
from UM.i18n import i18nCatalog # To translate placeholder names if data is not present.
+from UM.Logger import Logger
catalog = i18nCatalog("cura")
+class ManageState(Enum):
+ PROCESSING = 1
+ HALTED = 0
+ FAILED = -1
+
+
class PackageModel(QObject):
"""
Represents a package, containing all the relevant information to be displayed about a package.
@@ -60,14 +69,14 @@ class PackageModel(QObject):
if not self._icon_url or self._icon_url == "":
self._icon_url = author_data.get("icon_url", "")
- self._is_installing = False
+ self._is_installing: ManageState = ManageState.HALTED
self._is_recently_installed = False
self._is_recently_updated = False
self._is_recently_enabled = False
self._can_update = False
- self._is_updating = False
- self._is_enabling = False
+ self._is_updating: ManageState = ManageState.HALTED
+ self._is_enabling: ManageState = ManageState.HALTED
self._can_downgrade = False
self._section_title = section_title
self.sdk_version = package_data.get("sdk_version_semver", "")
@@ -288,7 +297,7 @@ 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:
+ if self._is_enabling == ManageState.PROCESSING:
return "busy"
if self._is_recently_enabled:
return "confirmed"
@@ -299,16 +308,16 @@ class PackageModel(QObject):
return "primary"
@property
- def is_enabling(self) -> bool:
+ def is_enabling(self) -> ManageState:
"""Flag if the package is being enabled/disabled"""
return self._is_enabling
@is_enabling.setter
- def is_enabling(self, value: bool) -> None:
+ def is_enabling(self, value: ManageState) -> None:
if value != self._is_enabling:
- if not value:
- self._is_recently_enabled = True
self._is_enabling = value
+ if value == ManageState.HALTED:
+ self._is_recently_enabled = True
self.stateManageButtonChanged.emit()
@property
@@ -327,7 +336,7 @@ class PackageModel(QObject):
@pyqtProperty(str, notify = stateManageButtonChanged)
def stateManageInstallButton(self) -> str:
"""The state of the Manage Install package card"""
- if self._is_installing:
+ if self._is_installing == ManageState.PROCESSING:
return "busy"
if self._is_recently_installed:
return "confirmed"
@@ -340,16 +349,16 @@ class PackageModel(QObject):
return "primary"
@property
- def is_installing(self) -> bool:
- """Flag is we're currently installing"""
+ def is_installing(self) -> ManageState:
+ """Flag is we're currently installing, when setting this to ``None`` in indicates a failed installation"""
return self._is_installing
@is_installing.setter
- def is_installing(self, value: bool) -> None:
+ def is_installing(self, value: ManageState) -> None:
if value != self._is_installing:
- if not value:
- self._is_recently_installed = True
self._is_installing = value
+ if value == ManageState.HALTED:
+ self._is_recently_installed = True
self.stateManageButtonChanged.emit()
@property
@@ -368,7 +377,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:
+ if self._is_updating == ManageState.PROCESSING:
return "busy"
if self._is_recently_updated:
return "confirmed"
@@ -377,16 +386,16 @@ class PackageModel(QObject):
return "hidden"
@property
- def is_updating(self) -> bool:
+ def is_updating(self) -> ManageState:
"""Flag indicating if the package is being updated"""
return self._is_updating
@is_updating.setter
- def is_updating(self, value: bool) -> None:
+ def is_updating(self, value: ManageState) -> None:
if value != self._is_updating:
- if not value:
- self._is_recently_updated = True
self._is_updating = value
+ if value == ManageState.HALTED:
+ self._is_recently_updated = True
self.stateManageButtonChanged.emit()
@property
diff --git a/plugins/Marketplace/resources/qml/ManageButton.qml b/plugins/Marketplace/resources/qml/ManageButton.qml
index 29b8ff22a5..0b3008461b 100644
--- a/plugins/Marketplace/resources/qml/ManageButton.qml
+++ b/plugins/Marketplace/resources/qml/ManageButton.qml
@@ -18,8 +18,8 @@ RowLayout
property string confirmedPrimaryText: confirmedMessageText.text
property string confirmedSecondaryText: confirmedMessageText.text
property bool enabled: true
- property bool busy: state == "busy"
- property bool confirmed: state == "confirmed"
+ property bool busy: false
+ property bool confirmed: false
signal clicked(bool primary_action)
@@ -62,7 +62,7 @@ RowLayout
UM.RecolorImage
{
id: busyIndicator
- visible: parent.visible
+ visible: busyMessage.visible
width: height
anchors.left: parent.left
anchors.top: parent.top
@@ -76,7 +76,7 @@ RowLayout
RotationAnimator
{
target: busyIndicator
- running: busyIndicator.visible
+ running: busyMessage.visible
from: 0
to: 360
loops: Animation.Infinite
@@ -86,7 +86,7 @@ RowLayout
Label
{
id: busyMessageText
- visible: parent.visible
+ visible: busyMessage.visible
anchors.left: busyIndicator.right
anchors.leftMargin: UM.Theme.getSize("narrow_margin").width
anchors.verticalCenter: parent.verticalCenter
@@ -123,6 +123,12 @@ RowLayout
name: "primary"
PropertyChanges
{
+ target: manageButton
+ busy: false
+ confirmed: false
+ }
+ PropertyChanges
+ {
target: primaryButton
visible: true
}
@@ -147,6 +153,12 @@ RowLayout
name: "secondary"
PropertyChanges
{
+ target: manageButton
+ busy: false
+ confirmed: false
+ }
+ PropertyChanges
+ {
target: primaryButton
visible: false
}
@@ -180,6 +192,12 @@ RowLayout
name: "busy"
PropertyChanges
{
+ target: manageButton
+ busy: true
+ confirmed: false
+ }
+ PropertyChanges
+ {
target: primaryButton
visible: false
}
@@ -204,6 +222,12 @@ RowLayout
name: "confirmed"
PropertyChanges
{
+ target: manageButton
+ busy: false
+ confirmed: true
+ }
+ PropertyChanges
+ {
target: primaryButton
visible: false
}
diff --git a/plugins/Marketplace/resources/qml/PackageCard.qml b/plugins/Marketplace/resources/qml/PackageCard.qml
index d782d43cbb..721a152b12 100644
--- a/plugins/Marketplace/resources/qml/PackageCard.qml
+++ b/plugins/Marketplace/resources/qml/PackageCard.qml
@@ -358,7 +358,7 @@ Rectangle
busySecondaryText: catalog.i18nc("@button", "Uninstalling...")
confirmedSecondaryText: catalog.i18nc("@button", "Uninstalled")
enabled: !(enableManageButton.busy || updateManageButton.busy)
- visible: state == "confirmed" || root.manageableInListView || root.expanded
+ visible: installManageButton.confirmed || root.manageableInListView || root.expanded
onClicked:
{