mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 03:07:53 -06:00
CURA-5296 Added "canDowngrade" functionality
Shows "Downgrade" instead of "Uninstall" for bundled packages with an upgrade installed.
This commit is contained in:
parent
fea37b52be
commit
0b0fb4cd2f
3 changed files with 23 additions and 3 deletions
|
@ -10,7 +10,6 @@ Item
|
|||
{
|
||||
height: UM.Theme.getSize("toolbox_installed_tile").height
|
||||
width: parent.width
|
||||
property bool canUpdate: false
|
||||
property bool isEnabled: true
|
||||
|
||||
Rectangle
|
||||
|
@ -109,7 +108,6 @@ Item
|
|||
{
|
||||
target: toolbox
|
||||
onEnabledChanged: isEnabled = toolbox.isEnabled(model.id)
|
||||
onMetadataChanged: canUpdate = toolbox.canUpdate(model.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import UM 1.1 as UM
|
|||
|
||||
Column
|
||||
{
|
||||
property bool canUpdate: false
|
||||
property bool canDowngrade: false
|
||||
width: UM.Theme.getSize("toolbox_action_button").width
|
||||
spacing: UM.Theme.getSize("narrow_margin").height
|
||||
|
||||
|
@ -36,7 +38,7 @@ Column
|
|||
Button
|
||||
{
|
||||
id: removeButton
|
||||
text: catalog.i18nc("@action:button", "Uninstall")
|
||||
text: canDowngrade ? catalog.i18nc("@action:button", "Downgrade") : catalog.i18nc("@action:button", "Uninstall")
|
||||
visible: !model.is_bundled
|
||||
enabled: !toolbox.isDownloading
|
||||
style: ButtonStyle
|
||||
|
@ -72,5 +74,11 @@ Column
|
|||
}
|
||||
}
|
||||
onClicked: toolbox.uninstall(model.id)
|
||||
Connections
|
||||
{
|
||||
target: toolbox
|
||||
onMetadataChanged: canUpdate = toolbox.canUpdate(model.id)
|
||||
onMetadataChanged: canDowngrade = toolbox.canDowngrade(model.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,6 +300,20 @@ class Toolbox(QObject, Extension):
|
|||
remote_version = Version(remote_package["package_version"])
|
||||
return remote_version > local_version
|
||||
|
||||
@pyqtSlot(str, result=bool)
|
||||
def canDowngrade(self, package_id: str) -> bool:
|
||||
local_package = self._package_manager.getInstalledPackageInfo(package_id)
|
||||
if local_package is None:
|
||||
return False
|
||||
|
||||
remote_package = self.getRemotePackage(package_id)
|
||||
if remote_package is None:
|
||||
return False
|
||||
|
||||
local_version = Version(local_package["package_version"])
|
||||
remote_version = Version(remote_package["package_version"])
|
||||
return remote_version < local_version
|
||||
|
||||
@pyqtSlot(str, result = bool)
|
||||
def isInstalled(self, package_id: str) -> bool:
|
||||
return self._package_manager.isPackageInstalled(package_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue