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 cura.UltimakerCloud.UltimakerCloudScope import UltimakerCloudScope # To make requests to the Ultimaker API with correct authorization.
|
||||||
|
|
||||||
from .PackageModel import PackageModel
|
from .PackageModel import PackageModel
|
||||||
from .Constants import USER_PACKAGES_URL
|
from .Constants import USER_PACKAGES_URL, PACKAGES_URL
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from PyQt5.QtCore import QObject
|
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
|
: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:
|
def downloadFinished(reply: "QNetworkReply") -> None:
|
||||||
self._downloadFinished(package_id, reply, update)
|
self._downloadFinished(package_id, reply, update)
|
||||||
|
|
||||||
|
|
|
@ -314,7 +314,6 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
self.setBusy(True)
|
|
||||||
self.uninstallPackageTriggered.emit(self.packageId)
|
self.uninstallPackageTriggered.emit(self.packageId)
|
||||||
|
|
||||||
@pyqtProperty(bool, notify= busyChanged)
|
@pyqtProperty(bool, notify= busyChanged)
|
||||||
|
@ -351,7 +350,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 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)
|
@pyqtProperty(bool, notify = stateManageButtonChanged)
|
||||||
def isActive(self) -> bool:
|
def isActive(self) -> bool:
|
||||||
|
|
|
@ -198,7 +198,7 @@ Item
|
||||||
visible: showManageButtons && (packageData.canDowngrade || !packageData.isBundled)
|
visible: showManageButtons && (packageData.canDowngrade || !packageData.isBundled)
|
||||||
enabled: !packageData.busy
|
enabled: !packageData.busy
|
||||||
busy: packageData.busy
|
busy: packageData.busy
|
||||||
button_style: !packageData.isInstalled
|
button_style: packageData.isInstalled || packageData.isToBeInstalled
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
||||||
text:
|
text:
|
||||||
|
@ -208,7 +208,7 @@ Item
|
||||||
if (busy) { return catalog.i18nc("@button", "Downgrading..."); }
|
if (busy) { return catalog.i18nc("@button", "Downgrading..."); }
|
||||||
else { return catalog.i18nc("@button", "Downgrade"); }
|
else { return catalog.i18nc("@button", "Downgrade"); }
|
||||||
}
|
}
|
||||||
if (!packageData.isInstalled)
|
if (!(packageData.isInstalled || packageData.isToBeInstalled))
|
||||||
{
|
{
|
||||||
if (busy) { return catalog.i18nc("@button", "Installing..."); }
|
if (busy) { return catalog.i18nc("@button", "Installing..."); }
|
||||||
else { return catalog.i18nc("@button", "Install"); }
|
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
|
ManageButton
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue