diff --git a/plugins/Toolbox/src/CloudSync/LicensePresenter.py b/plugins/Toolbox/src/CloudSync/LicensePresenter.py index f8aaa5c758..bd991a665a 100644 --- a/plugins/Toolbox/src/CloudSync/LicensePresenter.py +++ b/plugins/Toolbox/src/CloudSync/LicensePresenter.py @@ -8,18 +8,20 @@ from UM.Signal import Signal from cura.CuraApplication import CuraApplication from UM.i18n import i18nCatalog - from plugins.Toolbox.src.CloudSync.LicenseModel import LicenseModel +## Call present() to show a licenseDialog for a set of packages +# licenseAnswers emits a list of Dicts containing answers when the user has made a choice for all provided packages class LicensePresenter(QObject): def __init__(self, app: CuraApplication): super().__init__() - self._dialog = None #type: Optional[QObject] + self._dialog = None # type: Optional[QObject] self._package_manager = app.getPackageManager() # type: PackageManager - # Emits # todo - self.license_answers = Signal() + # Emits List[Dict[str, str]] containing for example + # [{ "package_id": "BarbarianPlugin", "package_path" : "/tmp/dg345as", "accepted" : True }] + self.licenseAnswers = Signal() self._current_package_idx = 0 self._package_models = None # type: Optional[Dict] @@ -30,6 +32,7 @@ class LicensePresenter(QObject): self._compatibility_dialog_path = "resources/qml/dialogs/ToolboxLicenseDialog.qml" ## Show a license dialog for multiple packages where users can read a license and accept or decline them + # \param plugin_path: Root directory of the Toolbox plugin # \param packages: Dict[package id, file path] def present(self, plugin_path: str, packages: Dict[str, str]): path = os.path.join(plugin_path, self._compatibility_dialog_path) @@ -87,7 +90,7 @@ class LicensePresenter(QObject): self._present_current_package() else: self._dialog.close() - self.license_answers.emit(self._package_models) + self.licenseAnswers.emit(self._package_models) diff --git a/plugins/Toolbox/src/CloudSync/SyncOrchestrator.py b/plugins/Toolbox/src/CloudSync/SyncOrchestrator.py index 44437fdaa5..ebbc71d0e0 100644 --- a/plugins/Toolbox/src/CloudSync/SyncOrchestrator.py +++ b/plugins/Toolbox/src/CloudSync/SyncOrchestrator.py @@ -20,7 +20,7 @@ from plugins.Toolbox.src.CloudSync.SubscribedPackagesModel import SubscribedPack # - The SyncOrchestrator uses PackageManager to remove local packages the users wants to see removed # - The DownloadPresenter shows a download progress dialog. It emits A tuple of succeeded and failed downloads # - The LicensePresenter extracts licenses from the downloaded packages and presents a license for each package to -# - be installed. It emits the `licenseAnswers` {'packageId' : bool} for accept or declines +# be installed. It emits the `licenseAnswers` {'packageId' : bool} for accept or declines # - The CloudPackageManager removes the declined packages from the account # - The SyncOrchestrator uses PackageManager to install the downloaded packages. # - Bliss / profit / done @@ -28,7 +28,9 @@ class SyncOrchestrator(Extension): def __init__(self, app: CuraApplication): super().__init__() - self._name = "SyncOrchestrator" # Critical to differentiate This PluginObject from the Toolbox + # Differentiate This PluginObject from the Toolbox. self.getId() includes _name. + # getPluginId() will return the same value for The toolbox extension and this one + self._name = "SyncOrchestrator" self._checker = CloudPackageChecker(app) # type: CloudPackageChecker self._checker.discrepancies.connect(self._onDiscrepancies) @@ -39,7 +41,7 @@ class SyncOrchestrator(Extension): self._downloadPresenter = DownloadPresenter(app) # type: DownloadPresenter self._licensePresenter = LicensePresenter(app) # type: LicensePresenter - self._licensePresenter.license_answers.connect(self._onLicenseAnswers) + self._licensePresenter.licenseAnswers.connect(self._onLicenseAnswers) def _onDiscrepancies(self, model: SubscribedPackagesModel): plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId()) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 7ef4a27ceb..c2d21b349c 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -31,6 +31,8 @@ if TYPE_CHECKING: i18n_catalog = i18nCatalog("cura") +# todo Remove license and download dialog, use SyncOrchestrator instead + ## Provides a marketplace for users to download plugins an materials class Toolbox(QObject, Extension): def __init__(self, application: CuraApplication) -> None: