mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 18:27:51 -06:00
Introduced a Manager to centralize plugin/package management
Should have done this from the start. Will move other relevant scattered functions to this type. For now it checks if the restart banner needs to show. Taking into account that a user can toggle between enable and disable without an actual restart. Even with multiple plugins. Contributes to: CURA-8587
This commit is contained in:
parent
a61c3e9eff
commit
6c976bc9b0
4 changed files with 38 additions and 4 deletions
32
plugins/Marketplace/Manager.py
Normal file
32
plugins/Marketplace/Manager.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
# Copyright (c) 2021 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
from typing import Optional
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from UM.PluginRegistry import PluginRegistry
|
||||
|
||||
class Manager(QObject):
|
||||
def __init__(self, parent: Optional[QObject] = None):
|
||||
super().__init__(parent = parent)
|
||||
self._manager: "CuraPackageManager" = CuraApplication.getInstance().getPackageManager()
|
||||
self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry()
|
||||
|
||||
self._manager.installedPackagesChanged.connect(self.checkIfRestartNeeded)
|
||||
self._plugin_registry.hasPluginsEnabledOrDisabledChanged.connect(self.checkIfRestartNeeded)
|
||||
|
||||
self._restart_needed = False
|
||||
|
||||
def checkIfRestartNeeded(self):
|
||||
if self._manager.hasPackagesToRemoveOrInstall or len(self._plugin_registry.getCurrentSessionActivationChangedPlugins()) > 0:
|
||||
self._restart_needed = True
|
||||
else:
|
||||
self._restart_needed = False
|
||||
self.showRestartNotificationChanged.emit()
|
||||
|
||||
showRestartNotificationChanged = pyqtSignal()
|
||||
|
||||
@pyqtProperty(bool, notify = showRestartNotificationChanged)
|
||||
def showRestartNotification(self) -> bool:
|
||||
return self._restart_needed
|
Loading…
Add table
Add a link
Reference in a new issue