mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 02:07:51 -06:00
Create MaterialsSyncDialog from a Python function
Rather than from the QML. This allows creating this dialogue from a message button without needing to put it in the base application. Contributes to issue CURA-8609.
This commit is contained in:
parent
1c78452d39
commit
9ec731eaf6
3 changed files with 20 additions and 6 deletions
|
@ -10,6 +10,7 @@ import zipfile # To export all materials in a .zip archive.
|
|||
from UM.i18n import i18nCatalog
|
||||
from UM.Logger import Logger
|
||||
from UM.Message import Message
|
||||
from UM.Resources import Resources # To find QML files.
|
||||
from UM.Signal import postponeSignals, CompressTechnique
|
||||
|
||||
import cura.CuraApplication # Imported like this to prevent circular imports.
|
||||
|
@ -28,6 +29,10 @@ class MaterialManagementModel(QObject):
|
|||
:param The base file of the material is provided as parameter when this emits
|
||||
"""
|
||||
|
||||
def __init__(self, parent: QObject = None):
|
||||
super().__init__(parent)
|
||||
self._sync_all_dialog = None # type: Optional[QObject]
|
||||
|
||||
@pyqtSlot("QVariant", result = bool)
|
||||
def canMaterialBeRemoved(self, material_node: "MaterialNode") -> bool:
|
||||
"""Can a certain material be deleted, or is it still in use in one of the container stacks anywhere?
|
||||
|
@ -262,6 +267,18 @@ class MaterialManagementModel(QObject):
|
|||
except ValueError: # Material was not in the favorites list.
|
||||
Logger.log("w", "Material {material_base_file} was already not a favorite material.".format(material_base_file = material_base_file))
|
||||
|
||||
@pyqtSlot()
|
||||
def openSyncAllWindow(self) -> None:
|
||||
"""
|
||||
Opens the window to sync all materials.
|
||||
"""
|
||||
if self._sync_all_dialog is None:
|
||||
qml_path = Resources.getPath(cura.CuraApplication.CuraApplication.ResourceTypes.QmlFiles, "Preferences", "Materials", "MaterialsSyncDialog.qml")
|
||||
self._sync_all_dialog = cura.CuraApplication.CuraApplication.getInstance().createQmlComponent(qml_path, {})
|
||||
if self._sync_all_dialog is None: # Failed to load QML file.
|
||||
return
|
||||
self._sync_all_dialog.show()
|
||||
|
||||
@pyqtSlot(result = QUrl)
|
||||
def getPreferredExportAllPath(self) -> QUrl:
|
||||
"""
|
||||
|
|
|
@ -201,7 +201,7 @@ Item
|
|||
onClicked:
|
||||
{
|
||||
forceActiveFocus();
|
||||
materialsSyncDialog.show();
|
||||
base.materialManagementModel.openSyncAllWindow();
|
||||
}
|
||||
visible: Cura.MachineManager.activeMachine.supportsMaterialExport
|
||||
}
|
||||
|
@ -399,9 +399,4 @@ Item
|
|||
{
|
||||
id: messageDialog
|
||||
}
|
||||
|
||||
MaterialsSyncDialog
|
||||
{
|
||||
id: materialsSyncDialog
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import UM 1.2 as UM
|
|||
Window
|
||||
{
|
||||
id: materialsSyncDialog
|
||||
property variant catalog: UM.I18nCatalog { name: "cura" }
|
||||
|
||||
title: catalog.i18nc("@title:window", "Sync materials with printers")
|
||||
minimumWidth: UM.Theme.getSize("modal_window_minimum").width
|
||||
minimumHeight: UM.Theme.getSize("modal_window_minimum").height
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue