mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-18 05:25:56 +08:00
Merge RestartManager into marketplace
CURA-8588
This commit is contained in:
parent
6af2677c52
commit
6a39862349
@ -13,7 +13,6 @@ from UM.PluginRegistry import PluginRegistry # To find out where we are stored
|
|||||||
|
|
||||||
from .RemotePackageList import RemotePackageList # To register this type with QML.
|
from .RemotePackageList import RemotePackageList # To register this type with QML.
|
||||||
from .LocalPackageList import LocalPackageList # To register this type with QML.
|
from .LocalPackageList import LocalPackageList # To register this type with QML.
|
||||||
from .RestartManager import RestartManager # To register this type with QML.
|
|
||||||
|
|
||||||
|
|
||||||
class Marketplace(Extension, QObject):
|
class Marketplace(Extension, QObject):
|
||||||
@ -36,9 +35,10 @@ class Marketplace(Extension, QObject):
|
|||||||
self._local_package_list = LocalPackageList(self)
|
self._local_package_list = LocalPackageList(self)
|
||||||
self._local_package_list.checkForUpdates(self._package_manager.local_packages)
|
self._local_package_list.checkForUpdates(self._package_manager.local_packages)
|
||||||
|
|
||||||
self._tab_shown: int = 0
|
self._package_manager.installedPackagesChanged.connect(self.checkIfRestartNeeded)
|
||||||
|
|
||||||
qmlRegisterType(RestartManager, "Marketplace", 1, 0, "RestartManager")
|
self._tab_shown: int = 0
|
||||||
|
self._restart_needed = False
|
||||||
|
|
||||||
def getTabShown(self) -> int:
|
def getTabShown(self) -> int:
|
||||||
return self._tab_shown
|
return self._tab_shown
|
||||||
@ -79,6 +79,7 @@ class Marketplace(Extension, QObject):
|
|||||||
"""
|
"""
|
||||||
if self._window is None:
|
if self._window is None:
|
||||||
self._plugin_registry = PluginRegistry.getInstance()
|
self._plugin_registry = PluginRegistry.getInstance()
|
||||||
|
self._plugin_registry.pluginsEnabledOrDisabledChanged.connect(self.checkIfRestartNeeded)
|
||||||
plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId())
|
plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId())
|
||||||
if plugin_path is None:
|
if plugin_path is None:
|
||||||
plugin_path = os.path.dirname(__file__)
|
plugin_path = os.path.dirname(__file__)
|
||||||
@ -97,3 +98,17 @@ class Marketplace(Extension, QObject):
|
|||||||
Not implemented in a more generic way because it needs the ability to be called with 'callExtensionMethod'.
|
Not implemented in a more generic way because it needs the ability to be called with 'callExtensionMethod'.
|
||||||
"""
|
"""
|
||||||
self.setTabShown(1)
|
self.setTabShown(1)
|
||||||
|
|
||||||
|
def checkIfRestartNeeded(self) -> None:
|
||||||
|
if self._package_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
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
# Copyright (c) 2021 Ultimaker B.V.
|
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
|
||||||
from typing import Optional, TYPE_CHECKING
|
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, QObject
|
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from UM.PluginRegistry import PluginRegistry
|
|
||||||
from cura.CuraPackageManager import CuraPackageManager
|
|
||||||
|
|
||||||
|
|
||||||
class RestartManager(QObject):
|
|
||||||
def __init__(self, parent: Optional[QObject] = None) -> 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.pluginsEnabledOrDisabledChanged.connect(self.checkIfRestartNeeded)
|
|
||||||
|
|
||||||
self._restart_needed = False
|
|
||||||
|
|
||||||
def checkIfRestartNeeded(self) -> None:
|
|
||||||
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
|
|
@ -4,7 +4,6 @@ import QtQuick 2.15
|
|||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
import Marketplace 1.0 as Marketplace
|
|
||||||
import UM 1.4 as UM
|
import UM 1.4 as UM
|
||||||
|
|
||||||
Packages
|
Packages
|
||||||
|
@ -8,13 +8,11 @@ import QtQuick.Window 2.2
|
|||||||
|
|
||||||
import UM 1.2 as UM
|
import UM 1.2 as UM
|
||||||
import Cura 1.6 as Cura
|
import Cura 1.6 as Cura
|
||||||
import Marketplace 1.0 as Marketplace
|
|
||||||
|
|
||||||
Window
|
Window
|
||||||
{
|
{
|
||||||
id: marketplaceDialog
|
id: marketplaceDialog
|
||||||
property variant catalog: UM.I18nCatalog { name: "cura" }
|
property variant catalog: UM.I18nCatalog { name: "cura" }
|
||||||
property variant restartManager: Marketplace.RestartManager { }
|
|
||||||
|
|
||||||
signal searchStringChanged(string new_search)
|
signal searchStringChanged(string new_search)
|
||||||
|
|
||||||
@ -235,7 +233,7 @@ Window
|
|||||||
{
|
{
|
||||||
height: quitButton.height + 2 * UM.Theme.getSize("default_margin").width
|
height: quitButton.height + 2 * UM.Theme.getSize("default_margin").width
|
||||||
color: UM.Theme.getColor("primary")
|
color: UM.Theme.getColor("primary")
|
||||||
visible: restartManager.showRestartNotification
|
visible: manager.showRestartNotification
|
||||||
anchors
|
anchors
|
||||||
{
|
{
|
||||||
left: parent.left
|
left: parent.left
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2021 Ultimaker B.V.
|
// Copyright (c) 2021 Ultimaker B.V.
|
||||||
// Cura is released under the terms of the LGPLv3 or higher.
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import Marketplace 1.0 as Marketplace
|
|
||||||
import UM 1.4 as UM
|
import UM 1.4 as UM
|
||||||
|
|
||||||
Packages
|
Packages
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2021 Ultimaker B.V.
|
// Copyright (c) 2021 Ultimaker B.V.
|
||||||
// Cura is released under the terms of the LGPLv3 or higher.
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import Marketplace 1.0 as Marketplace
|
|
||||||
import UM 1.4 as UM
|
import UM 1.4 as UM
|
||||||
|
|
||||||
Packages
|
Packages
|
||||||
|
Loading…
x
Reference in New Issue
Block a user