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 @is_recently_installed.setter
def is_recently_installed(self, value): def is_recently_installed(self, value):
if value != self._is_recently_installed: if value != self._is_recently_installed:
value = self._is_recently_installed self._is_recently_installed = value
self.stateManageButtonChanged.emit() self.stateManageButtonChanged.emit()
@property @property

View file

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

View file

@ -323,7 +323,9 @@ Rectangle
ManageButton ManageButton
{ {
id: enableManageButton 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 Layout.alignment: Qt.AlignTop
primaryText: catalog.i18nc("@button", "Enable") primaryText: catalog.i18nc("@button", "Enable")
busyPrimaryText: catalog.i18nc("@button", "Enabling...") busyPrimaryText: catalog.i18nc("@button", "Enabling...")
@ -332,9 +334,9 @@ Rectangle
busySecondaryText: catalog.i18nc("@button", "Disabling...") busySecondaryText: catalog.i18nc("@button", "Disabling...")
confirmedSecondaryText: catalog.i18nc("@button", "Disabled") confirmedSecondaryText: catalog.i18nc("@button", "Disabled")
enabled: !(installManageButton.busy || updateManageButton.busy) enabled: !(installManageButton.busy || updateManageButton.busy)
visible: (root.manageableInListView || root.expanded) && !(installManageButton.confirmed || updateManageButton.confirmed)
onClicked: { onClicked:
{
if (primary_action) if (primary_action)
{ {
packageData.enablePackageTriggered(packageData.packageId) packageData.enablePackageTriggered(packageData.packageId)
@ -349,7 +351,9 @@ Rectangle
ManageButton ManageButton
{ {
id: installManageButton 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 Layout.alignment: Qt.AlignTop
primaryText: catalog.i18nc("@button", "Install") primaryText: catalog.i18nc("@button", "Install")
busyPrimaryText: catalog.i18nc("@button", "Installing...") busyPrimaryText: catalog.i18nc("@button", "Installing...")
@ -358,7 +362,8 @@ Rectangle
busySecondaryText: catalog.i18nc("@button", "Uninstalling...") busySecondaryText: catalog.i18nc("@button", "Uninstalling...")
confirmedSecondaryText: catalog.i18nc("@button", "Uninstalled") confirmedSecondaryText: catalog.i18nc("@button", "Uninstalled")
enabled: !(enableManageButton.busy || updateManageButton.busy) 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: onClicked:
{ {
@ -376,13 +381,14 @@ Rectangle
ManageButton ManageButton
{ {
id: updateManageButton 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 Layout.alignment: Qt.AlignTop
primaryText: catalog.i18nc("@button", "Update") primaryText: catalog.i18nc("@button", "Update")
busyPrimaryText: catalog.i18nc("@button", "Updating...") busyPrimaryText: catalog.i18nc("@button", "Updating...")
confirmedPrimaryText: catalog.i18nc("@button", "Updated") confirmedPrimaryText: catalog.i18nc("@button", "Updated")
enabled: !(installManageButton.busy || enableManageButton.busy) enabled: !(installManageButton.busy || enableManageButton.busy)
visible: (root.manageableInListView || root.expanded) && !installManageButton.confirmed
onClicked: packageData.updatePackageTriggered(packageData.packageId) onClicked: packageData.updatePackageTriggered(packageData.packageId)
} }