Show a conformation message after a successful manage action

Contributes to: CURA-8587
This commit is contained in:
Jelle Spijker 2021-12-07 12:23:04 +01:00
parent 1c0e484069
commit ca76bcc29c
No known key found for this signature in database
GPG Key ID: 6662DC033BE6B99A
4 changed files with 91 additions and 22 deletions

View File

@ -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:

View File

@ -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()

View File

@ -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
}
}
]
}

View File

@ -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