mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 18:39:07 +08:00
Merge pull request #7089 from Ultimaker/CURA-7207_fix_package_compatibility
CURA-7207_fix_package_compatibility
This commit is contained in:
commit
8ac52e8baa
@ -83,7 +83,7 @@ class CloudPackageChecker(QObject):
|
|||||||
package_discrepancy = list(set(user_subscribed_packages).difference(user_installed_packages))
|
package_discrepancy = list(set(user_subscribed_packages).difference(user_installed_packages))
|
||||||
if package_discrepancy:
|
if package_discrepancy:
|
||||||
self._model.addDiscrepancies(package_discrepancy)
|
self._model.addDiscrepancies(package_discrepancy)
|
||||||
self._model.initialize(subscribed_packages_payload)
|
self._model.initialize(self._package_manager, subscribed_packages_payload)
|
||||||
self._handlePackageDiscrepancies()
|
self._handlePackageDiscrepancies()
|
||||||
|
|
||||||
def _handlePackageDiscrepancies(self) -> None:
|
def _handlePackageDiscrepancies(self) -> None:
|
||||||
|
@ -2,9 +2,12 @@
|
|||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, pyqtProperty, pyqtSlot
|
from PyQt5.QtCore import Qt, pyqtProperty, pyqtSlot
|
||||||
|
|
||||||
|
from UM.PackageManager import PackageManager
|
||||||
from UM.Qt.ListModel import ListModel
|
from UM.Qt.ListModel import ListModel
|
||||||
|
from UM.Version import Version
|
||||||
|
|
||||||
from cura import ApplicationMetadata
|
from cura import ApplicationMetadata
|
||||||
from UM.Logger import Logger
|
|
||||||
from typing import List, Dict, Any
|
from typing import List, Dict, Any
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +49,7 @@ class SubscribedPackagesModel(ListModel):
|
|||||||
def getIncompatiblePackages(self) -> List[str]:
|
def getIncompatiblePackages(self) -> List[str]:
|
||||||
return [package["package_id"] for package in self._items if not package["is_compatible"]]
|
return [package["package_id"] for package in self._items if not package["is_compatible"]]
|
||||||
|
|
||||||
def initialize(self, subscribed_packages_payload: List[Dict[str, Any]]) -> None:
|
def initialize(self, package_manager: PackageManager, subscribed_packages_payload: List[Dict[str, Any]]) -> None:
|
||||||
self._items.clear()
|
self._items.clear()
|
||||||
for item in subscribed_packages_payload:
|
for item in subscribed_packages_payload:
|
||||||
if item["package_id"] not in self._discrepancies:
|
if item["package_id"] not in self._discrepancies:
|
||||||
@ -59,15 +62,13 @@ class SubscribedPackagesModel(ListModel):
|
|||||||
"md5_hash": item["md5_hash"],
|
"md5_hash": item["md5_hash"],
|
||||||
"is_dismissed": False,
|
"is_dismissed": False,
|
||||||
}
|
}
|
||||||
if self._sdk_version not in item["sdk_versions"]:
|
|
||||||
package.update({"is_compatible": False})
|
compatible = any(package_manager.isPackageCompatible(Version(version)) for version in item["sdk_versions"])
|
||||||
else:
|
package.update({"is_compatible": compatible})
|
||||||
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._items.append(package)
|
self._items.append(package)
|
||||||
self.setItems(self._items)
|
self.setItems(self._items)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user