mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
Show Install and Update buttons in the correct scenario's
Contributes to: CURA-8587
This commit is contained in:
parent
8708fd0f3a
commit
7734bf5169
2 changed files with 14 additions and 19 deletions
|
@ -64,8 +64,6 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
self._is_installing = False
|
self._is_installing = False
|
||||||
self._install_status_changing = False
|
self._install_status_changing = False
|
||||||
self._is_recently_installed = False
|
|
||||||
self._is_recently_updated = False
|
|
||||||
|
|
||||||
self._can_update = False
|
self._can_update = False
|
||||||
self._is_updating = False
|
self._is_updating = False
|
||||||
|
@ -93,10 +91,8 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
def finished_installed(is_updating):
|
def finished_installed(is_updating):
|
||||||
if is_updating:
|
if is_updating:
|
||||||
self._is_recently_installed = True
|
|
||||||
self.setIsUpdating(False)
|
self.setIsUpdating(False)
|
||||||
else:
|
else:
|
||||||
self._is_recently_updated
|
|
||||||
self.setIsInstalling(False)
|
self.setIsInstalling(False)
|
||||||
|
|
||||||
self.isRecentlyInstalledChanged.connect(finished_installed)
|
self.isRecentlyInstalledChanged.connect(finished_installed)
|
||||||
|
@ -362,7 +358,11 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
||||||
def isInstalled(self) -> bool:
|
def isInstalled(self) -> bool:
|
||||||
return self._package_id in CuraApplication.getInstance().getPackageManager().getPackagesToInstall()
|
return self._package_id in CuraApplication.getInstance().getPackageManager().local_packages
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
||||||
|
def isRecentlyInstalled(self) -> bool:
|
||||||
|
return self._package_id in CuraApplication.getInstance().getPackageManager().getPackagesToInstall() or self._package_id in CuraApplication.getInstance().getPackageManager().getPackagesToRemove()
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
||||||
def isUninstalled(self) -> bool:
|
def isUninstalled(self) -> bool:
|
||||||
|
@ -389,14 +389,9 @@ class PackageModel(QObject):
|
||||||
def isUpdating(self):
|
def isUpdating(self):
|
||||||
return self._is_updating
|
return self._is_updating
|
||||||
|
|
||||||
def setIsUpdated(self, value):
|
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
||||||
if value != self._is_recently_updated:
|
def isRecentlyUpdated(self):
|
||||||
self._is_recently_updated = value
|
return self._package_id in CuraApplication.getInstance().getPackageManager().getPackagesToInstall() and self._package_id in CuraApplication.getInstance().getPackageManager().getPackagesToRemove()
|
||||||
self.stateManageButtonChanged.emit()
|
|
||||||
|
|
||||||
@pyqtProperty(bool, fset = setIsUpdated, notify = stateManageButtonChanged)
|
|
||||||
def isUpdated(self):
|
|
||||||
return self._is_recently_updated
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def can_update(self) -> bool:
|
def can_update(self) -> bool:
|
||||||
|
|
|
@ -181,7 +181,7 @@ Item
|
||||||
ManageButton
|
ManageButton
|
||||||
{
|
{
|
||||||
id: enableManageButton
|
id: enableManageButton
|
||||||
visible: showManageButtons && !(installManageButton.confirmed || updateManageButton.confirmed)
|
visible: showManageButtons && packageData.isInstalled && !(installManageButton.confirmed || updateManageButton.confirmed)
|
||||||
enabled: !(installManageButton.busy || updateManageButton.busy)
|
enabled: !(installManageButton.busy || updateManageButton.busy)
|
||||||
|
|
||||||
busy: false
|
busy: false
|
||||||
|
@ -208,12 +208,12 @@ Item
|
||||||
ManageButton
|
ManageButton
|
||||||
{
|
{
|
||||||
id: installManageButton
|
id: installManageButton
|
||||||
visible: (showManageButtons || confirmed) && ((packageData.isBundled && packageData.canDowngrade) || !packageData.isBundled || !updateManageButton.confirmed)
|
visible: (showManageButtons || confirmed) && ((packageData.isBundled && packageData.canDowngrade) || !packageData.isBundled) && !updateManageButton.confirmed
|
||||||
|
|
||||||
enabled: !packageData.isUpdating
|
enabled: !packageData.isUpdating
|
||||||
|
|
||||||
busy: packageData.isInstalling
|
busy: packageData.isInstalling
|
||||||
confirmed: packageData.isInstalled || packageData.isUninstalled
|
confirmed: packageData.isRecentlyInstalled
|
||||||
|
|
||||||
button_style: packageData.stateManageInstallButton
|
button_style: packageData.stateManageInstallButton
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
@ -223,7 +223,7 @@ Item
|
||||||
if (packageData.stateManageInstallButton)
|
if (packageData.stateManageInstallButton)
|
||||||
{
|
{
|
||||||
if (packageData.isInstalling) { return catalog.i18nc("@button", "Installing..."); }
|
if (packageData.isInstalling) { return catalog.i18nc("@button", "Installing..."); }
|
||||||
else if (packageData.isInstalled) { return catalog.i18nc("@button", "Installed"); }
|
else if (packageData.isRecentlyInstalled) { return catalog.i18nc("@button", "Installed"); }
|
||||||
else { return catalog.i18nc("@button", "Install"); }
|
else { return catalog.i18nc("@button", "Install"); }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -254,7 +254,7 @@ Item
|
||||||
enabled: !installManageButton.busy
|
enabled: !installManageButton.busy
|
||||||
|
|
||||||
busy: packageData.isUpdating
|
busy: packageData.isUpdating
|
||||||
confirmed: packageData.isUpdated
|
confirmed: packageData.isRecentlyUpdated
|
||||||
|
|
||||||
button_style: true
|
button_style: true
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
@ -262,7 +262,7 @@ Item
|
||||||
text:
|
text:
|
||||||
{
|
{
|
||||||
if (packageData.isUpdating) { return catalog.i18nc("@button", "Updating..."); }
|
if (packageData.isUpdating) { return catalog.i18nc("@button", "Updating..."); }
|
||||||
else if (packageData.isUpdated) { return catalog.i18nc("@button", "Updated"); }
|
else if (packageData.isRecentlyUpdated) { return catalog.i18nc("@button", "Updated"); }
|
||||||
else { return catalog.i18nc("@button", "Update"); }
|
else { return catalog.i18nc("@button", "Update"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue