Skip to content

Commit d73e6e9

Browse files
committed
Use CuraApplication.callLater instead of QTimer
1 parent f83d32b commit d73e6e9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

SidebarGUIPlugin.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
# The SidebarGUIPlugin is released under the terms of the AGPLv3 or higher.
33

44
import os.path
5-
from UM.Application import Application
5+
from cura.CuraApplication import CuraApplication
66
from UM.Extension import Extension
77
from UM.Logger import Logger
8-
from PyQt6.QtCore import QTimer
98

109
from .SidebarGUIProxy import SidebarGUIProxy
1110

@@ -16,16 +15,16 @@ def __init__(self):
1615

1716
self._prepare_stage_view_id = "SolidView" # can be "SolidView" or "XRayView"
1817

19-
Application.getInstance().pluginsLoaded.connect(self._onPluginsLoaded)
20-
preferences = Application.getInstance().getPreferences()
18+
CuraApplication.getInstance().pluginsLoaded.connect(self._onPluginsLoaded)
19+
preferences = CuraApplication.getInstance().getPreferences()
2120
preferences.addPreference("sidebargui/expand_extruder_configuration", False)
2221
preferences.addPreference("sidebargui/expand_legend", True)
2322
preferences.addPreference("sidebargui/docked_sidebar", True)
2423
preferences.addPreference("sidebargui/settings_window_left", 65535)
2524
preferences.addPreference("sidebargui/settings_window_top", 65535)
2625
preferences.addPreference("sidebargui/settings_window_height", 0)
2726

28-
self._controller = Application.getInstance().getController()
27+
self._controller = CuraApplication.getInstance().getController()
2928
self._controller.activeStageChanged.connect(self._onStageChanged)
3029
self._controller.activeViewChanged.connect(self._onViewChanged)
3130

@@ -34,12 +33,12 @@ def __init__(self):
3433
def _onPluginsLoaded(self):
3534
# delayed connection to engineCreatedSignal to force this plugin to receive that signal
3635
# AFTER the original stages are created
37-
Application.getInstance().engineCreatedSignal.connect(self._onEngineCreated)
36+
CuraApplication.getInstance().engineCreatedSignal.connect(self._onEngineCreated)
3837

3938
def _onEngineCreated(self):
4039
Logger.log("d", "Registering replacement stages")
4140

42-
engine = Application.getInstance()._qml_engine
41+
engine = CuraApplication.getInstance()._qml_engine
4342
engine.rootContext().setContextProperty("SidebarGUIPlugin", self._proxy)
4443

4544
sidebar_component_path = os.path.join(
@@ -111,7 +110,9 @@ def _onViewChanged(self):
111110

112111
# Force machine settings update when PaintTool is activated to fix rendering issue
113112
if active_view_id == "PaintTool":
114-
QTimer.singleShot(0, lambda: Application.getInstance().getMachineManager().forceUpdateAllSettings())
113+
CuraApplication.getInstance().callLater(
114+
CuraApplication.getInstance().getMachineManager().forceUpdateAllSettings()
115+
)
115116

116117
if (
117118
active_stage_id == "SmartSlicePlugin"

0 commit comments

Comments
 (0)