mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 01:07:52 -06:00

There is a distinction between packages which are already installed on the local machine and packages which are available on the remote server. Even with this difference it is important that they are handled the same and can be reused in the same GUI elements. In order to reduce code duplication I created a parent object PackageList which contains the base logic and interface for the QML and let both RemotePackageList and LocalPackageList inherit from this. UX specified that the gear icon (Settings.svg) should be separate from the tabs of material and plugins. This also ment that the current tab item couldn't set the pageTitle anymore. This is now defined in the Package component and set when the loader has loaded the external QML file. Contributes to CURA-8558
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
# Copyright (c) 2021 Ultimaker B.V.
|
|
# Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
from PyQt5.QtCore import pyqtSlot, Qt
|
|
from typing import TYPE_CHECKING
|
|
|
|
from UM.i18n import i18nCatalog
|
|
|
|
from cura.CuraApplication import CuraApplication
|
|
|
|
from .PackageList import PackageList
|
|
from .PackageModel import PackageModel # The contents of this list.
|
|
|
|
if TYPE_CHECKING:
|
|
from PyQt5.QtCore import QObject
|
|
|
|
catalog = i18nCatalog("cura")
|
|
|
|
|
|
class LocalPackageList(PackageList):
|
|
PackageRole = Qt.UserRole + 1
|
|
|
|
def __init__(self, parent: "QObject" = None) -> None:
|
|
super().__init__(parent)
|
|
self._application = CuraApplication.getInstance()
|
|
|
|
@pyqtSlot()
|
|
def updatePackages(self) -> None:
|
|
"""
|
|
Make a request for the first paginated page of packages.
|
|
|
|
When the request is done, the list will get updated with the new package models.
|
|
"""
|
|
self.setErrorMessage("") # Clear any previous errors.
|
|
self.setIsLoading(True)
|
|
self._getLocalPackages()
|
|
|
|
def _getLocalPackages(self) -> None:
|
|
plugin_registry = self._application.getPluginRegistry()
|
|
package_manager = self._application.getPackageManager()
|
|
|
|
bundled = plugin_registry.getInstalledPlugins()
|
|
for b in bundled:
|
|
package = PackageModel({"package_id": b, "display_name": b}, parent = self)
|
|
self.appendItem({"package": package})
|
|
packages = package_manager.getInstalledPackageIDs()
|
|
self.setIsLoading(False)
|
|
self.setHasMore(False)
|