Trying to set a persistent install managebutton

Contributes to: CURA-8587
This commit is contained in:
Jelle Spijker 2021-12-07 18:25:46 +01:00
parent 9e4258ef8b
commit 3be6747e5d
No known key found for this signature in database
GPG key ID: 6662DC033BE6B99A
3 changed files with 34 additions and 45 deletions

View file

@ -367,7 +367,7 @@ class PackageModel(QObject):
@is_recently_installed.setter
def is_recently_installed(self, value):
if value != self._is_recently_installed:
value = self._is_recently_installed
self._is_recently_installed = value
self.stateManageButtonChanged.emit()
@property

View file

@ -17,16 +17,14 @@ RowLayout
property string busySecondaryText: busyMessageText.text
property string confirmedPrimaryText: confirmedMessageText.text
property string confirmedSecondaryText: confirmedMessageText.text
property bool enabled: true
property bool busy: false
property bool confirmed: false
property bool busy
property bool confirmed
signal clicked(bool primary_action)
Cura.PrimaryButton
{
id: primaryButton
visible: false
enabled: manageButton.enabled
onClicked:
@ -40,7 +38,6 @@ RowLayout
Cura.SecondaryButton
{
id: secondaryButton
visible: false
enabled: manageButton.enabled
onClicked:
@ -54,7 +51,6 @@ RowLayout
Item
{
id: busyMessage
visible: false
property alias text: busyMessageText.text
height: UM.Theme.getSize("action_button").height
width: childrenRect.width
@ -62,7 +58,6 @@ RowLayout
UM.RecolorImage
{
id: busyIndicator
visible: busyMessage.visible
width: height
anchors.left: parent.left
anchors.top: parent.top
@ -86,7 +81,6 @@ RowLayout
Label
{
id: busyMessageText
visible: busyMessage.visible
anchors.left: busyIndicator.right
anchors.leftMargin: UM.Theme.getSize("narrow_margin").width
anchors.verticalCenter: parent.verticalCenter
@ -101,14 +95,12 @@ RowLayout
id: confirmedMessage
property alias text: confirmedMessageText.text
visible: false
height: UM.Theme.getSize("action_button").height
width: childrenRect.width
Label
{
id: confirmedMessageText
visible: parent.visible
anchors.verticalCenter: parent.verticalCenter
font: UM.Theme.getFont("medium_bold")
@ -122,12 +114,6 @@ RowLayout
{
name: "primary"
PropertyChanges
{
target: manageButton
busy: false
confirmed: false
}
PropertyChanges
{
target: primaryButton
visible: true
@ -152,12 +138,6 @@ RowLayout
{
name: "secondary"
PropertyChanges
{
target: manageButton
busy: false
confirmed: false
}
PropertyChanges
{
target: primaryButton
visible: false
@ -183,7 +163,22 @@ RowLayout
name: "hidden"
PropertyChanges
{
target: manageButton
target: primaryButton
visible: false
}
PropertyChanges
{
target: secondaryButton
visible: false
}
PropertyChanges
{
target: busyMessage
visible: false
}
PropertyChanges
{
target: confirmedMessage
visible: false
}
},
@ -191,12 +186,6 @@ RowLayout
{
name: "busy"
PropertyChanges
{
target: manageButton
busy: true
confirmed: false
}
PropertyChanges
{
target: primaryButton
visible: false
@ -209,7 +198,7 @@ RowLayout
PropertyChanges
{
target: busyMessage
visible: manageButton.visible
visible: true
}
PropertyChanges
{
@ -221,12 +210,6 @@ RowLayout
{
name: "confirmed"
PropertyChanges
{
target: manageButton
busy: false
confirmed: true
}
PropertyChanges
{
target: primaryButton
visible: false
@ -244,7 +227,7 @@ RowLayout
PropertyChanges
{
target: confirmedMessage
visible: manageButton.visible
visible: true
}
}
]

View file

@ -323,7 +323,9 @@ Rectangle
ManageButton
{
id: enableManageButton
state: packageData.stateManageEnableButton
state: !(installManageButton.confirmed || updateManageButton.confirmed) || enableManageButton.confirmed ? packageData.stateManageEnableButton : "hidden"
busy: packageData.enableManageButton == "busy"
confirmed: packageData.enableManageButton == "confirmed"
Layout.alignment: Qt.AlignTop
primaryText: catalog.i18nc("@button", "Enable")
busyPrimaryText: catalog.i18nc("@button", "Enabling...")
@ -332,9 +334,9 @@ Rectangle
busySecondaryText: catalog.i18nc("@button", "Disabling...")
confirmedSecondaryText: catalog.i18nc("@button", "Disabled")
enabled: !(installManageButton.busy || updateManageButton.busy)
visible: (root.manageableInListView || root.expanded) && !(installManageButton.confirmed || updateManageButton.confirmed)
onClicked: {
onClicked:
{
if (primary_action)
{
packageData.enablePackageTriggered(packageData.packageId)
@ -349,7 +351,9 @@ Rectangle
ManageButton
{
id: installManageButton
state: packageData.stateManageInstallButton
state: (root.manageableInListView || root.expanded || installManageButton.confirmed) && !(enableManageButton.confirmed || updateManageButton.confirmed) ? packageData.stateManageInstallButton : "hidden"
busy: packageData.stateManageInstallButton == "busy"
confirmed: packageData.stateManageInstallButton == "confirmed"
Layout.alignment: Qt.AlignTop
primaryText: catalog.i18nc("@button", "Install")
busyPrimaryText: catalog.i18nc("@button", "Installing...")
@ -358,7 +362,8 @@ Rectangle
busySecondaryText: catalog.i18nc("@button", "Uninstalling...")
confirmedSecondaryText: catalog.i18nc("@button", "Uninstalled")
enabled: !(enableManageButton.busy || updateManageButton.busy)
visible: (installManageButton.confirmed || root.manageableInListView || root.expanded) && !(updateManageButton.confirmed || enableManageButton.confirmed)
onStateChanged: print(packageData.displayName + " " + state) // TODO: Cleanup once you find out why this happens
onClicked:
{
@ -376,13 +381,14 @@ Rectangle
ManageButton
{
id: updateManageButton
state: packageData.stateManageUpdateButton
state: (root.manageableInListView || root.expanded) && (!installManageButton.confirmed || updateManageButton.confirmed) ? packageData.stateManageUpdateButton : "hidden"
busy: packageData.stateManageUpdateButton == "busy"
confirmed: packageData.stateManageUpdateButton == "confirmed"
Layout.alignment: Qt.AlignTop
primaryText: catalog.i18nc("@button", "Update")
busyPrimaryText: catalog.i18nc("@button", "Updating...")
confirmedPrimaryText: catalog.i18nc("@button", "Updated")
enabled: !(installManageButton.busy || enableManageButton.busy)
visible: (root.manageableInListView || root.expanded) && !installManageButton.confirmed
onClicked: packageData.updatePackageTriggered(packageData.packageId)
}