mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Create InstallMissingPackageDialog with newly-exposed function from Marketplace
This adds a new function to the API of the Marketplace plug-in. It's not pretty, but it's going to be how it is for a while. Done to fix a critical build issue. The 'import plugins' thing works from source but not on the build.
This commit is contained in:
parent
de8a58f0d7
commit
0f12b012cf
2 changed files with 29 additions and 14 deletions
|
@ -1,19 +1,20 @@
|
||||||
# Copyright (c) 2020 Ultimaker B.V.
|
# Copyright (c) 2022 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.
|
||||||
from typing import List, Optional, Dict, cast
|
|
||||||
|
|
||||||
from PyQt6.QtCore import pyqtSignal, QObject, pyqtProperty, QCoreApplication, QUrl
|
from PyQt6.QtCore import pyqtSignal, QObject, pyqtProperty, QCoreApplication, QUrl
|
||||||
from PyQt6.QtGui import QDesktopServices
|
from PyQt6.QtGui import QDesktopServices
|
||||||
|
from typing import List, Optional, Dict, cast
|
||||||
|
|
||||||
from UM.FlameProfiler import pyqtSlot
|
|
||||||
from UM.PluginRegistry import PluginRegistry
|
|
||||||
from UM.Application import Application
|
|
||||||
from UM.i18n import i18nCatalog
|
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
|
||||||
from cura.Settings.GlobalStack import GlobalStack
|
from cura.Settings.GlobalStack import GlobalStack
|
||||||
from plugins.Marketplace.InstallMissingPackagesDialog import InstallMissingPackageDialog
|
from UM.Application import Application
|
||||||
from .UpdatableMachinesModel import UpdatableMachinesModel
|
from UM.FlameProfiler import pyqtSlot
|
||||||
|
from UM.i18n import i18nCatalog
|
||||||
|
from UM.Logger import Logger
|
||||||
from UM.Message import Message
|
from UM.Message import Message
|
||||||
|
from UM.PluginRegistry import PluginRegistry
|
||||||
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
|
|
||||||
|
from .UpdatableMachinesModel import UpdatableMachinesModel
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
@ -292,8 +293,10 @@ class WorkspaceDialog(QObject):
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def installMissingPackages(self) -> None:
|
def installMissingPackages(self) -> None:
|
||||||
self._install_missing_package_dialog = InstallMissingPackageDialog(self._missing_package_metadata, self.showMissingMaterialsWarning)
|
marketplace_plugin = PluginRegistry.getInstance().getPluginObject("Marketplace")
|
||||||
self._install_missing_package_dialog.show()
|
if not marketplace_plugin:
|
||||||
|
Logger.warning("Could not show dialog to install missing plug-ins. Is Marketplace plug-in not available?")
|
||||||
|
marketplace_plugin.showInstallMissingPackageDialog(self._missing_package_metadata, self.showMissingMaterialsWarning) # type: ignore
|
||||||
|
|
||||||
def getResult(self) -> Dict[str, Optional[str]]:
|
def getResult(self) -> Dict[str, Optional[str]]:
|
||||||
if "machine" in self._result and self.updatableMachinesModel.count <= 1:
|
if "machine" in self._result and self.updatableMachinesModel.count <= 1:
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
from PyQt6.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
from PyQt6.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
||||||
from typing import Optional, cast
|
from typing import Callable, cast, Dict, List, Optional
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication # Creating QML objects and managing packages.
|
from cura.CuraApplication import CuraApplication # Creating QML objects and managing packages.
|
||||||
|
|
||||||
from UM.Extension import Extension # We are implementing the main object of an extension here.
|
from UM.Extension import Extension # We are implementing the main object of an extension here.
|
||||||
from UM.PluginRegistry import PluginRegistry # To find out where we are stored (the proper way).
|
from UM.PluginRegistry import PluginRegistry # To find out where we are stored (the proper way).
|
||||||
|
|
||||||
from .RemotePackageList import RemotePackageList # To register this type with QML.
|
from .InstallMissingPackagesDialog import InstallMissingPackageDialog # To allow creating this dialogue from outside of the plug-in.
|
||||||
from .LocalPackageList import LocalPackageList # To register this type with QML.
|
from .LocalPackageList import LocalPackageList # To register this type with QML.
|
||||||
|
from .RemotePackageList import RemotePackageList # To register this type with QML.
|
||||||
|
|
||||||
|
|
||||||
class Marketplace(Extension, QObject):
|
class Marketplace(Extension, QObject):
|
||||||
|
@ -118,3 +118,15 @@ class Marketplace(Extension, QObject):
|
||||||
@pyqtProperty(bool, notify=showRestartNotificationChanged)
|
@pyqtProperty(bool, notify=showRestartNotificationChanged)
|
||||||
def showRestartNotification(self) -> bool:
|
def showRestartNotification(self) -> bool:
|
||||||
return self._restart_needed
|
return self._restart_needed
|
||||||
|
|
||||||
|
def showInstallMissingPackageDialog(self, packages_metadata: List[Dict[str, str]], ignore_warning_callback: Callable[[], None]) -> None:
|
||||||
|
"""
|
||||||
|
Show a dialog that prompts the user to install certain packages.
|
||||||
|
|
||||||
|
The dialog is worded for packages that are missing and required for a certain operation.
|
||||||
|
:param packages_metadata: The metadata of the packages that are missing.
|
||||||
|
:param ignore_warning_callback: A callback that gets executed when the user ignores the pop-up, to show them a
|
||||||
|
warning.
|
||||||
|
"""
|
||||||
|
dialog = InstallMissingPackageDialog(packages_metadata, ignore_warning_callback)
|
||||||
|
dialog.show()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue