diff options
author | Jaime van Kessel <nallath@gmail.com> | 2019-11-08 15:38:58 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2019-11-08 15:38:58 +0300 |
commit | 9940bc8551929910d4b53764a0f7c59f26d7ca05 (patch) | |
tree | 51fc49be2c4216cd9e9b1e0660d48146a57cf39c /plugins | |
parent | 00078fd65939ac2e089099c733228374d71b1cc1 (diff) | |
parent | 832b4f28dc0ce9ac3649d40df4ef7c264d25404e (diff) |
Merge branch 'master' of github.com:Ultimaker/Cura
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/SimulationView/LayerSlider.qml | 3 | ||||
-rw-r--r-- | plugins/Toolbox/src/Toolbox.py | 43 |
2 files changed, 32 insertions, 14 deletions
diff --git a/plugins/SimulationView/LayerSlider.qml b/plugins/SimulationView/LayerSlider.qml index 0c62dd01cf..6f608fe474 100644 --- a/plugins/SimulationView/LayerSlider.qml +++ b/plugins/SimulationView/LayerSlider.qml @@ -165,8 +165,9 @@ Item } onHeightChanged : { - // After a height change, the pixel-position of the lower handle is out of sync with the property value + // After a height change, the pixel-position of the handles is out of sync with the property value setLowerValue(lowerValue) + setUpperValue(upperValue) } // Upper handle diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index c8c809cc82..27197275b8 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -48,7 +48,7 @@ class Toolbox(QObject, Extension): self._download_progress = 0 # type: float self._is_downloading = False # type: bool self._network_manager = None # type: Optional[QNetworkAccessManager] - self._request_headers = [] # type: List[Tuple[bytes, bytes]] + self._request_headers = [] # type: List[Tuple[bytes, bytes]] self._updateRequestHeader() self._request_urls = {} # type: Dict[str, QUrl] @@ -59,13 +59,15 @@ class Toolbox(QObject, Extension): # The responses as given by the server parsed to a list. self._server_response_data = { "authors": [], - "packages": [] + "packages": [], + "updates": [], } # type: Dict[str, List[Any]] # Models: self._models = { "authors": AuthorsModel(self), "packages": PackagesModel(self), + "updates": PackagesModel(self), } # type: Dict[str, Union[AuthorsModel, PackagesModel]] self._plugins_showcase_model = PackagesModel(self) @@ -195,21 +197,27 @@ class Toolbox(QObject, Extension): cloud_api_version = self._cloud_api_version, sdk_version = self._sdk_version ) + + # We need to construct a query like installed_packages=ID:VERSION&installed_packages=ID:VERSION, etc. + installed_package_ids_with_versions = [":".join(items) for items in + self._package_manager.getAllInstalledPackageIdsAndVersions()] + installed_packages_query = "&installed_packages=".join(installed_package_ids_with_versions) + self._request_urls = { "authors": QUrl("{base_url}/authors".format(base_url = self._api_url)), - "packages": QUrl("{base_url}/packages".format(base_url = self._api_url)) + "packages": QUrl("{base_url}/packages".format(base_url = self._api_url)), + "updates": QUrl("{base_url}/packages/package-updates?installed_packages={query}".format( + base_url = self._api_url, query = installed_packages_query)) } self._application.getCuraAPI().account.loginStateChanged.connect(self._restart) - if CuraApplication.getInstance().getPreferences().getValue("info/automatic_update_check"): + # On boot we check which packages have updates. + if CuraApplication.getInstance().getPreferences().getValue("info/automatic_update_check") and len(installed_package_ids_with_versions) > 0: # Request the latest and greatest! - self._fetchPackageData() + self._fetchPackageUpdates() - def _fetchPackageData(self): - # Create the network manager: - # This was formerly its own function but really had no reason to be as - # it was never called more than once ever. + def _prepareNetworkManager(self): if self._network_manager is not None: self._network_manager.finished.disconnect(self._onRequestFinished) self._network_manager.networkAccessibleChanged.disconnect(self._onNetworkAccessibleChanged) @@ -217,10 +225,15 @@ class Toolbox(QObject, Extension): self._network_manager.finished.connect(self._onRequestFinished) self._network_manager.networkAccessibleChanged.connect(self._onNetworkAccessibleChanged) + def _fetchPackageUpdates(self): + self._prepareNetworkManager() + self._makeRequestByType("updates") + + def _fetchPackageData(self): + self._prepareNetworkManager() # Make remote requests: self._makeRequestByType("packages") self._makeRequestByType("authors") - # Gather installed packages: self._updateInstalledModels() @@ -248,7 +261,7 @@ class Toolbox(QObject, Extension): if not plugin_path: return None path = os.path.join(plugin_path, "resources", "qml", qml_name) - + dialog = self._application.createQmlComponent(path, {"toolbox": self}) if not dialog: raise Exception("Failed to create Marketplace dialog") @@ -632,7 +645,7 @@ class Toolbox(QObject, Extension): if not self._models[response_type]: Logger.log("e", "Could not find the %s model.", response_type) break - + self._server_response_data[response_type] = json_data["data"] self._models[response_type].setMetadata(self._server_response_data[response_type]) @@ -644,6 +657,10 @@ class Toolbox(QObject, Extension): elif response_type == "authors": self._models[response_type].setFilter({"package_types": "material"}) self._models[response_type].setFilter({"tags": "generic"}) + elif response_type == "updates": + # Tell the package manager that there's a new set of updates available. + packages = set([pkg["package_id"] for pkg in self._server_response_data[response_type]]) + self._package_manager.setPackagesWithUpdate(packages) self.metadataChanged.emit() @@ -674,7 +691,7 @@ class Toolbox(QObject, Extension): self.setIsDownloading(False) self._download_reply = cast(QNetworkReply, self._download_reply) self._download_reply.downloadProgress.disconnect(self._onDownloadProgress) - + # Check if the download was sucessfull if self._download_reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200: try: |