mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-24 05:29:12 +08:00
Plugin browser now shows difference between new & upgradable plugins
CURA-3856
This commit is contained in:
parent
b2a21f0443
commit
68663b2789
@ -124,6 +124,7 @@ class PluginBrowser(QObject, Extension):
|
||||
self._plugins_model.addRoleName(Qt.UserRole + 4, "author")
|
||||
self._plugins_model.addRoleName(Qt.UserRole + 5, "already_installed")
|
||||
self._plugins_model.addRoleName(Qt.UserRole + 6, "file_location")
|
||||
self._plugins_model.addRoleName(Qt.UserRole + 7, "can_upgrade")
|
||||
else:
|
||||
self._plugins_model.clear()
|
||||
items = []
|
||||
@ -134,22 +135,30 @@ class PluginBrowser(QObject, Extension):
|
||||
"short_description": metadata["short_description"],
|
||||
"author": metadata["author"],
|
||||
"already_installed": self._checkAlreadyInstalled(metadata["id"], metadata["version"]),
|
||||
"file_location": metadata["file_location"]
|
||||
"file_location": metadata["file_location"],
|
||||
"can_upgrade": self._checkCanUpgrade(metadata["id"], metadata["version"])
|
||||
})
|
||||
print(items)
|
||||
self._plugins_model.setItems(items)
|
||||
return self._plugins_model
|
||||
|
||||
def _checkAlreadyInstalled(self, id, version):
|
||||
def _checkCanUpgrade(self, id, version):
|
||||
plugin_registry = PluginRegistry.getInstance()
|
||||
metadata = plugin_registry.getMetaData(id)
|
||||
if metadata != {}:
|
||||
current_version = Version(metadata["plugin"]["version"])
|
||||
new_version = Version(version)
|
||||
if new_version > current_version:
|
||||
return False
|
||||
return True
|
||||
return False
|
||||
|
||||
def _checkAlreadyInstalled(self, id, version):
|
||||
plugin_registry = PluginRegistry.getInstance()
|
||||
metadata = plugin_registry.getMetaData(id)
|
||||
if metadata != {}:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
|
||||
def _onRequestFinished(self, reply):
|
||||
reply_url = reply.url().toString()
|
||||
|
@ -59,14 +59,13 @@ UM.Dialog
|
||||
text: model.name
|
||||
width: contentWidth
|
||||
}
|
||||
|
||||
}
|
||||
Button
|
||||
{
|
||||
text: !model.already_installed ? "Download" : "Already Installed"
|
||||
text: !model.already_installed ? "Download" : model.can_upgrade ? "Upgrade" : "Download"
|
||||
onClicked: manager.downloadAndInstallPlugin(model.file_location)
|
||||
anchors.right: parent.right
|
||||
enabled: !model.already_installed && !manager.isDownloading
|
||||
enabled: (!model.already_installed || model.can_upgrade) && !manager.isDownloading
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user