From 0fefe85fca7518d4fa22992511d884d02e40ac28 Mon Sep 17 00:00:00 2001 From: Jelle Spijker Date: Tue, 7 Dec 2021 08:57:49 +0100 Subject: [PATCH] Present restart banner if plugin has been en-/disabled Contributes to: CURA-8587 --- plugins/Marketplace/Marketplace.py | 15 +++++++++------ plugins/Marketplace/resources/qml/Marketplace.qml | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/Marketplace/Marketplace.py b/plugins/Marketplace/Marketplace.py index 89ad986920..228ee1e506 100644 --- a/plugins/Marketplace/Marketplace.py +++ b/plugins/Marketplace/Marketplace.py @@ -2,7 +2,7 @@ # Cura is released under the terms of the LGPLv3 or higher. import os.path -from PyQt5.QtCore import pyqtSlot +from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject from PyQt5.QtQml import qmlRegisterType from typing import Optional, TYPE_CHECKING @@ -18,14 +18,16 @@ if TYPE_CHECKING: from PyQt5.QtCore import QObject -class Marketplace(Extension): +class Marketplace(Extension, QObject): """ The main managing object for the Marketplace plug-in. """ - def __init__(self) -> None: - super().__init__() - self._window: Optional["QObject"] = None # If the window has been loaded yet, it'll be cached in here. + def __init__(self, parent: Optional[QObject] = None) -> None: + QObject.__init__(self, parent = parent) + Extension.__init__(self) + self._window: Optional[QObject] = None # If the window has been loaded yet, it'll be cached in here. + self.plugin_registry: Optional[PluginRegistry] = None qmlRegisterType(RemotePackageList, "Marketplace", 1, 0, "RemotePackageList") qmlRegisterType(LocalPackageList, "Marketplace", 1, 0, "LocalPackageList") @@ -38,11 +40,12 @@ class Marketplace(Extension): If the window hadn't been loaded yet into Qt, it will be created lazily. """ if self._window is None: + self.plugin_registry = PluginRegistry.getInstance() plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId()) if plugin_path is None: plugin_path = os.path.dirname(__file__) path = os.path.join(plugin_path, "resources", "qml", "Marketplace.qml") - self._window = CuraApplication.getInstance().createQmlComponent(path, {}) + self._window = CuraApplication.getInstance().createQmlComponent(path, {"plugin_registry": self.plugin_registry}) if self._window is None: # Still None? Failed to load the QML then. return self._window.show() diff --git a/plugins/Marketplace/resources/qml/Marketplace.qml b/plugins/Marketplace/resources/qml/Marketplace.qml index cde33faa97..5c56b0c41d 100644 --- a/plugins/Marketplace/resources/qml/Marketplace.qml +++ b/plugins/Marketplace/resources/qml/Marketplace.qml @@ -232,7 +232,7 @@ Window { height: quitButton.height + 2 * UM.Theme.getSize("default_margin").width color: UM.Theme.getColor("primary") - visible: CuraApplication.getPackageManager().hasPackagesToRemoveOrInstall + visible: CuraApplication.getPackageManager().hasPackagesToRemoveOrInstall || plugin_registry.hasPluginsEnabledOrDisabled anchors { left: parent.left