From ca76bcc29cc573b777c72ace624e384f78eff3d6 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 7 Dec 2021 12:23:04 +0100 Subject: [PATCH] Show a conformation message after a successful manage action Contributes to: CURA-8587 --- plugins/Marketplace/PackageList.py | 2 - plugins/Marketplace/PackageModel.py | 32 +++++---- .../resources/qml/ManageButton.qml | 68 ++++++++++++++++++- .../Marketplace/resources/qml/PackageCard.qml | 11 ++- 4 files changed, 91 insertions(+), 22 deletions(-) diff --git a/plugins/Marketplace/PackageList.py b/plugins/Marketplace/PackageList.py index 346b7a2b67..47b5e8ff4b 100644 --- a/plugins/Marketplace/PackageList.py +++ b/plugins/Marketplace/PackageList.py @@ -187,7 +187,6 @@ class PackageList(ListModel): if update: package.is_updating = False else: - package.is_recently_managed = True package.is_installing = False self.subscribeUserToPackage(package_id, str(package.sdk_version)) @@ -293,7 +292,6 @@ class PackageList(ListModel): self._manager.removePackage(package_id) self.unsunscribeUserFromPackage(package_id) package.is_installing = False - package.is_recently_managed = True @pyqtSlot(str) def updatePackage(self, package_id: str) -> None: diff --git a/plugins/Marketplace/PackageModel.py b/plugins/Marketplace/PackageModel.py index 2231f6adbd..6b313eb9a5 100644 --- a/plugins/Marketplace/PackageModel.py +++ b/plugins/Marketplace/PackageModel.py @@ -61,7 +61,10 @@ class PackageModel(QObject): self._icon_url = author_data.get("icon_url", "") self._is_installing = False - self._is_recently_managed = False + 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 @@ -287,7 +290,9 @@ class PackageModel(QObject): """The state of the manage Enable Button of this package""" if self._is_enabling: return "busy" - if self._is_recently_managed or self._package_type == "material" or not self._is_installed: + if self._is_recently_enabled: + return "confirmed" + if self._package_type == "material" or not self._is_installed: return "hidden" if self._is_installed and self._is_active: return "secondary" @@ -301,6 +306,8 @@ class PackageModel(QObject): @is_enabling.setter def is_enabling(self, value: bool) -> None: if value != self._is_enabling: + if not value: + self._is_recently_enabled = True self._is_enabling = value self.stateManageButtonChanged.emit() @@ -322,8 +329,8 @@ class PackageModel(QObject): """The state of the Manage Install package card""" if self._is_installing: return "busy" - if self._is_recently_managed: - return "hidden" + if self._is_recently_installed: + return "confirmed" if self._is_installed: if self._is_bundled and not self._can_downgrade: return "hidden" @@ -332,17 +339,6 @@ class PackageModel(QObject): else: return "primary" - @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 - def is_recently_managed(self, value: bool) -> None: - if value != self._is_recently_managed: - self._is_recently_managed = value - self.stateManageButtonChanged.emit() - @property def is_installing(self) -> bool: """Flag is we're currently installing""" @@ -351,6 +347,8 @@ class PackageModel(QObject): @is_installing.setter def is_installing(self, value: bool) -> None: if value != self._is_installing: + if not value: + self._is_recently_installed = True self._is_installing = value self.stateManageButtonChanged.emit() @@ -372,6 +370,8 @@ class PackageModel(QObject): """The state of the manage Update button for this card """ if self._is_updating: return "busy" + if self._is_recently_updated: + return "confirmed" if self._can_update: return "primary" return "hidden" @@ -384,6 +384,8 @@ class PackageModel(QObject): @is_updating.setter def is_updating(self, value: bool) -> None: if value != self._is_updating: + if not value: + self._is_recently_updated = True self._is_updating = value self.stateManageButtonChanged.emit() diff --git a/plugins/Marketplace/resources/qml/ManageButton.qml b/plugins/Marketplace/resources/qml/ManageButton.qml index 39be04d386..67532bc9aa 100644 --- a/plugins/Marketplace/resources/qml/ManageButton.qml +++ b/plugins/Marketplace/resources/qml/ManageButton.qml @@ -15,6 +15,8 @@ RowLayout property alias secondaryText: secondaryButton.text property string busyPrimaryText: busyMessageText.text property string busySecondaryText: busyMessageText.text + property string confirmedPrimaryText: confirmedMessageText.text + property string confirmedSecondaryText: confirmedMessageText.text property bool enabled: true property bool busy: state == "busy" @@ -28,7 +30,8 @@ RowLayout onClicked: { - busyMessageText.text = manageButton.busyPrimaryText + busyMessage.text = manageButton.busyPrimaryText + confirmedMessage.text = manageButton.confirmedPrimaryText manageButton.clicked(true) } } @@ -41,7 +44,8 @@ RowLayout onClicked: { - busyMessageText.text = manageButton.busySecondaryText + busyMessage.text = manageButton.busySecondaryText + confirmedMessage.text = manageButton.confirmedSecondaryText manageButton.clicked(false) } } @@ -50,6 +54,7 @@ RowLayout { id: busyMessage visible: false + property alias text: busyMessageText.text height: UM.Theme.getSize("action_button").height width: childrenRect.width @@ -90,6 +95,26 @@ RowLayout } } + Item + { + id: confirmedMessage + property alias text: confirmedMessageText.text + + visible: false + height: UM.Theme.getSize("action_button").height + width: childrenRect.width + + Label + { + id: confirmedMessageText + visible: parent.visble + anchors.verticalCenter: parent.verticalCenter + + font: UM.Theme.getFont("medium_bold") + color: UM.Theme.getColor("primary") + } + } + states: [ State @@ -110,6 +135,11 @@ RowLayout target: busyMessage visible: false } + PropertyChanges + { + target: confirmedMessage + visible: false + } }, State { @@ -129,6 +159,11 @@ RowLayout target: busyMessage visible: false } + PropertyChanges + { + target: confirmedMessage + visible: false + } }, State { @@ -157,6 +192,35 @@ RowLayout target: busyMessage visible: manageButton.visible } + PropertyChanges + { + target: confirmedMessage + visible: false + } + }, + State + { + name: "confirmed" + PropertyChanges + { + target: primaryButton + visible: false + } + PropertyChanges + { + target: secondaryButton + visible: false + } + PropertyChanges + { + target: busyMessage + visible: false + } + PropertyChanges + { + target: confirmedMessage + visible: manageButton.visible + } } ] } diff --git a/plugins/Marketplace/resources/qml/PackageCard.qml b/plugins/Marketplace/resources/qml/PackageCard.qml index 326cf0583f..46e9214284 100644 --- a/plugins/Marketplace/resources/qml/PackageCard.qml +++ b/plugins/Marketplace/resources/qml/PackageCard.qml @@ -326,9 +326,11 @@ Rectangle state: packageData.stateManageEnableButton Layout.alignment: Qt.AlignTop primaryText: catalog.i18nc("@button", "Enable") - busyPrimaryText: catalog.i18nc("@button", "Inabling...") + busyPrimaryText: catalog.i18nc("@button", "Enabling...") + confirmedPrimaryText: catalog.i18nc("@button", "Enabled") secondaryText: catalog.i18nc("@button", "Disable") busySecondaryText: catalog.i18nc("@button", "Disabling...") + confirmedSecondaryText: catalog.i18nc("@button", "Disabled") enabled: !(installManageButton.busy || updateManageButton.busy) visible: root.manageableInListView || root.expanded @@ -351,10 +353,12 @@ Rectangle Layout.alignment: Qt.AlignTop primaryText: catalog.i18nc("@button", "Install") busyPrimaryText: catalog.i18nc("@button", "Installing...") + confirmedPrimaryText: catalog.i18nc("@button", "Installed") secondaryText: catalog.i18nc("@button", "Uninstall") busySecondaryText: catalog.i18nc("@button", "Uninstalling...") + confirmedSecondaryText: catalog.i18nc("@button", "Uninstalled") enabled: !(enableManageButton.busy || updateManageButton.busy) - visible: root.manageableInListView || root.expanded + visible: state == "confirmed" || root.manageableInListView || root.expanded onClicked: { @@ -375,7 +379,8 @@ Rectangle state: packageData.stateManageUpdateButton Layout.alignment: Qt.AlignTop primaryText: catalog.i18nc("@button", "Update") - busyPrimaryText: catalog.i18nc("@button", "updating...") + busyPrimaryText: catalog.i18nc("@button", "Updating...") + confirmedPrimaryText: catalog.i18nc("@button", "Updated") enabled: !(installManageButton.busy || enableManageButton.busy) visible: root.manageableInListView || root.expanded