mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 19:28:07 -06:00
Reworked the flow to show only not installed packages for installing in the Compatibility Dialog
CURA-7038
This commit is contained in:
parent
4375118a9f
commit
12be21e594
2 changed files with 13 additions and 11 deletions
|
@ -55,7 +55,7 @@ Rectangle
|
||||||
}
|
}
|
||||||
Text{
|
Text{
|
||||||
id: packageName
|
id: packageName
|
||||||
text: model.name
|
text: model.name + " (Compatible: " + model.is_compatible + ")"
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
}
|
}
|
||||||
MouseArea{
|
MouseArea{
|
||||||
|
|
|
@ -702,12 +702,13 @@ class Toolbox(QObject, Extension):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _checkCompatibilities(self, json_data):
|
def _checkCompatibilities(self, json_data):
|
||||||
user_subscribed_list = [plugin["package_id"] for plugin in json_data]
|
user_subscribed_packages = [plugin["package_id"] for plugin in json_data]
|
||||||
user_installed_packages = self._package_manager.getUserInstalledPackages()
|
user_installed_packages = self._package_manager.getUserInstalledPackages()
|
||||||
|
|
||||||
# We check if there are packages installed in Cloud Marketplace but not in Cura marketplace
|
# We check if there are packages installed in Cloud Marketplace but not in Cura marketplace (discrepancy)
|
||||||
if list(set(user_subscribed_list).difference(user_installed_packages)):
|
package_discrepancy = list(set(user_subscribed_packages).difference(user_installed_packages))
|
||||||
Logger.log("d", "Mismatch found between Cloud subscribed packages and Cura installed packages")
|
if package_discrepancy:
|
||||||
|
Logger.log("d", "Discrepancy found between Cloud subscribed packages and Cura installed packages")
|
||||||
sync_message = Message(i18n_catalog.i18nc(
|
sync_message = Message(i18n_catalog.i18nc(
|
||||||
"@info:generic",
|
"@info:generic",
|
||||||
"\nDo you want to sync material and software packages with your account?"),
|
"\nDo you want to sync material and software packages with your account?"),
|
||||||
|
@ -719,27 +720,28 @@ class Toolbox(QObject, Extension):
|
||||||
description="Sync your Cloud subscribed packages to your local environment.",
|
description="Sync your Cloud subscribed packages to your local environment.",
|
||||||
button_align=Message.ActionButtonAlignment.ALIGN_RIGHT)
|
button_align=Message.ActionButtonAlignment.ALIGN_RIGHT)
|
||||||
|
|
||||||
self._onSyncButtonClickedHelper = functools.partial(self._onSyncButtonClicked, json_data)
|
self._onSyncButtonClickedHelper = functools.partial(self._onSyncButtonClicked, json_data, package_discrepancy)
|
||||||
sync_message.actionTriggered.connect(self._onSyncButtonClickedHelper)
|
sync_message.actionTriggered.connect(self._onSyncButtonClickedHelper)
|
||||||
sync_message.show()
|
sync_message.show()
|
||||||
|
|
||||||
def _onSyncButtonClicked(self, json_data, messageId: str, actionId: str) -> None:
|
def _onSyncButtonClicked(self, json_data, package_discrepancy, messageId: str, actionId: str) -> None:
|
||||||
self.subscribed_packages.clear()
|
# self.subscribed_packages.clear()
|
||||||
# We create the packages from the HTTP payload
|
# We 'create' the packages from the HTTP payload
|
||||||
for item in json_data:
|
for item in json_data:
|
||||||
|
if item["package_id"] not in package_discrepancy: # But we skip packages that the user has locally installed
|
||||||
|
continue
|
||||||
package = {"name": item["package_id"], "sdk_versions": item["sdk_versions"]}
|
package = {"name": item["package_id"], "sdk_versions": item["sdk_versions"]}
|
||||||
|
|
||||||
if self._sdk_version not in item["sdk_versions"]:
|
if self._sdk_version not in item["sdk_versions"]:
|
||||||
package.update({"is_compatible": False})
|
package.update({"is_compatible": False})
|
||||||
else:
|
else:
|
||||||
package.update({"is_compatible": True})
|
package.update({"is_compatible": True})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
package.update({"icon_url": item["icon_url"]})
|
package.update({"icon_url": item["icon_url"]})
|
||||||
except KeyError: # There is no 'icon_url" in the response payload for this package
|
except KeyError: # There is no 'icon_url" in the response payload for this package
|
||||||
package.update({"icon_url": ""})
|
package.update({"icon_url": ""})
|
||||||
|
|
||||||
self.subscribed_packages.append(package)
|
self.subscribed_packages.append(package)
|
||||||
|
Logger.log("d", "Package '{}' scheduled for installing.".format(package['name']))
|
||||||
self._models["subscribed_packages"].update()
|
self._models["subscribed_packages"].update()
|
||||||
|
|
||||||
compatibilityDialog = "resources/qml/dialogs/CompatibilityDialog.qml"
|
compatibilityDialog = "resources/qml/dialogs/CompatibilityDialog.qml"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue