diff --git a/plugins/BlackBeltPlugin/BlackBeltPlugin.py b/plugins/BlackBeltPlugin/BlackBeltPlugin.py index 1e64fcf73d..1c61c28161 100644 --- a/plugins/BlackBeltPlugin/BlackBeltPlugin.py +++ b/plugins/BlackBeltPlugin/BlackBeltPlugin.py @@ -3,7 +3,6 @@ from UM.Extension import Extension from UM.Application import Application -from UM.Preferences import Preferences from UM.PluginRegistry import PluginRegistry from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Settings.SettingFunction import SettingFunction @@ -70,7 +69,7 @@ class BlackBeltPlugin(Extension): self._application.getController().activeViewChanged.connect(self._onActiveViewChanged) # Handle default setting visibility - preferences = Preferences.getInstance() + preferences = self._application.getPreferences() preferences.preferenceChanged.connect(self._onPreferencesChanged) if self._configurationNeedsUpdates(): Logger.log("d", "BlackBelt-specific updates to configuration are needed") @@ -81,10 +80,10 @@ class BlackBeltPlugin(Extension): preferences.setValue("cura/active_setting_visibility_preset", "blackbelt") # Disable USB printing output device - Application.getInstance().getOutputDeviceManager().outputDevicesChanged.connect(self._onOutputDevicesChanged) + self._application.getOutputDeviceManager().outputDevicesChanged.connect(self._onOutputDevicesChanged) def _configurationNeedsUpdates(self): - preferences = Preferences.getInstance() + preferences = self._application.getPreferences() preferences.addPreference("blackbelt/setting_version", "0.0.0") # Get version information from plugin.json @@ -110,11 +109,11 @@ class BlackBeltPlugin(Extension): self._application.getMachineManager().activeQualityChanged.connect(self._onActiveQualityChanged) # Set window title - self._application._engine.rootObjects()[0].setTitle(i18n_catalog.i18nc("@title:window","BlackBelt Cura")) + self._application._qml_engine.rootObjects()[0].setTitle(i18n_catalog.i18nc("@title:window","BlackBelt Cura")) # Substitute our own sidebar sidebar_component_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "sidebar", "PrepareSidebar.qml") - prepare_stage = Application.getInstance().getController().getStage("PrepareStage") + prepare_stage = self._application.getController().getStage("PrepareStage") prepare_stage.addDisplayComponent("sidebar", sidebar_component_path) # Apply patches @@ -143,7 +142,7 @@ class BlackBeltPlugin(Extension): # HACK: Remove USB output device for blackbelt printers devices_to_remove = [] - output_device_manager = Application.getInstance().getOutputDeviceManager() + output_device_manager = self._application.getOutputDeviceManager() for output_device in output_device_manager.getOutputDevices(): if "USBPrinterOutputDevice" in str(output_device): self._output_device_patches[output_device] = USBPrinterOutputDevicePatches.USBPrinterOutputDevicePatches(output_device) @@ -248,7 +247,7 @@ class BlackBeltPlugin(Extension): def _fixVisibilityPreferences(self, forced = False): # Fix setting visibility preferences - preferences = Preferences.getInstance() + preferences = self._application.getPreferences() visible_settings = preferences.getValue("general/visible_settings") if not visible_settings: # Wait until the default visible settings have been set @@ -277,7 +276,7 @@ class BlackBeltPlugin(Extension): self._adjustLayerViewNozzle() def _adjustLayerViewNozzle(self): - global_stack = Application.getInstance().getGlobalContainerStack() + global_stack = self._application.getGlobalContainerStack() if not global_stack: return @@ -291,13 +290,13 @@ class BlackBeltPlugin(Extension): def _filterGcode(self, output_device): - global_stack = Application.getInstance().getGlobalContainerStack() + global_stack = self._application.getGlobalContainerStack() definition_container = self._global_container_stack.getBottom() if definition_container.getId() != "blackbelt": return - scene = Application.getInstance().getController().getScene() + scene = self._application.getController().getScene() gcode_dict = getattr(scene, "gcode_dict", {}) if not gcode_dict: # this also checks for an empty dict Logger.log("w", "Scene has no gcode to process") diff --git a/plugins/BlackBeltPlugin/BuildVolumePatches.py b/plugins/BlackBeltPlugin/BuildVolumePatches.py index 3fb2ba5963..131f75d99d 100644 --- a/plugins/BlackBeltPlugin/BuildVolumePatches.py +++ b/plugins/BlackBeltPlugin/BuildVolumePatches.py @@ -20,7 +20,7 @@ class BuildVolumePatches(): if not self._build_volume._width or not self._build_volume._height or not self._build_volume._depth: return - if not Application.getInstance()._engine: + if not self._build_volume._engine_ready: return if not self._build_volume._volume_outline_color: diff --git a/plugins/BlackBeltPlugin/CuraApplicationPatches.py b/plugins/BlackBeltPlugin/CuraApplicationPatches.py index 54d100052e..180649fa53 100644 --- a/plugins/BlackBeltPlugin/CuraApplicationPatches.py +++ b/plugins/BlackBeltPlugin/CuraApplicationPatches.py @@ -1,5 +1,3 @@ -from UM.Preferences import Preferences - from UM.Math.Vector import Vector from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation @@ -62,6 +60,8 @@ class CuraApplicationPatches(): if not global_container_stack: return + preferences = self._application.getPreferences() + definition_container = global_container_stack.getBottom() is_blackbelt_printer = definition_container.getId() == "blackbelt" ### END PATCH @@ -71,9 +71,10 @@ class CuraApplicationPatches(): self._application._currently_loading_files.remove(filename) self._application.fileLoaded.emit(filename) + arrange_objects_on_load = ( - not Preferences.getInstance().getValue("cura/use_multi_build_plate") or - not Preferences.getInstance().getValue("cura/not_arrange_objects_on_load")) + not preferences.getValue("cura/use_multi_build_plate") or + not preferences.getValue("cura/not_arrange_objects_on_load")) target_build_plate = self._application.getMultiBuildPlateModel().activeBuildPlate if arrange_objects_on_load else -1 root = self._application.getController().getScene().getRoot() @@ -89,7 +90,7 @@ class CuraApplicationPatches(): default_extruder_position = self._application.getMachineManager().defaultExtruderPosition default_extruder_id = self._application._global_container_stack.extruders[default_extruder_position].getId() - select_models_on_load = Preferences.getInstance().getValue("cura/select_models_on_load") + select_models_on_load = preferences.getValue("cura/select_models_on_load") for original_node in nodes: diff --git a/plugins/BlackBeltPlugin/ProcessSlicedLayersJob.py b/plugins/BlackBeltPlugin/ProcessSlicedLayersJob.py index a5ecce6c21..51448d2f96 100644 --- a/plugins/BlackBeltPlugin/ProcessSlicedLayersJob.py +++ b/plugins/BlackBeltPlugin/ProcessSlicedLayersJob.py @@ -255,7 +255,7 @@ class ProcessSlicedLayersJob(Job): material_color_map[0, :] = color # We have to scale the colors for compatibility mode - if OpenGLContext.isLegacyOpenGL() or bool(Preferences.getInstance().getValue("view/force_layer_view_compatibility_mode")): + if OpenGLContext.isLegacyOpenGL() or bool(Application.getInstance().getPreferences().getValue("view/force_layer_view_compatibility_mode")): line_type_brightness = 0.5 # for compatibility mode else: line_type_brightness = 1.0