diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index a8cb4b3601..ebb39d7cba 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -48,8 +48,7 @@ from cura.Arranging.Arrange import Arrange from cura.Arranging.ArrangeObjectsJob import ArrangeObjectsJob from cura.Arranging.ArrangeObjectsAllBuildPlatesJob import ArrangeObjectsAllBuildPlatesJob from cura.Arranging.ShapeArray import ShapeArray -from cura.MultiplyObjectsJob import MultiplyObjectsJob -from cura.GlobalStacksModel import GlobalStacksModel +from cura.UI.GlobalStacksModel import GlobalStacksModel from cura.Scene.ConvexHullDecorator import ConvexHullDecorator from cura.Operations.SetParentOperation import SetParentOperation from cura.Scene.SliceableObjectDecorator import SliceableObjectDecorator @@ -68,19 +67,19 @@ from UM.Settings.SettingFunction import SettingFunction from cura.Settings.CuraContainerRegistry import CuraContainerRegistry from cura.Settings.MachineNameValidator import MachineNameValidator -from cura.Machines.Models.BuildPlateModel import BuildPlateModel -from cura.Machines.Models.NozzleModel import NozzleModel -from cura.Machines.Models.QualityProfilesDropDownMenuModel import QualityProfilesDropDownMenuModel -from cura.Machines.Models.CustomQualityProfilesDropDownMenuModel import CustomQualityProfilesDropDownMenuModel -from cura.Machines.Models.MultiBuildPlateModel import MultiBuildPlateModel -from cura.Machines.Models.FavoriteMaterialsModel import FavoriteMaterialsModel -from cura.Machines.Models.GenericMaterialsModel import GenericMaterialsModel -from cura.Machines.Models.MaterialBrandsModel import MaterialBrandsModel -from cura.Machines.Models.QualityManagementModel import QualityManagementModel -from cura.Machines.Models.QualitySettingsModel import QualitySettingsModel -from cura.Machines.Models.FirstStartMachineActionsModel import FirstStartMachineActionsModel - -from cura.Machines.Models.SettingVisibilityPresetsModel import SettingVisibilityPresetsModel +from cura.UI.MachineModels.BuildPlateModel import BuildPlateModel +from cura.UI.MachineModels.DiscoveredPrintersModel import DiscoveredPrintersModel +from cura.UI.MachineModels.NozzleModel import NozzleModel +from cura.UI.MachineModels.QualityProfilesDropDownMenuModel import QualityProfilesDropDownMenuModel +from cura.UI.MachineModels.CustomQualityProfilesDropDownMenuModel import CustomQualityProfilesDropDownMenuModel +from cura.UI.MachineModels.MultiBuildPlateModel import MultiBuildPlateModel +from cura.UI.MachineModels.FavoriteMaterialsModel import FavoriteMaterialsModel +from cura.UI.MachineModels.FirstStartMachineActionsModel import FirstStartMachineActionsModel +from cura.UI.MachineModels.GenericMaterialsModel import GenericMaterialsModel +from cura.UI.MachineModels.MaterialBrandsModel import MaterialBrandsModel +from cura.UI.MachineModels.QualityManagementModel import QualityManagementModel +from cura.UI.MachineModels.QualitySettingsModel import QualitySettingsModel +from cura.UI.MachineModels.SettingVisibilityPresetsModel import SettingVisibilityPresetsModel from cura.Machines.MachineErrorChecker import MachineErrorChecker @@ -94,30 +93,26 @@ from .AutoSave import AutoSave from . import PlatformPhysics from . import BuildVolume from . import CameraAnimation -from . import PrintInformation from . import CuraActions from cura.Scene import ZOffsetDecorator -from . import CuraSplashScreen +from cura.UI import CuraSplashScreen, MachineActionManager, PrintInformation from . import PrintJobPreviewImageProvider -from . import MachineActionManager from cura.TaskManagement.OnExitCallbackManager import OnExitCallbackManager from cura.Settings.MachineManager import MachineManager from cura.Settings.ExtruderManager import ExtruderManager -from cura.Settings.UserChangesModel import UserChangesModel -from cura.Settings.ExtrudersModel import ExtrudersModel +from cura.UI.UserChangesModel import UserChangesModel +from cura.UI.ExtrudersModel import ExtrudersModel from cura.Settings.MaterialSettingsVisibilityHandler import MaterialSettingsVisibilityHandler from cura.Settings.ContainerManager import ContainerManager from cura.Settings.SidebarCustomMenuItemsModel import SidebarCustomMenuItemsModel import cura.Settings.cura_empty_instance_containers from cura.Settings.CuraFormulaFunctions import CuraFormulaFunctions -from cura.ObjectsModel import ObjectsModel +from cura.UI.ObjectsModel import ObjectsModel -from cura.Machines.Models.DiscoveredPrintersModel import DiscoveredPrintersModel - -from cura.PrinterOutputDevice import PrinterOutputDevice +from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice from cura.PrinterOutput.NetworkMJPGImage import NetworkMJPGImage from cura import ApplicationMetadata, UltimakerCloudAuthentication @@ -1010,7 +1005,7 @@ class CuraApplication(QtApplication): qmlRegisterSingletonType(SimpleModeSettingsManager, "Cura", 1, 0, "SimpleModeSettingsManager", self.getSimpleModeSettingsManager) qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager) - qmlRegisterType(WelcomePagesModel, "Cura", 1, 0, "WelcomePageModel") + qmlRegisterType(WelcomePagesModel, "Cura", 1, 0, "WelcomePagesModel") qmlRegisterType(NetworkMJPGImage, "Cura", 1, 0, "NetworkMJPGImage") diff --git a/cura/PrinterOutput/FirmwareUpdater.py b/cura/PrinterOutput/FirmwareUpdater.py index c6d9513ee0..3f20e0f3c4 100644 --- a/cura/PrinterOutput/FirmwareUpdater.py +++ b/cura/PrinterOutput/FirmwareUpdater.py @@ -9,7 +9,7 @@ from typing import Union MYPY = False if MYPY: - from cura.PrinterOutputDevice import PrinterOutputDevice + from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice class FirmwareUpdater(QObject): firmwareProgressChanged = pyqtSignal() diff --git a/cura/PrinterOutput/GenericOutputController.py b/cura/PrinterOutput/GenericOutputController.py index 1cb416787c..88ac529e01 100644 --- a/cura/PrinterOutput/GenericOutputController.py +++ b/cura/PrinterOutput/GenericOutputController.py @@ -3,14 +3,15 @@ from typing import TYPE_CHECKING, Set, Union, Optional -from cura.PrinterOutput.PrinterOutputController import PrinterOutputController from PyQt5.QtCore import QTimer +from cura.PrinterOutput.PrinterOutputController import PrinterOutputController + if TYPE_CHECKING: - from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel - from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel + from cura.UI.PrintJobOutputModel import PrintJobOutputModel + from cura.UI.PrinterOutputModel import PrinterOutputModel from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice - from cura.PrinterOutput.ExtruderOutputModel import ExtruderOutputModel + from cura.UI.ExtruderOutputModel import ExtruderOutputModel class GenericOutputController(PrinterOutputController): diff --git a/cura/PrinterOutput/MaterialOutputModel.py b/cura/PrinterOutput/MaterialOutputModel.py deleted file mode 100644 index 64ebd3c94c..0000000000 --- a/cura/PrinterOutput/MaterialOutputModel.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) 2017 Ultimaker B.V. -# Cura is released under the terms of the LGPLv3 or higher. - -from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot - - -class MaterialOutputModel(QObject): - def __init__(self, guid, type, color, brand, name, parent = None): - super().__init__(parent) - self._guid = guid - self._type = type - self._color = color - self._brand = brand - self._name = name - - @pyqtProperty(str, constant = True) - def guid(self): - return self._guid - - @pyqtProperty(str, constant=True) - def type(self): - return self._type - - @pyqtProperty(str, constant=True) - def brand(self): - return self._brand - - @pyqtProperty(str, constant=True) - def color(self): - return self._color - - @pyqtProperty(str, constant=True) - def name(self): - return self._name \ No newline at end of file diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index 0e33a71249..b846d98299 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -7,7 +7,7 @@ from UM.Scene.SceneNode import SceneNode #For typing. from cura.API import Account from cura.CuraApplication import CuraApplication -from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState, ConnectionType +from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionState, ConnectionType from PyQt5.QtNetwork import QHttpMultiPart, QHttpPart, QNetworkRequest, QNetworkAccessManager, QNetworkReply, QAuthenticator from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QUrl, QCoreApplication diff --git a/cura/PrinterOutput/PrinterOutputController.py b/cura/PrinterOutput/PrinterOutputController.py index aa06ada8a3..4352c59762 100644 --- a/cura/PrinterOutput/PrinterOutputController.py +++ b/cura/PrinterOutput/PrinterOutputController.py @@ -4,13 +4,11 @@ from UM.Logger import Logger from UM.Signal import Signal -from typing import Union - MYPY = False if MYPY: - from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel - from cura.PrinterOutput.ExtruderOutputModel import ExtruderOutputModel - from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel + from cura.UI.PrintJobOutputModel import PrintJobOutputModel + from cura.UI.ExtruderOutputModel import ExtruderOutputModel + from cura.UI.PrinterOutputModel import PrinterOutputModel from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutput/PrinterOutputDevice.py similarity index 97% rename from cura/PrinterOutputDevice.py rename to cura/PrinterOutput/PrinterOutputDevice.py index dbdf8c986c..d15de94cc8 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutput/PrinterOutputDevice.py @@ -16,8 +16,8 @@ from UM.FlameProfiler import pyqtSlot MYPY = False if MYPY: - from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel - from cura.PrinterOutput.ConfigurationModel import ConfigurationModel + from cura.UI.PrinterOutputModel import PrinterOutputModel + from cura.UI.PrinterConfigurationModel import PrinterConfigurationModel from cura.PrinterOutput.FirmwareUpdater import FirmwareUpdater from UM.FileHandler.FileHandler import FileHandler from UM.Scene.SceneNode import SceneNode @@ -73,7 +73,7 @@ class PrinterOutputDevice(QObject, OutputDevice): super().__init__(device_id = device_id, parent = parent) # type: ignore # MyPy complains with the multiple inheritance self._printers = [] # type: List[PrinterOutputModel] - self._unique_configurations = [] # type: List[ConfigurationModel] + self._unique_configurations = [] # type: List[PrinterConfigurationModel] self._monitor_view_qml_path = "" # type: str self._monitor_component = None # type: Optional[QObject] @@ -216,7 +216,7 @@ class PrinterOutputDevice(QObject, OutputDevice): # Returns the unique configurations of the printers within this output device @pyqtProperty("QVariantList", notify = uniqueConfigurationsChanged) - def uniqueConfigurations(self) -> List["ConfigurationModel"]: + def uniqueConfigurations(self) -> List["PrinterConfigurationModel"]: return self._unique_configurations def _updateUniqueConfigurations(self) -> None: diff --git a/cura/Scene/CuraSceneController.py b/cura/Scene/CuraSceneController.py index 9f26ea7cc3..b0e9e10c32 100644 --- a/cura/Scene/CuraSceneController.py +++ b/cura/Scene/CuraSceneController.py @@ -4,8 +4,8 @@ from PyQt5.QtCore import Qt, pyqtSlot, QObject from PyQt5.QtWidgets import QApplication from UM.Scene.Camera import Camera -from cura.ObjectsModel import ObjectsModel -from cura.Machines.Models.MultiBuildPlateModel import MultiBuildPlateModel +from cura.UI.ObjectsModel import ObjectsModel +from cura.UI.MachineModels.MultiBuildPlateModel import MultiBuildPlateModel from UM.Application import Application from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index c910b67d0c..0afca64c88 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -22,10 +22,10 @@ from UM.Settings.SettingFunction import SettingFunction from UM.Signal import postponeSignals, CompressTechnique from cura.Machines.QualityManager import getMachineDefinitionIDForQualitySearch -from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionType -from cura.PrinterOutput.ConfigurationModel import ConfigurationModel -from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel -from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel +from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionType +from cura.UI.PrinterConfigurationModel import PrinterConfigurationModel +from cura.UI.ExtruderConfigurationModel import ExtruderConfigurationModel +from cura.UI.MaterialOutputModel import MaterialOutputModel from cura.Settings.CuraContainerRegistry import CuraContainerRegistry from cura.Settings.ExtruderManager import ExtruderManager from cura.Settings.ExtruderStack import ExtruderStack @@ -106,7 +106,7 @@ class MachineManager(QObject): # There might already be some output devices by the time the signal is connected self._onOutputDevicesChanged() - self._current_printer_configuration = ConfigurationModel() # Indicates the current configuration setup in this printer + self._current_printer_configuration = PrinterConfigurationModel() # Indicates the current configuration setup in this printer self.activeMaterialChanged.connect(self._onCurrentConfigurationChanged) self.activeVariantChanged.connect(self._onCurrentConfigurationChanged) # Force to compute the current configuration @@ -174,7 +174,7 @@ class MachineManager(QObject): self.outputDevicesChanged.emit() @pyqtProperty(QObject, notify = currentConfigurationChanged) - def currentConfiguration(self) -> ConfigurationModel: + def currentConfiguration(self) -> PrinterConfigurationModel: return self._current_printer_configuration def _onCurrentConfigurationChanged(self) -> None: @@ -205,7 +205,7 @@ class MachineManager(QObject): self.currentConfigurationChanged.emit() @pyqtSlot(QObject, result = bool) - def matchesConfiguration(self, configuration: ConfigurationModel) -> bool: + def matchesConfiguration(self, configuration: PrinterConfigurationModel) -> bool: return self._current_printer_configuration == configuration @pyqtProperty("QVariantList", notify = outputDevicesChanged) @@ -1375,7 +1375,7 @@ class MachineManager(QObject): self.setActiveMachine(new_machine.getId()) @pyqtSlot(QObject) - def applyRemoteConfiguration(self, configuration: ConfigurationModel) -> None: + def applyRemoteConfiguration(self, configuration: PrinterConfigurationModel) -> None: if self._global_container_stack is None: return self.blurSettings.emit() @@ -1678,7 +1678,9 @@ class MachineManager(QObject): meta_data = global_stack.getMetaData() - if "um_network_key" in meta_data: # Global stack already had a connection, but it's changed. + # Global stack previously had a connection, so here it needs to change the connection information in all + # global stacks in that same group. + if "um_network_key" in meta_data: old_network_key = meta_data["um_network_key"] # Since we might have a bunch of hidden stacks, we also need to change it there. metadata_filter = {"um_network_key": old_network_key} @@ -1698,6 +1700,7 @@ class MachineManager(QObject): # Ensure that these containers do know that they are configured for network connection container.addConfiguredConnectionType(printer_device.connectionType.value) - else: # Global stack didn't have a connection yet, configure it. + # Global stack previously didn't have a connection, so directly configure it. + else: global_stack.setMetaDataEntry("um_network_key", printer_device.key) global_stack.addConfiguredConnectionType(printer_device.connectionType.value) diff --git a/cura/Stages/__init__.py b/cura/Stages/__init__.py deleted file mode 100644 index 2977645166..0000000000 --- a/cura/Stages/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright (c) 2017 Ultimaker B.V. -# Cura is released under the terms of the LGPLv3 or higher. diff --git a/cura/CuraSplashScreen.py b/cura/UI/CuraSplashScreen.py similarity index 100% rename from cura/CuraSplashScreen.py rename to cura/UI/CuraSplashScreen.py diff --git a/cura/Stages/CuraStage.py b/cura/UI/CuraStage.py similarity index 93% rename from cura/Stages/CuraStage.py rename to cura/UI/CuraStage.py index 844b0d0768..6c4d46dd72 100644 --- a/cura/Stages/CuraStage.py +++ b/cura/UI/CuraStage.py @@ -1,29 +1,32 @@ -# Copyright (c) 2018 Ultimaker B.V. -# Cura is released under the terms of the LGPLv3 or higher. - -from PyQt5.QtCore import pyqtProperty, QUrl - -from UM.Stage import Stage - - -# Since Cura has a few pre-defined "space claims" for the locations of certain components, we've provided some structure -# to indicate this. -# * The StageMenuComponent is the horizontal area below the stage bar. This should be used to show stage specific -# buttons and elements. This component will be drawn over the bar & main component. -# * The MainComponent is the component that will be drawn starting from the bottom of the stageBar and fills the rest -# of the screen. -class CuraStage(Stage): - def __init__(self, parent = None) -> None: - super().__init__(parent) - - @pyqtProperty(str, constant = True) - def stageId(self) -> str: - return self.getPluginId() - - @pyqtProperty(QUrl, constant = True) - def mainComponent(self) -> QUrl: - return self.getDisplayComponent("main") - - @pyqtProperty(QUrl, constant = True) - def stageMenuComponent(self) -> QUrl: - return self.getDisplayComponent("menu") \ No newline at end of file +# Copyright (c) 2018 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + +from PyQt5.QtCore import pyqtProperty, QUrl + +from UM.Stage import Stage + + +# Since Cura has a few pre-defined "space claims" for the locations of certain components, we've provided some structure +# to indicate this. +# * The StageMenuComponent is the horizontal area below the stage bar. This should be used to show stage specific +# buttons and elements. This component will be drawn over the bar & main component. +# * The MainComponent is the component that will be drawn starting from the bottom of the stageBar and fills the rest +# of the screen. +class CuraStage(Stage): + def __init__(self, parent = None) -> None: + super().__init__(parent) + + @pyqtProperty(str, constant = True) + def stageId(self) -> str: + return self.getPluginId() + + @pyqtProperty(QUrl, constant = True) + def mainComponent(self) -> QUrl: + return self.getDisplayComponent("main") + + @pyqtProperty(QUrl, constant = True) + def stageMenuComponent(self) -> QUrl: + return self.getDisplayComponent("menu") + + +__all__ = ["CuraStage"] diff --git a/cura/PrinterOutput/ExtruderConfigurationModel.py b/cura/UI/ExtruderConfigurationModel.py similarity index 97% rename from cura/PrinterOutput/ExtruderConfigurationModel.py rename to cura/UI/ExtruderConfigurationModel.py index da0ad6b0b2..7de37918b9 100644 --- a/cura/PrinterOutput/ExtruderConfigurationModel.py +++ b/cura/UI/ExtruderConfigurationModel.py @@ -4,7 +4,7 @@ from typing import Optional from PyQt5.QtCore import pyqtProperty, QObject, pyqtSignal -from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel +from cura.UI.MaterialOutputModel import MaterialOutputModel class ExtruderConfigurationModel(QObject): @@ -67,4 +67,4 @@ class ExtruderConfigurationModel(QObject): # Calculating a hash function using the position of the extruder, the material GUID and the hotend id to check if is # unique within a set def __hash__(self): - return hash(self._position) ^ (hash(self._material.guid) if self._material is not None else hash(0)) ^ hash(self._hotend_id) \ No newline at end of file + return hash(self._position) ^ (hash(self._material.guid) if self._material is not None else hash(0)) ^ hash(self._hotend_id) diff --git a/cura/PrinterOutput/ExtruderOutputModel.py b/cura/UI/ExtruderOutputModel.py similarity index 95% rename from cura/PrinterOutput/ExtruderOutputModel.py rename to cura/UI/ExtruderOutputModel.py index 30d53bbd85..7fab441a08 100644 --- a/cura/PrinterOutput/ExtruderOutputModel.py +++ b/cura/UI/ExtruderOutputModel.py @@ -2,13 +2,13 @@ # Cura is released under the terms of the LGPLv3 or higher. from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot -from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel +from cura.UI.ExtruderConfigurationModel import ExtruderConfigurationModel from typing import Optional, TYPE_CHECKING if TYPE_CHECKING: - from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel - from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel + from cura.UI.PrinterOutputModel import PrinterOutputModel + from cura.UI.MaterialOutputModel import MaterialOutputModel class ExtruderOutputModel(QObject): diff --git a/cura/Settings/ExtrudersModel.py b/cura/UI/ExtrudersModel.py similarity index 97% rename from cura/Settings/ExtrudersModel.py rename to cura/UI/ExtrudersModel.py index 93cc1ce402..9eee7f5f9e 100644 --- a/cura/Settings/ExtrudersModel.py +++ b/cura/UI/ExtrudersModel.py @@ -2,23 +2,25 @@ # Cura is released under the terms of the LGPLv3 or higher. from PyQt5.QtCore import Qt, pyqtSignal, pyqtProperty, QTimer -from typing import Iterable +from typing import Iterable, TYPE_CHECKING from UM.i18n import i18nCatalog -import UM.Qt.ListModel +from UM.Qt.ListModel import ListModel from UM.Application import Application import UM.FlameProfiler -from cura.Settings.ExtruderStack import ExtruderStack # To listen to changes on the extruders. +if TYPE_CHECKING: + from cura.Settings.ExtruderStack import ExtruderStack # To listen to changes on the extruders. catalog = i18nCatalog("cura") + ## Model that holds extruders. # # This model is designed for use by any list of extruders, but specifically # intended for drop-down lists of the current machine's extruders in place of # settings. -class ExtrudersModel(UM.Qt.ListModel.ListModel): +class ExtrudersModel(ListModel): # The ID of the container stack for the extruder. IdRole = Qt.UserRole + 1 diff --git a/cura/GlobalStacksModel.py b/cura/UI/GlobalStacksModel.py similarity index 79% rename from cura/GlobalStacksModel.py rename to cura/UI/GlobalStacksModel.py index a6d64cfc02..579555e52c 100644 --- a/cura/GlobalStacksModel.py +++ b/cura/UI/GlobalStacksModel.py @@ -1,12 +1,12 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from PyQt5.QtCore import pyqtProperty, Qt, QTimer +from PyQt5.QtCore import Qt, QTimer from UM.Qt.ListModel import ListModel from UM.i18n import i18nCatalog -from cura.PrinterOutputDevice import ConnectionType +from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from cura.Settings.CuraContainerRegistry import CuraContainerRegistry from cura.Settings.GlobalStack import GlobalStack @@ -17,9 +17,9 @@ class GlobalStacksModel(ListModel): HasRemoteConnectionRole = Qt.UserRole + 3 ConnectionTypeRole = Qt.UserRole + 4 MetaDataRole = Qt.UserRole + 5 - SectionNameRole = Qt.UserRole + 6 # For separating local and remote printers in the machine management page + DiscoverySourceRole = Qt.UserRole + 6 # For separating local and remote printers in the machine management page - def __init__(self, parent = None): + def __init__(self, parent = None) -> None: super().__init__(parent) self._catalog = i18nCatalog("cura") @@ -28,7 +28,7 @@ class GlobalStacksModel(ListModel): self.addRoleName(self.IdRole, "id") self.addRoleName(self.HasRemoteConnectionRole, "hasRemoteConnection") self.addRoleName(self.MetaDataRole, "metadata") - self.addRoleName(self.SectionNameRole, "sectionName") + self.addRoleName(self.DiscoverySourceRole, "discoverySource") self._container_stacks = [] self._change_timer = QTimer() @@ -44,12 +44,12 @@ class GlobalStacksModel(ListModel): self._updateDelayed() ## Handler for container added/removed events from registry - def _onContainerChanged(self, container): + def _onContainerChanged(self, container) -> None: # We only need to update when the added / removed container GlobalStack if isinstance(container, GlobalStack): self._updateDelayed() - def _updateDelayed(self): + def _updateDelayed(self) -> None: self._change_timer.start() def _update(self) -> None: @@ -61,7 +61,8 @@ class GlobalStacksModel(ListModel): has_remote_connection = False for connection_type in container_stack.configuredConnectionTypes: - has_remote_connection |= connection_type in [ConnectionType.NetworkConnection.value, ConnectionType.CloudConnection.value] + has_remote_connection |= connection_type in [ConnectionType.NetworkConnection.value, + ConnectionType.CloudConnection.value] if container_stack.getMetaDataEntry("hidden", False) in ["True", True]: continue @@ -73,6 +74,6 @@ class GlobalStacksModel(ListModel): "id": container_stack.getId(), "hasRemoteConnection": has_remote_connection, "metadata": container_stack.getMetaData().copy(), - "sectionName": section_name}) - items.sort(key=lambda i: not i["hasRemoteConnection"]) + "discoverySource": section_name}) + items.sort(key = lambda i: not i["hasRemoteConnection"]) self.setItems(items) diff --git a/cura/MachineActionManager.py b/cura/UI/MachineActionManager.py similarity index 99% rename from cura/MachineActionManager.py rename to cura/UI/MachineActionManager.py index 8cfde654fb..aa90e909e2 100644 --- a/cura/MachineActionManager.py +++ b/cura/UI/MachineActionManager.py @@ -12,7 +12,7 @@ from UM.PluginRegistry import PluginRegistry # So MachineAction can be added as if TYPE_CHECKING: from cura.CuraApplication import CuraApplication from cura.Settings.GlobalStack import GlobalStack - from .MachineAction import MachineAction + from cura.MachineAction import MachineAction ## Raised when trying to add an unknown machine action as a required action diff --git a/cura/Machines/Models/BaseMaterialsModel.py b/cura/UI/MachineModels/BaseMaterialsModel.py similarity index 100% rename from cura/Machines/Models/BaseMaterialsModel.py rename to cura/UI/MachineModels/BaseMaterialsModel.py diff --git a/cura/Machines/Models/BuildPlateModel.py b/cura/UI/MachineModels/BuildPlateModel.py similarity index 100% rename from cura/Machines/Models/BuildPlateModel.py rename to cura/UI/MachineModels/BuildPlateModel.py diff --git a/cura/Machines/Models/CustomQualityProfilesDropDownMenuModel.py b/cura/UI/MachineModels/CustomQualityProfilesDropDownMenuModel.py similarity index 92% rename from cura/Machines/Models/CustomQualityProfilesDropDownMenuModel.py rename to cura/UI/MachineModels/CustomQualityProfilesDropDownMenuModel.py index dcade8cb0d..387182dd90 100644 --- a/cura/Machines/Models/CustomQualityProfilesDropDownMenuModel.py +++ b/cura/UI/MachineModels/CustomQualityProfilesDropDownMenuModel.py @@ -3,7 +3,7 @@ from UM.Logger import Logger -from cura.Machines.Models.QualityProfilesDropDownMenuModel import QualityProfilesDropDownMenuModel +from cura.UI.MachineModels.QualityProfilesDropDownMenuModel import QualityProfilesDropDownMenuModel # diff --git a/cura/Machines/Models/DiscoveredPrintersModel.py b/cura/UI/MachineModels/DiscoveredPrintersModel.py similarity index 87% rename from cura/Machines/Models/DiscoveredPrintersModel.py rename to cura/UI/MachineModels/DiscoveredPrintersModel.py index e31b8133a8..21820da73d 100644 --- a/cura/Machines/Models/DiscoveredPrintersModel.py +++ b/cura/UI/MachineModels/DiscoveredPrintersModel.py @@ -1,7 +1,7 @@ # Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from typing import Callable, List, Optional, TYPE_CHECKING +from typing import Callable, Dict, List, Optional, TYPE_CHECKING from PyQt5.QtCore import pyqtSlot, pyqtProperty, pyqtSignal, QObject @@ -81,34 +81,34 @@ class DiscoveredPrintersModel(QObject): def __init__(self, parent: Optional["QObject"]) -> None: super().__init__(parent) - self._discovered_printer_dict = dict() + self._discovered_printer_by_ip_dict = dict() # type: Dict[str, DiscoveredPrinter] discoveredPrintersChanged = pyqtSignal() @pyqtProperty(list, notify = discoveredPrintersChanged) def discovered_printers(self) -> "List[DiscoveredPrinter]": - item_list = list(x for x in self._discovered_printer_dict.values()) + item_list = list(x for x in self._discovered_printer_by_ip_dict.values()) item_list.sort(key = lambda x: x.name) return item_list def addDiscoveredPrinter(self, ip_address: str, key: str, name: str, create_callback: Callable[[str], None], machine_type: str, device) -> None: - if ip_address in self._discovered_printer_dict: + if ip_address in self._discovered_printer_by_ip_dict: Logger.log("e", "Printer with ip [%s] has already been added", ip_address) return discovered_printer = DiscoveredPrinter(ip_address, key, name, create_callback, machine_type, device, parent = self) - self._discovered_printer_dict[ip_address] = discovered_printer + self._discovered_printer_by_ip_dict[ip_address] = discovered_printer self.discoveredPrintersChanged.emit() def updateDiscoveredPrinter(self, ip_address: str, name: Optional[str] = None, machine_type: Optional[str] = None) -> None: - if ip_address not in self._discovered_printer_dict: + if ip_address not in self._discovered_printer_by_ip_dict: Logger.log("e", "Printer with ip [%s] is not known", ip_address) return - item = self._discovered_printer_dict[ip_address] + item = self._discovered_printer_by_ip_dict[ip_address] if name is not None: item.setName(name) @@ -116,11 +116,11 @@ class DiscoveredPrintersModel(QObject): item.setMachineType(machine_type) def removeDiscoveredPrinter(self, ip_address: str) -> None: - if ip_address not in self._discovered_printer_dict: + if ip_address not in self._discovered_printer_by_ip_dict: Logger.log("i", "Key [%s] does not exist in the discovered printers list.", ip_address) return - del self._discovered_printer_dict[ip_address] + del self._discovered_printer_by_ip_dict[ip_address] self.discoveredPrintersChanged.emit() @pyqtSlot("QVariant") diff --git a/cura/Machines/Models/FavoriteMaterialsModel.py b/cura/UI/MachineModels/FavoriteMaterialsModel.py similarity index 94% rename from cura/Machines/Models/FavoriteMaterialsModel.py rename to cura/UI/MachineModels/FavoriteMaterialsModel.py index 98a2a01597..b81c25a2b4 100644 --- a/cura/Machines/Models/FavoriteMaterialsModel.py +++ b/cura/UI/MachineModels/FavoriteMaterialsModel.py @@ -1,7 +1,7 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from cura.Machines.Models.BaseMaterialsModel import BaseMaterialsModel +from cura.UI.MachineModels.BaseMaterialsModel import BaseMaterialsModel ## Model that shows the list of favorite materials. class FavoriteMaterialsModel(BaseMaterialsModel): diff --git a/cura/Machines/Models/FirstStartMachineActionsModel.py b/cura/UI/MachineModels/FirstStartMachineActionsModel.py similarity index 100% rename from cura/Machines/Models/FirstStartMachineActionsModel.py rename to cura/UI/MachineModels/FirstStartMachineActionsModel.py diff --git a/cura/Machines/Models/GenericMaterialsModel.py b/cura/UI/MachineModels/GenericMaterialsModel.py similarity index 91% rename from cura/Machines/Models/GenericMaterialsModel.py rename to cura/UI/MachineModels/GenericMaterialsModel.py index 8f41dd6a70..122bb3fc8f 100644 --- a/cura/Machines/Models/GenericMaterialsModel.py +++ b/cura/UI/MachineModels/GenericMaterialsModel.py @@ -1,8 +1,7 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from UM.Logger import Logger -from cura.Machines.Models.BaseMaterialsModel import BaseMaterialsModel +from cura.UI.MachineModels.BaseMaterialsModel import BaseMaterialsModel class GenericMaterialsModel(BaseMaterialsModel): diff --git a/cura/Machines/Models/MaterialBrandsModel.py b/cura/UI/MachineModels/MaterialBrandsModel.py similarity index 96% rename from cura/Machines/Models/MaterialBrandsModel.py rename to cura/UI/MachineModels/MaterialBrandsModel.py index ac82cf6670..bd641d29e7 100644 --- a/cura/Machines/Models/MaterialBrandsModel.py +++ b/cura/UI/MachineModels/MaterialBrandsModel.py @@ -1,10 +1,9 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from PyQt5.QtCore import Qt, pyqtSignal, pyqtProperty +from PyQt5.QtCore import Qt, pyqtSignal from UM.Qt.ListModel import ListModel -from UM.Logger import Logger -from cura.Machines.Models.BaseMaterialsModel import BaseMaterialsModel +from cura.UI.MachineModels.BaseMaterialsModel import BaseMaterialsModel class MaterialTypesModel(ListModel): diff --git a/cura/Machines/Models/MultiBuildPlateModel.py b/cura/UI/MachineModels/MultiBuildPlateModel.py similarity index 100% rename from cura/Machines/Models/MultiBuildPlateModel.py rename to cura/UI/MachineModels/MultiBuildPlateModel.py diff --git a/cura/Machines/Models/NozzleModel.py b/cura/UI/MachineModels/NozzleModel.py similarity index 100% rename from cura/Machines/Models/NozzleModel.py rename to cura/UI/MachineModels/NozzleModel.py diff --git a/cura/Machines/Models/QualityManagementModel.py b/cura/UI/MachineModels/QualityManagementModel.py similarity index 100% rename from cura/Machines/Models/QualityManagementModel.py rename to cura/UI/MachineModels/QualityManagementModel.py diff --git a/cura/Machines/Models/QualityProfilesDropDownMenuModel.py b/cura/UI/MachineModels/QualityProfilesDropDownMenuModel.py similarity index 100% rename from cura/Machines/Models/QualityProfilesDropDownMenuModel.py rename to cura/UI/MachineModels/QualityProfilesDropDownMenuModel.py diff --git a/cura/Machines/Models/QualitySettingsModel.py b/cura/UI/MachineModels/QualitySettingsModel.py similarity index 100% rename from cura/Machines/Models/QualitySettingsModel.py rename to cura/UI/MachineModels/QualitySettingsModel.py diff --git a/cura/Machines/Models/SettingVisibilityPresetsModel.py b/cura/UI/MachineModels/SettingVisibilityPresetsModel.py similarity index 100% rename from cura/Machines/Models/SettingVisibilityPresetsModel.py rename to cura/UI/MachineModels/SettingVisibilityPresetsModel.py diff --git a/cura/Machines/Models/__init__.py b/cura/UI/MachineModels/__init__.py similarity index 100% rename from cura/Machines/Models/__init__.py rename to cura/UI/MachineModels/__init__.py diff --git a/cura/UI/MaterialOutputModel.py b/cura/UI/MaterialOutputModel.py new file mode 100644 index 0000000000..b3dd83fb72 --- /dev/null +++ b/cura/UI/MaterialOutputModel.py @@ -0,0 +1,34 @@ +# Copyright (c) 2017 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + +from PyQt5.QtCore import pyqtProperty, QObject + + +class MaterialOutputModel(QObject): + def __init__(self, guid: str, type: str, color: str, brand: str, name: str, parent = None): + super().__init__(parent) + self._guid = guid + self._type = type + self._color = color + self._brand = brand + self._name = name + + @pyqtProperty(str, constant = True) + def guid(self) -> str: + return self._guid + + @pyqtProperty(str, constant = True) + def type(self) -> str: + return self._type + + @pyqtProperty(str, constant = True) + def brand(self) -> str: + return self._brand + + @pyqtProperty(str, constant = True) + def color(self) -> str: + return self._color + + @pyqtProperty(str, constant = True) + def name(self) -> str: + return self._name diff --git a/cura/ObjectsModel.py b/cura/UI/ObjectsModel.py similarity index 95% rename from cura/ObjectsModel.py rename to cura/UI/ObjectsModel.py index f9f923b31d..4d0233f6cb 100644 --- a/cura/ObjectsModel.py +++ b/cura/UI/ObjectsModel.py @@ -1,6 +1,8 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from collections import defaultdict + from PyQt5.QtCore import QTimer from UM.Application import Application @@ -10,7 +12,6 @@ from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Scene.SceneNode import SceneNode from UM.Scene.Selection import Selection from UM.i18n import i18nCatalog -from collections import defaultdict catalog = i18nCatalog("cura") @@ -30,19 +31,19 @@ class ObjectsModel(ListModel): self._build_plate_number = -1 - def setActiveBuildPlate(self, nr): + def setActiveBuildPlate(self, nr: int) -> None: if self._build_plate_number != nr: self._build_plate_number = nr self._update() - def _updateSceneDelayed(self, source): + def _updateSceneDelayed(self, source) -> None: if not isinstance(source, Camera): self._update_timer.start() - def _updateDelayed(self, *args): + def _updateDelayed(self, *args) -> None: self._update_timer.start() - def _update(self, *args): + def _update(self, *args) -> None: nodes = [] filter_current_build_plate = Application.getInstance().getPreferences().getValue("view/filter_current_build_plate") active_build_plate_number = self._build_plate_number diff --git a/cura/PrintInformation.py b/cura/UI/PrintInformation.py similarity index 99% rename from cura/PrintInformation.py rename to cura/UI/PrintInformation.py index ba7c74fd6d..2122abbe82 100644 --- a/cura/PrintInformation.py +++ b/cura/UI/PrintInformation.py @@ -5,8 +5,7 @@ import json import math import os import unicodedata -import re # To create abbreviations for printer names. -from typing import Dict, List, Optional +from typing import Dict, List, Optional, TYPE_CHECKING from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty, pyqtSlot @@ -16,8 +15,6 @@ from UM.Scene.SceneNode import SceneNode from UM.i18n import i18nCatalog from UM.MimeTypeDatabase import MimeTypeDatabase, MimeTypeNotFoundError -from typing import TYPE_CHECKING - if TYPE_CHECKING: from cura.CuraApplication import CuraApplication diff --git a/cura/PrinterOutput/PrintJobOutputModel.py b/cura/UI/PrintJobOutputModel.py similarity index 91% rename from cura/PrinterOutput/PrintJobOutputModel.py rename to cura/UI/PrintJobOutputModel.py index fb163ef065..a556680ef7 100644 --- a/cura/PrinterOutput/PrintJobOutputModel.py +++ b/cura/UI/PrintJobOutputModel.py @@ -1,16 +1,15 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot from typing import Optional, TYPE_CHECKING, List -from PyQt5.QtCore import QUrl +from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot, QUrl from PyQt5.QtGui import QImage if TYPE_CHECKING: from cura.PrinterOutput.PrinterOutputController import PrinterOutputController - from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel - from cura.PrinterOutput.ConfigurationModel import ConfigurationModel + from cura.UI.PrinterOutputModel import PrinterOutputModel + from cura.UI.PrinterConfigurationModel import PrinterConfigurationModel class PrintJobOutputModel(QObject): @@ -25,7 +24,7 @@ class PrintJobOutputModel(QObject): previewImageChanged = pyqtSignal() compatibleMachineFamiliesChanged = pyqtSignal() - def __init__(self, output_controller: "PrinterOutputController", key: str = "", name: str = "", parent=None) -> None: + def __init__(self, output_controller: "PrinterOutputController", key: str = "", name: str = "", parent = None) -> None: super().__init__(parent) self._output_controller = output_controller self._state = "" @@ -36,7 +35,7 @@ class PrintJobOutputModel(QObject): self._assigned_printer = None # type: Optional[PrinterOutputModel] self._owner = "" # Who started/owns the print job? - self._configuration = None # type: Optional[ConfigurationModel] + self._configuration = None # type: Optional[PrinterConfigurationModel] self._compatible_machine_families = [] # type: List[str] self._preview_image_id = 0 @@ -70,10 +69,10 @@ class PrintJobOutputModel(QObject): self.previewImageChanged.emit() @pyqtProperty(QObject, notify=configurationChanged) - def configuration(self) -> Optional["ConfigurationModel"]: + def configuration(self) -> Optional["PrinterConfigurationModel"]: return self._configuration - def updateConfiguration(self, configuration: Optional["ConfigurationModel"]) -> None: + def updateConfiguration(self, configuration: Optional["PrinterConfigurationModel"]) -> None: if self._configuration != configuration: self._configuration = configuration self.configurationChanged.emit() @@ -142,13 +141,13 @@ class PrintJobOutputModel(QObject): @pyqtProperty(bool, notify=stateChanged) def isActive(self) -> bool: - inactiveStates = [ + inactive_states = [ "pausing", "paused", "resuming", "wait_cleanup" ] - if self.state in inactiveStates and self.timeRemaining > 0: + if self.state in inactive_states and self.timeRemaining > 0: return False return True diff --git a/cura/PrinterOutput/ConfigurationModel.py b/cura/UI/PrinterConfigurationModel.py similarity index 91% rename from cura/PrinterOutput/ConfigurationModel.py rename to cura/UI/PrinterConfigurationModel.py index 312e3cffb0..3db34768d1 100644 --- a/cura/PrinterOutput/ConfigurationModel.py +++ b/cura/UI/PrinterConfigurationModel.py @@ -6,10 +6,10 @@ from typing import List MYPY = False if MYPY: - from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel + from cura.UI.ExtruderConfigurationModel import ExtruderConfigurationModel -class ConfigurationModel(QObject): +class PrinterConfigurationModel(QObject): configurationChanged = pyqtSignal() @@ -19,14 +19,14 @@ class ConfigurationModel(QObject): self._extruder_configurations = [] # type: List[ExtruderConfigurationModel] self._buildplate_configuration = "" - def setPrinterType(self, printer_type): + def setPrinterType(self, printer_type: str) -> None: self._printer_type = printer_type @pyqtProperty(str, fset = setPrinterType, notify = configurationChanged) def printerType(self) -> str: return self._printer_type - def setExtruderConfigurations(self, extruder_configurations: List["ExtruderConfigurationModel"]): + def setExtruderConfigurations(self, extruder_configurations: List["ExtruderConfigurationModel"]) -> None: if self._extruder_configurations != extruder_configurations: self._extruder_configurations = extruder_configurations @@ -40,7 +40,7 @@ class ConfigurationModel(QObject): return self._extruder_configurations def setBuildplateConfiguration(self, buildplate_configuration: str) -> None: - if self._buildplate_configuration != buildplate_configuration: + if self._buildplate_configuration != buildplate_configuration: self._buildplate_configuration = buildplate_configuration self.configurationChanged.emit() @@ -86,4 +86,4 @@ class ConfigurationModel(QObject): if first_extruder: extruder_hash &= hash(first_extruder) - return hash(self._printer_type) ^ extruder_hash ^ hash(self._buildplate_configuration) \ No newline at end of file + return hash(self._printer_type) ^ extruder_hash ^ hash(self._buildplate_configuration) diff --git a/cura/PrinterOutput/PrinterOutputModel.py b/cura/UI/PrinterOutputModel.py similarity index 96% rename from cura/PrinterOutput/PrinterOutputModel.py rename to cura/UI/PrinterOutputModel.py index 12884b5f9b..2c782cc701 100644 --- a/cura/PrinterOutput/PrinterOutputModel.py +++ b/cura/UI/PrinterOutputModel.py @@ -4,12 +4,12 @@ from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot, QUrl from typing import List, Dict, Optional from UM.Math.Vector import Vector -from cura.PrinterOutput.ConfigurationModel import ConfigurationModel -from cura.PrinterOutput.ExtruderOutputModel import ExtruderOutputModel +from cura.UI.PrinterConfigurationModel import PrinterConfigurationModel +from cura.UI.ExtruderOutputModel import ExtruderOutputModel MYPY = False if MYPY: - from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel + from cura.UI.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.PrinterOutputController import PrinterOutputController @@ -37,7 +37,7 @@ class PrinterOutputModel(QObject): self._controller = output_controller self._controller.canUpdateFirmwareChanged.connect(self._onControllerCanUpdateFirmwareChanged) self._extruders = [ExtruderOutputModel(printer = self, position = i) for i in range(number_of_extruders)] - self._printer_configuration = ConfigurationModel() # Indicates the current configuration setup in this printer + self._printer_configuration = PrinterConfigurationModel() # Indicates the current configuration setup in this printer self._head_position = Vector(0, 0, 0) self._active_print_job = None # type: Optional[PrintJobOutputModel] self._firmware_version = firmware_version @@ -291,7 +291,7 @@ class PrinterOutputModel(QObject): # Returns the configuration (material, variant and buildplate) of the current printer @pyqtProperty(QObject, notify = configurationChanged) - def printerConfiguration(self) -> Optional[ConfigurationModel]: + def printerConfiguration(self) -> Optional[PrinterConfigurationModel]: if self._printer_configuration.isValid(): return self._printer_configuration return None \ No newline at end of file diff --git a/cura/Settings/UserChangesModel.py b/cura/UI/UserChangesModel.py similarity index 99% rename from cura/Settings/UserChangesModel.py rename to cura/UI/UserChangesModel.py index 9a26e5607e..e629295397 100644 --- a/cura/Settings/UserChangesModel.py +++ b/cura/UI/UserChangesModel.py @@ -10,7 +10,6 @@ from UM.Application import Application from UM.Settings.ContainerRegistry import ContainerRegistry from UM.i18n import i18nCatalog from UM.Settings.SettingFunction import SettingFunction - from UM.Qt.ListModel import ListModel diff --git a/cura/UI/WelcomePagesModel.py b/cura/UI/WelcomePagesModel.py index 222de27d17..1e9a2a124b 100644 --- a/cura/UI/WelcomePagesModel.py +++ b/cura/UI/WelcomePagesModel.py @@ -1,7 +1,7 @@ # Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import os -from typing import TYPE_CHECKING, Optional +from typing import TYPE_CHECKING, Optional, List, Dict, Any from PyQt5.QtCore import QUrl, Qt @@ -25,56 +25,44 @@ class WelcomePagesModel(ListModel): self.addRoleName(self.PageUrlRole, "page_url") self.addRoleName(self.NextPageIdRole, "next_page_id") - self._pages = [] + self._pages = [] # type: List[Dict[str, Any]] + + # Convenience function to get QUrl path to pages that's located in "resources/qml/WelcomePages". + def _getBuiltinWelcomePagePath(self, page_filename: str) -> "QUrl": + from cura.CuraApplication import CuraApplication + return QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, + os.path.join("WelcomePages", page_filename))) def initialize(self) -> None: - from cura.CuraApplication import CuraApplication - # Add default welcome pages self._pages.append({"id": "welcome", - "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, - os.path.join("WelcomePages", - "WelcomeContent.qml"))), + "page_url": self._getBuiltinWelcomePagePath("WelcomeContent.qml"), }) self._pages.append({"id": "user_agreement", - "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, - os.path.join("WelcomePages", - "UserAgreementContent.qml"))), + "page_url": self._getBuiltinWelcomePagePath("UserAgreementContent.qml"), }) self._pages.append({"id": "whats_new", - "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, - os.path.join("WelcomePages", - "WhatsNewContent.qml"))), + "page_url": self._getBuiltinWelcomePagePath("WhatsNewContent.qml"), }) self._pages.append({"id": "data_collections", - "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, - os.path.join("WelcomePages", - "DataCollectionsContent.qml"))), + "page_url": self._getBuiltinWelcomePagePath("DataCollectionsContent.qml"), }) self._pages.append({"id": "add_printer_by_selection", - "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, - os.path.join("WelcomePages", - "AddPrinterBySelectionContent.qml"))), + "page_url": self._getBuiltinWelcomePagePath("AddPrinterBySelectionContent.qml"), }) self._pages.append({"id": "add_printer_by_ip", - "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, - os.path.join("WelcomePages", - "AddPrinterByIpContent.qml"))), + "page_url": self._getBuiltinWelcomePagePath("AddPrinterByIpContent.qml"), }) self._pages.append({"id": "machine_actions", - "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, - os.path.join("WelcomePages", - "FirstStartMachineActionsContent.qml"))), + "page_url": self._getBuiltinWelcomePagePath("FirstStartMachineActionsContent.qml"), }) self._pages.append({"id": "cloud", - "page_url": QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, - os.path.join("WelcomePages", - "CloudContent.qml"))), + "page_url": self._getBuiltinWelcomePagePath("CloudContent.qml"), }) self.setItems(self._pages) - def addPage(self): + def addPage(self) -> None: pass diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index ceba5f3006..0527b4534e 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -10,20 +10,17 @@ from time import time from typing import Any, cast, Dict, List, Optional, Set, TYPE_CHECKING from UM.Backend.Backend import Backend, BackendState -from UM.Scene.Camera import Camera from UM.Scene.SceneNode import SceneNode from UM.Signal import Signal from UM.Logger import Logger from UM.Message import Message from UM.PluginRegistry import PluginRegistry -from UM.Resources import Resources from UM.Platform import Platform from UM.Qt.Duration import DurationFormat from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Settings.Interfaces import DefinitionContainerInterface from UM.Settings.SettingInstance import SettingInstance #For typing. from UM.Tool import Tool #For typing. -from UM.Mesh.MeshData import MeshData #For typing. from cura.CuraApplication import CuraApplication from cura.Settings.ExtruderManager import ExtruderManager @@ -33,7 +30,7 @@ from .StartSliceJob import StartSliceJob, StartJobResult import Arcus if TYPE_CHECKING: - from cura.Machines.Models.MultiBuildPlateModel import MultiBuildPlateModel + from cura.UI.MachineModels.MultiBuildPlateModel import MultiBuildPlateModel from cura.Machines.MachineErrorChecker import MachineErrorChecker from UM.Scene.Scene import Scene from UM.Settings.ContainerStack import ContainerStack diff --git a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py index 3cc23130ea..312de71e11 100644 --- a/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py +++ b/plugins/CuraEngineBackend/ProcessSlicedLayersJob.py @@ -24,7 +24,7 @@ from cura import LayerPolygon import numpy from time import time -from cura.Settings.ExtrudersModel import ExtrudersModel +from cura.UI.ExtrudersModel import ExtrudersModel catalog = i18nCatalog("cura") diff --git a/plugins/MonitorStage/MonitorStage.py b/plugins/MonitorStage/MonitorStage.py index 69b7f20f4e..4dae6b8579 100644 --- a/plugins/MonitorStage/MonitorStage.py +++ b/plugins/MonitorStage/MonitorStage.py @@ -2,9 +2,7 @@ # Cura is released under the terms of the LGPLv3 or higher. import os.path from UM.Application import Application -from UM.PluginRegistry import PluginRegistry -from UM.Resources import Resources -from cura.Stages.CuraStage import CuraStage +from cura.UI.CuraStage import CuraStage ## Stage for monitoring a 3D printing while it's printing. diff --git a/plugins/PrepareStage/PrepareStage.py b/plugins/PrepareStage/PrepareStage.py index c2dee9693b..8150efca09 100644 --- a/plugins/PrepareStage/PrepareStage.py +++ b/plugins/PrepareStage/PrepareStage.py @@ -4,7 +4,7 @@ import os.path from UM.Application import Application from UM.PluginRegistry import PluginRegistry -from cura.Stages.CuraStage import CuraStage +from cura.UI.CuraStage import CuraStage ## Stage for preparing model (slicing). class PrepareStage(CuraStage): diff --git a/plugins/PreviewStage/PreviewStage.py b/plugins/PreviewStage/PreviewStage.py index 1c487c8340..eff307418e 100644 --- a/plugins/PreviewStage/PreviewStage.py +++ b/plugins/PreviewStage/PreviewStage.py @@ -4,7 +4,7 @@ import os.path from UM.Qt.QtApplication import QtApplication -from cura.Stages.CuraStage import CuraStage +from cura.UI.CuraStage import CuraStage from typing import TYPE_CHECKING, Optional diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index d052d925d2..60e9ec6e7c 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -18,8 +18,8 @@ from UM.Scene.SceneNode import SceneNode from cura.CuraApplication import CuraApplication from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState, NetworkedPrinterOutputDevice -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel -from cura.PrinterOutputDevice import ConnectionType +from cura.UI.PrinterOutputModel import PrinterOutputModel +from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from .CloudOutputController import CloudOutputController from ..MeshFormatHandler import MeshFormatHandler diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintCoreConfiguration.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintCoreConfiguration.py index 7454401d09..922d3e840c 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintCoreConfiguration.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintCoreConfiguration.py @@ -2,8 +2,8 @@ # Cura is released under the terms of the LGPLv3 or higher. from typing import Union, Dict, Optional, Any -from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel -from cura.PrinterOutput.ExtruderOutputModel import ExtruderOutputModel +from cura.UI.ExtruderConfigurationModel import ExtruderConfigurationModel +from cura.UI.ExtruderOutputModel import ExtruderOutputModel from .CloudClusterPrinterConfigurationMaterial import CloudClusterPrinterConfigurationMaterial from .BaseCloudModel import BaseCloudModel diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobStatus.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobStatus.py index 45b7d838a5..a4bc46e2d9 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobStatus.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrintJobStatus.py @@ -2,7 +2,7 @@ # Cura is released under the terms of the LGPLv3 or higher. from typing import List, Optional, Union, Dict, Any -from cura.PrinterOutput.ConfigurationModel import ConfigurationModel +from cura.UI.PrinterConfigurationModel import PrinterConfigurationModel from ...UM3PrintJobOutputModel import UM3PrintJobOutputModel from ...ConfigurationChangeModel import ConfigurationChangeModel from ..CloudOutputController import CloudOutputController @@ -95,9 +95,9 @@ class CloudClusterPrintJobStatus(BaseCloudModel): return model ## Creates a new configuration model - def _createConfigurationModel(self) -> ConfigurationModel: + def _createConfigurationModel(self) -> PrinterConfigurationModel: extruders = [extruder.createConfigurationModel() for extruder in self.configuration or ()] - configuration = ConfigurationModel() + configuration = PrinterConfigurationModel() configuration.setExtruderConfigurations(extruders) return configuration diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterConfigurationMaterial.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterConfigurationMaterial.py index 652cbdabda..73e54c8141 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterConfigurationMaterial.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterConfigurationMaterial.py @@ -2,7 +2,7 @@ from typing import Optional from UM.Logger import Logger from cura.CuraApplication import CuraApplication -from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel +from cura.UI.MaterialOutputModel import MaterialOutputModel from .BaseCloudModel import BaseCloudModel diff --git a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterStatus.py b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterStatus.py index bd3e482bde..65ce770192 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterStatus.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/Models/CloudClusterPrinterStatus.py @@ -3,7 +3,7 @@ from typing import List, Union, Dict, Optional, Any from cura.PrinterOutput.PrinterOutputController import PrinterOutputController -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel +from cura.UI.PrinterOutputModel import PrinterOutputModel from .CloudClusterBuildPlate import CloudClusterBuildPlate from .CloudClusterPrintCoreConfiguration import CloudClusterPrintCoreConfiguration from .BaseCloudModel import BaseCloudModel diff --git a/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py index 1d97127637..1312ab2129 100644 --- a/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py @@ -19,12 +19,12 @@ from UM.Scene.SceneNode import SceneNode # For typing. from UM.Settings.ContainerRegistry import ContainerRegistry from cura.CuraApplication import CuraApplication -from cura.PrinterOutput.ConfigurationModel import ConfigurationModel -from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel +from cura.UI.PrinterConfigurationModel import PrinterConfigurationModel +from cura.UI.ExtruderConfigurationModel import ExtruderConfigurationModel from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState, NetworkedPrinterOutputDevice -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel -from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel -from cura.PrinterOutputDevice import ConnectionType +from cura.UI.PrinterOutputModel import PrinterOutputModel +from cura.UI.MaterialOutputModel import MaterialOutputModel +from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from .Cloud.Utils import formatTimeCompleted, formatDateCompleted from .ClusterUM3PrinterOutputController import ClusterUM3PrinterOutputController @@ -522,7 +522,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): print_job = UM3PrintJobOutputModel(output_controller=ClusterUM3PrinterOutputController(self), key=data["uuid"], name= data["name"]) - configuration = ConfigurationModel() + configuration = PrinterConfigurationModel() extruders = [ExtruderConfigurationModel(position = idx) for idx in range(0, self._number_of_extruders)] for index in range(0, self._number_of_extruders): try: diff --git a/plugins/UM3NetworkPrinting/src/ClusterUM3PrinterOutputController.py b/plugins/UM3NetworkPrinting/src/ClusterUM3PrinterOutputController.py index fc6798386a..1d5dcd2c79 100644 --- a/plugins/UM3NetworkPrinting/src/ClusterUM3PrinterOutputController.py +++ b/plugins/UM3NetworkPrinting/src/ClusterUM3PrinterOutputController.py @@ -5,7 +5,7 @@ from cura.PrinterOutput.PrinterOutputController import PrinterOutputController MYPY = False if MYPY: - from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel + from cura.UI.PrintJobOutputModel import PrintJobOutputModel class ClusterUM3PrinterOutputController(PrinterOutputController): def __init__(self, output_device): diff --git a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py index 51c234650b..4cb8119d37 100644 --- a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py +++ b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py @@ -18,7 +18,7 @@ from cura.Settings.CuraContainerRegistry import CuraContainerRegistry from .UM3OutputDevicePlugin import UM3OutputDevicePlugin if TYPE_CHECKING: - from cura.PrinterOutputDevice import PrinterOutputDevice + from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice catalog = i18nCatalog("cura") diff --git a/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py b/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py index 2c7c33d382..55a4a57026 100644 --- a/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py @@ -2,10 +2,10 @@ from typing import List, Optional from cura.CuraApplication import CuraApplication from cura.PrinterOutput.NetworkedPrinterOutputDevice import NetworkedPrinterOutputDevice, AuthState -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel -from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel -from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel -from cura.PrinterOutputDevice import ConnectionType +from cura.UI.PrinterOutputModel import PrinterOutputModel +from cura.UI.PrintJobOutputModel import PrintJobOutputModel +from cura.UI.MaterialOutputModel import MaterialOutputModel +from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from cura.Settings.ContainerManager import ContainerManager from cura.Settings.ExtruderManager import ExtruderManager diff --git a/plugins/UM3NetworkPrinting/src/LegacyUM3PrinterOutputController.py b/plugins/UM3NetworkPrinting/src/LegacyUM3PrinterOutputController.py index 63167b4ffb..089a083275 100644 --- a/plugins/UM3NetworkPrinting/src/LegacyUM3PrinterOutputController.py +++ b/plugins/UM3NetworkPrinting/src/LegacyUM3PrinterOutputController.py @@ -7,8 +7,8 @@ from UM.Version import Version MYPY = False if MYPY: - from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel - from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel + from cura.UI.PrintJobOutputModel import PrintJobOutputModel + from cura.UI.PrinterOutputModel import PrinterOutputModel class LegacyUM3PrinterOutputController(PrinterOutputController): diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index d0fc543cd6..b0fffe8e37 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -5,16 +5,16 @@ from queue import Queue from threading import Event, Thread from time import time import os +from typing import Optional, TYPE_CHECKING from zeroconf import Zeroconf, ServiceBrowser, ServiceStateChange, ServiceInfo from PyQt5.QtNetwork import QNetworkRequest, QNetworkAccessManager -from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QObject +from PyQt5.QtCore import QUrl from PyQt5.QtGui import QDesktopServices from cura.CuraApplication import CuraApplication -from cura.PrinterOutputDevice import ConnectionType -from cura.Settings.GlobalStack import GlobalStack # typing -from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin +from cura.PrinterOutput.PrinterOutputDevice import ConnectionType + from UM.OutputDevice.OutputDeviceManager import ManualDeviceAdditionAttempt from UM.i18n import i18nCatalog @@ -28,10 +28,13 @@ from UM.Version import Version from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager -from typing import Optional +if TYPE_CHECKING: + from cura.Settings.GlobalStack import GlobalStack + from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin i18n_catalog = i18nCatalog("cura") + ## This plugin handles the connection detection & creation of output device objects for the UM3 printer. # Zero-Conf is used to detect printers, which are saved in a dict. # If we discover a printer that has the same key as the active machine instance a connection is made. @@ -448,7 +451,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): Logger.log("d", "Checking if cloud connection is possible...") # Pre-Check: Skip if active machine already has been cloud connected or you said don't ask again - active_machine = self._application.getMachineManager().activeMachine # type: Optional["GlobalStack"] + active_machine = self._application.getMachineManager().activeMachine # type: Optional[GlobalStack] if active_machine: # Check 1A: Printer isn't already configured for cloud @@ -536,7 +539,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): return def _onDontAskMeAgain(self, checked: bool) -> None: - active_machine = self._application.getMachineManager().activeMachine # type: Optional["GlobalStack"] + active_machine = self._application.getMachineManager().activeMachine # type: Optional[GlobalStack] if active_machine: active_machine.setMetaDataEntry("do_not_show_cloud_message", checked) if checked: diff --git a/plugins/UM3NetworkPrinting/src/UM3PrintJobOutputModel.py b/plugins/UM3NetworkPrinting/src/UM3PrintJobOutputModel.py index 4f44ca4af8..e51a891f58 100644 --- a/plugins/UM3NetworkPrinting/src/UM3PrintJobOutputModel.py +++ b/plugins/UM3NetworkPrinting/src/UM3PrintJobOutputModel.py @@ -5,7 +5,7 @@ from typing import List from PyQt5.QtCore import pyqtProperty, pyqtSignal -from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel +from cura.UI.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.PrinterOutputController import PrinterOutputController from .ConfigurationChangeModel import ConfigurationChangeModel diff --git a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py index c4d891302e..2cbf2def50 100644 --- a/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/tests/Cloud/TestCloudOutputDevice.py @@ -6,7 +6,7 @@ from unittest.mock import patch, MagicMock from UM.Scene.SceneNode import SceneNode from cura.UltimakerCloudAuthentication import CuraCloudAPIRoot -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel +from cura.UI.PrinterOutputModel import PrinterOutputModel from ...src.Cloud import CloudApiClient from ...src.Cloud.CloudOutputDevice import CloudOutputDevice from ...src.Cloud.Models.CloudClusterResponse import CloudClusterResponse diff --git a/plugins/USBPrinting/AvrFirmwareUpdater.py b/plugins/USBPrinting/AvrFirmwareUpdater.py index 56e3f99c23..0f7146560d 100644 --- a/plugins/USBPrinting/AvrFirmwareUpdater.py +++ b/plugins/USBPrinting/AvrFirmwareUpdater.py @@ -13,7 +13,7 @@ from time import sleep MYPY = False if MYPY: - from cura.PrinterOutputDevice import PrinterOutputDevice + from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice class AvrFirmwareUpdater(FirmwareUpdater): diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 3375ac27e7..43a91584fa 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -7,9 +7,9 @@ from UM.i18n import i18nCatalog from UM.Qt.Duration import DurationFormat from cura.CuraApplication import CuraApplication -from cura.PrinterOutputDevice import PrinterOutputDevice, ConnectionState, ConnectionType -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel -from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel +from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionState, ConnectionType +from cura.UI.PrinterOutputModel import PrinterOutputModel +from cura.UI.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.GenericOutputController import GenericOutputController from .AutoDetectBaudJob import AutoDetectBaudJob diff --git a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py index d4c0d1828e..f84a1bb175 100644 --- a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py +++ b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py @@ -5,15 +5,13 @@ import threading import time import serial.tools.list_ports -from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal +from PyQt5.QtCore import QObject, pyqtSignal -from UM.Logger import Logger from UM.Signal import Signal, signalemitter from UM.OutputDevice.OutputDevicePlugin import OutputDevicePlugin from UM.i18n import i18nCatalog -from cura.PrinterOutputDevice import ConnectionState -from cura.CuraApplication import CuraApplication +from cura.PrinterOutput.PrinterOutputDevice import ConnectionState from . import USBPrinterOutputDevice diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.py b/plugins/UltimakerMachineActions/BedLevelMachineAction.py index d6de21c89b..818ad0e4f0 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.py +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.py @@ -4,7 +4,7 @@ from typing import List from cura.MachineAction import MachineAction -from cura.PrinterOutputDevice import PrinterOutputDevice +from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice from UM.FlameProfiler import pyqtSlot diff --git a/plugins/VersionUpgrade/VersionUpgrade35to40/VersionUpgrade35to40.py b/plugins/VersionUpgrade/VersionUpgrade35to40/VersionUpgrade35to40.py index 900c0a7396..71ce2e4fd0 100644 --- a/plugins/VersionUpgrade/VersionUpgrade35to40/VersionUpgrade35to40.py +++ b/plugins/VersionUpgrade/VersionUpgrade35to40/VersionUpgrade35to40.py @@ -3,7 +3,7 @@ from typing import Tuple, List, Set, Dict import io from UM.VersionUpgrade import VersionUpgrade -from cura.PrinterOutputDevice import ConnectionType +from cura.PrinterOutput.PrinterOutputDevice import ConnectionType deleted_settings = {"bridge_wall_max_overhang"} # type: Set[str] renamed_configurations = {"connect_group_name": "group_name"} # type: Dict[str, str] diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index 206f99af00..c35e845993 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -69,18 +69,9 @@ Item property alias browsePackages: browsePackagesAction - property alias showOnBoarding: showOnBoarding - UM.I18nCatalog{id: catalog; name: "cura"} - Controls2.Action - { - id: showOnBoarding - text: catalog.i18nc("@action:inmenu", "Show On boarding") - shortcut: "Ctrl+Alt+D" - } - Action { id: showTroubleShootingAction diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 6af28d3e7b..d71f219052 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -58,16 +58,6 @@ UM.MainWindow z: stageMenu.z + 1 } - Connections - { - target: Cura.Actions.showOnBoarding - onTriggered: - { - welcomeDialog.currentStep = 0 - welcomeDialog.show() - } - } - Component.onCompleted: { CuraApplication.setMinimumWindowSize(UM.Theme.getSize("window_minimum_size")) diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index 98958360a8..9bb17470c8 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -16,7 +16,7 @@ UM.ManagementPage title: catalog.i18nc("@title:tab", "Printers"); model: Cura.GlobalStacksModel { } - sectionRole: "sectionName" + sectionRole: "discoverySource" activeId: Cura.MachineManager.activeMachineId activeIndex: activeMachineIndex() diff --git a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml index 2e85117d5c..2eb05a0530 100644 --- a/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml +++ b/resources/qml/WelcomePages/AddLocalPrinterScrollView.qml @@ -23,7 +23,7 @@ ScrollView property string preferredCategory: "Ultimaker" ScrollBar.horizontal.policy: ScrollBar.AlwaysOff - ScrollBar.vertical.policy: ScrollBar.AlwaysOn + ScrollBar.vertical.policy: ScrollBar.AsNeeded property int maxItemCountAtOnce: 10 // show at max 10 items at once, otherwise you need to scroll. height: maxItemCountAtOnce * UM.Theme.getSize("action_button").height @@ -100,7 +100,6 @@ ScrollView { id: arrow anchors.left: parent.left - //anchors.verticalCenter: label.verticalCenter width: UM.Theme.getSize("standard_arrow").width height: UM.Theme.getSize("standard_arrow").height sourceSize.width: width @@ -162,7 +161,8 @@ ScrollView border.width: UM.Theme.getSize("default_lining").width border.color: radioButton.hovered ? UM.Theme.getColor("small_button_text") : UM.Theme.getColor("small_button_text_hover") - Rectangle { + Rectangle + { width: parent.width / 2 height: width anchors.centerIn: parent diff --git a/resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml b/resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml index bee0c49e92..f3c5b88723 100644 --- a/resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml +++ b/resources/qml/WelcomePages/AddNetworkPrinterScrollView.qml @@ -56,7 +56,7 @@ Item anchors.right: parent.right ScrollBar.horizontal.policy: ScrollBar.AsNeeded - ScrollBar.vertical.policy: ScrollBar.AlwaysOn + ScrollBar.vertical.policy: ScrollBar.AsNeeded property int maxItemCountAtOnce: 8 // show at max 8 items at once, otherwise you need to scroll. height: maxItemCountAtOnce * UM.Theme.getSize("action_button").height diff --git a/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py b/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py index b3f7277051..da3ce66ac4 100644 --- a/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py +++ b/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py @@ -4,7 +4,7 @@ from unittest.mock import MagicMock from PyQt5.QtNetwork import QNetworkAccessManager from PyQt5.QtCore import QUrl from cura.PrinterOutput.NetworkedPrinterOutputDevice import NetworkedPrinterOutputDevice, AuthState -from cura.PrinterOutputDevice import ConnectionState +from cura.PrinterOutput.PrinterOutputDevice import ConnectionState def test_properties(): diff --git a/tests/TestPrinterOutputDevice.py b/tests/PrinterOutput/TestPrinterOutputDevice.py similarity index 90% rename from tests/TestPrinterOutputDevice.py rename to tests/PrinterOutput/TestPrinterOutputDevice.py index 9d3a337c21..4c12a34859 100644 --- a/tests/TestPrinterOutputDevice.py +++ b/tests/PrinterOutput/TestPrinterOutputDevice.py @@ -1,7 +1,7 @@ from unittest.mock import MagicMock import pytest -from cura.PrinterOutputDevice import PrinterOutputDevice +from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice test_validate_data_get_set = [ {"attribute": "connectionText", "value": "yay"}, @@ -34,4 +34,4 @@ def test_getAndSet(data): # Attempt to set the value again getattr(model, "set" + attribute)(data["value"]) # The signal should not fire again - assert signal.emit.call_count == 1 \ No newline at end of file + assert signal.emit.call_count == 1 diff --git a/tests/Settings/TestSettingVisibilityPresets.py b/tests/Settings/TestSettingVisibilityPresets.py index b82aa62ea7..13089e8aa6 100644 --- a/tests/Settings/TestSettingVisibilityPresets.py +++ b/tests/Settings/TestSettingVisibilityPresets.py @@ -5,7 +5,7 @@ import os.path from UM.Preferences import Preferences from UM.Resources import Resources from cura.CuraApplication import CuraApplication -from cura.Machines.Models.SettingVisibilityPresetsModel import SettingVisibilityPresetsModel +from cura.UI.MachineModels.SettingVisibilityPresetsModel import SettingVisibilityPresetsModel from cura.Settings.SettingVisibilityPreset import SettingVisibilityPreset setting_visibility_preset_test_settings = {"test", "zomg", "derp", "yay", "whoo"} diff --git a/tests/TestMachineAction.py b/tests/TestMachineAction.py index f1487a1d9f..9b0cb0a4a0 100755 --- a/tests/TestMachineAction.py +++ b/tests/TestMachineAction.py @@ -4,7 +4,7 @@ import pytest from cura.MachineAction import MachineAction -from cura.MachineActionManager import NotUniqueMachineActionError, UnknownMachineActionError +from cura.UI.MachineActionManager import NotUniqueMachineActionError, UnknownMachineActionError from cura.Settings.GlobalStack import GlobalStack diff --git a/tests/TestPrintInformation.py b/tests/TestPrintInformation.py index 177643bc90..66af734d89 100644 --- a/tests/TestPrintInformation.py +++ b/tests/TestPrintInformation.py @@ -1,7 +1,7 @@ import functools from UM.Qt.Duration import Duration -from cura import PrintInformation +from cura.UI import PrintInformation from cura.Settings.MachineManager import MachineManager from unittest.mock import MagicMock, patch diff --git a/tests/PrinterOutput/TestPrintJobOutputModel.py b/tests/UI/TestPrintJobOutputModel.py similarity index 89% rename from tests/PrinterOutput/TestPrintJobOutputModel.py rename to tests/UI/TestPrintJobOutputModel.py index 658cff7a7e..71a08c223c 100644 --- a/tests/PrinterOutput/TestPrintJobOutputModel.py +++ b/tests/UI/TestPrintJobOutputModel.py @@ -2,16 +2,16 @@ from unittest.mock import MagicMock import pytest -from cura.PrinterOutput.ConfigurationModel import ConfigurationModel -from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel +from cura.UI.PrinterConfigurationModel import PrinterConfigurationModel +from cura.UI.PrintJobOutputModel import PrintJobOutputModel +from cura.UI.PrinterOutputModel import PrinterOutputModel test_validate_data_get_set = [ {"attribute": "compatibleMachineFamilies", "value": ["yay"]}, ] test_validate_data_get_update = [ - {"attribute": "configuration", "value": ConfigurationModel()}, + {"attribute": "configuration", "value": PrinterConfigurationModel()}, {"attribute": "owner", "value": "WHOO"}, {"attribute": "assignedPrinter", "value": PrinterOutputModel(MagicMock())}, {"attribute": "key", "value": "YAY"}, diff --git a/tests/PrinterOutput/TestConfigurationModel.py b/tests/UI/TestPrinterConfigurationModel.py similarity index 86% rename from tests/PrinterOutput/TestConfigurationModel.py rename to tests/UI/TestPrinterConfigurationModel.py index d6b7b885c2..e365aaebf6 100644 --- a/tests/PrinterOutput/TestConfigurationModel.py +++ b/tests/UI/TestPrinterConfigurationModel.py @@ -4,8 +4,8 @@ from unittest.mock import MagicMock import pytest -from cura.PrinterOutput.ConfigurationModel import ConfigurationModel -from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel +from cura.UI.PrinterConfigurationModel import PrinterConfigurationModel +from cura.UI.ExtruderConfigurationModel import ExtruderConfigurationModel test_validate_data_get_set = [ {"attribute": "extruderConfigurations", "value": [ExtruderConfigurationModel()]}, @@ -16,7 +16,7 @@ test_validate_data_get_set = [ @pytest.mark.parametrize("data", test_validate_data_get_set) def test_getAndSet(data): - model = ConfigurationModel() + model = PrinterConfigurationModel() # Convert the first letter into a capital attribute = list(data["attribute"]) diff --git a/tests/PrinterOutput/TestPrinterOutputModel.py b/tests/UI/TestPrinterOutputModel.py similarity index 94% rename from tests/PrinterOutput/TestPrinterOutputModel.py rename to tests/UI/TestPrinterOutputModel.py index f42149d50f..e0d57b90dc 100644 --- a/tests/PrinterOutput/TestPrinterOutputModel.py +++ b/tests/UI/TestPrinterOutputModel.py @@ -4,8 +4,8 @@ from unittest.mock import MagicMock import pytest -from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel -from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel +from cura.UI.PrintJobOutputModel import PrintJobOutputModel +from cura.UI.PrinterOutputModel import PrinterOutputModel test_validate_data_get_set = [ {"attribute": "name", "value": "YAY"}, diff --git a/tests/conftest.py b/tests/conftest.py index b21b32b028..5336c28fba 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,11 +6,8 @@ import unittest.mock import pytest -import Arcus #Prevents error: "PyCapsule_GetPointer called with incorrect name" with conflicting SIP configurations between Arcus and PyQt: Import Arcus and Savitar first! -import Savitar -from UM.Qt.QtApplication import QtApplication #QtApplication import is required, even though it isn't used. from cura.CuraApplication import CuraApplication -from cura.MachineActionManager import MachineActionManager +from cura.UI.MachineActionManager import MachineActionManager # Create a CuraApplication object that will be shared among all tests. It needs to be initialized.