mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Switch between correct states of the un-/installed buttons
Contributes to CURA-8587
This commit is contained in:
parent
0ffaafc8c0
commit
23cc7084c4
3 changed files with 12 additions and 6 deletions
|
@ -19,7 +19,7 @@ from cura.CuraPackageManager import CuraPackageManager
|
|||
from cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope # To make requests to the Ultimaker API with correct authorization.
|
||||
|
||||
from .PackageModel import PackageModel
|
||||
from .Constants import USER_PACKAGES_URL
|
||||
from .Constants import USER_PACKAGES_URL, PACKAGES_URL
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from PyQt5.QtCore import QObject
|
||||
|
@ -195,6 +195,9 @@ class PackageList(ListModel):
|
|||
:param update: A flag if this is download request is an update process
|
||||
"""
|
||||
|
||||
if url == "":
|
||||
url = f"{PACKAGES_URL}/{package_id}/download"
|
||||
|
||||
def downloadFinished(reply: "QNetworkReply") -> None:
|
||||
self._downloadFinished(package_id, reply, update)
|
||||
|
||||
|
|
|
@ -314,7 +314,6 @@ class PackageModel(QObject):
|
|||
|
||||
@pyqtSlot()
|
||||
def uninstall(self):
|
||||
self.setBusy(True)
|
||||
self.uninstallPackageTriggered.emit(self.packageId)
|
||||
|
||||
@pyqtProperty(bool, notify= busyChanged)
|
||||
|
@ -351,7 +350,11 @@ class PackageModel(QObject):
|
|||
|
||||
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
||||
def isInstalled(self) -> bool:
|
||||
return self._package_id in self._package_manager.local_packages_ids
|
||||
return self._package_id in self._package_manager.getAllInstalledPackageIDs()
|
||||
|
||||
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
||||
def isToBeInstalled(self) -> bool:
|
||||
return self._package_id in self._package_manager.getPackagesToInstall()
|
||||
|
||||
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
||||
def isActive(self) -> bool:
|
||||
|
|
|
@ -198,7 +198,7 @@ Item
|
|||
visible: showManageButtons && (packageData.canDowngrade || !packageData.isBundled)
|
||||
enabled: !packageData.busy
|
||||
busy: packageData.busy
|
||||
button_style: !packageData.isInstalled
|
||||
button_style: packageData.isInstalled || packageData.isToBeInstalled
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
text:
|
||||
|
@ -208,7 +208,7 @@ Item
|
|||
if (busy) { return catalog.i18nc("@button", "Downgrading..."); }
|
||||
else { return catalog.i18nc("@button", "Downgrade"); }
|
||||
}
|
||||
if (!packageData.isInstalled)
|
||||
if (!(packageData.isInstalled || packageData.isToBeInstalled))
|
||||
{
|
||||
if (busy) { return catalog.i18nc("@button", "Installing..."); }
|
||||
else { return catalog.i18nc("@button", "Install"); }
|
||||
|
@ -219,7 +219,7 @@ Item
|
|||
}
|
||||
}
|
||||
|
||||
onClicked: packageData.isInstalled ? packageData.uninstall(): packageData.install()
|
||||
onClicked: packageData.isInstalled || packageData.isToBeInstalled ? packageData.uninstall(): packageData.install()
|
||||
}
|
||||
|
||||
ManageButton
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue