mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 17:55:52 +08:00
Extract UI boot from non-UI boot
This commit is contained in:
parent
3246480111
commit
5b43a32986
@ -637,12 +637,34 @@ class CuraApplication(QtApplication):
|
|||||||
def run(self):
|
def run(self):
|
||||||
self.preRun()
|
self.preRun()
|
||||||
|
|
||||||
self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Setting up scene..."))
|
# Check if we should run as single instance or not
|
||||||
|
|
||||||
self._setUpSingleInstanceServer()
|
self._setUpSingleInstanceServer()
|
||||||
|
|
||||||
|
# Detect in which mode to run and execute that mode
|
||||||
|
if self.getCommandLineOption("headless", False):
|
||||||
|
self.runWithoutGUI()
|
||||||
|
else:
|
||||||
|
self.runWithGUI()
|
||||||
|
|
||||||
|
## Run Cura without GUI elements and interaction (server mode).
|
||||||
|
def runWithoutGUI(self):
|
||||||
|
self.closeSplash()
|
||||||
|
|
||||||
|
for file_name in self.getCommandLineOption("file", []):
|
||||||
|
self._openFile(file_name)
|
||||||
|
for file_name in self._open_file_queue: # Open all the files that were queued up while plug-ins were loading.
|
||||||
|
self._openFile(file_name)
|
||||||
|
|
||||||
|
self._started = True
|
||||||
|
self.exec_()
|
||||||
|
|
||||||
|
## Run Cura with GUI (desktop mode).
|
||||||
|
def runWithGUI(self):
|
||||||
|
self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Setting up scene..."))
|
||||||
|
|
||||||
controller = self.getController()
|
controller = self.getController()
|
||||||
|
|
||||||
|
# Initialize UI state
|
||||||
controller.setActiveStage("PrepareStage")
|
controller.setActiveStage("PrepareStage")
|
||||||
controller.setActiveView("SolidView")
|
controller.setActiveView("SolidView")
|
||||||
controller.setCameraTool("CameraTool")
|
controller.setCameraTool("CameraTool")
|
||||||
@ -662,8 +684,10 @@ class CuraApplication(QtApplication):
|
|||||||
# Set the build volume of the arranger to the used build volume
|
# Set the build volume of the arranger to the used build volume
|
||||||
Arrange.build_volume = self._volume
|
Arrange.build_volume = self._volume
|
||||||
|
|
||||||
|
# Set default background color for scene
|
||||||
self.getRenderer().setBackgroundColor(QColor(245, 245, 245))
|
self.getRenderer().setBackgroundColor(QColor(245, 245, 245))
|
||||||
|
|
||||||
|
# Initialize platform physics
|
||||||
self._physics = PlatformPhysics.PlatformPhysics(controller, self._volume)
|
self._physics = PlatformPhysics.PlatformPhysics(controller, self._volume)
|
||||||
|
|
||||||
camera = Camera("3d", root)
|
camera = Camera("3d", root)
|
||||||
@ -691,21 +715,15 @@ class CuraApplication(QtApplication):
|
|||||||
self.setMainQml(Resources.getPath(self.ResourceTypes.QmlFiles, "Cura.qml"))
|
self.setMainQml(Resources.getPath(self.ResourceTypes.QmlFiles, "Cura.qml"))
|
||||||
self._qml_import_paths.append(Resources.getPath(self.ResourceTypes.QmlFiles))
|
self._qml_import_paths.append(Resources.getPath(self.ResourceTypes.QmlFiles))
|
||||||
|
|
||||||
run_without_gui = self.getCommandLineOption("headless", False)
|
|
||||||
if not run_without_gui:
|
|
||||||
self.initializeEngine()
|
self.initializeEngine()
|
||||||
|
|
||||||
|
# Make sure the correct stage is activated
|
||||||
controller.setActiveStage("PrepareStage")
|
controller.setActiveStage("PrepareStage")
|
||||||
|
|
||||||
if run_without_gui or self._engine.rootObjects:
|
# Hide the splash screen
|
||||||
self.closeSplash()
|
self.closeSplash()
|
||||||
|
|
||||||
for file_name in self.getCommandLineOption("file", []):
|
|
||||||
self._openFile(file_name)
|
|
||||||
for file_name in self._open_file_queue: #Open all the files that were queued up while plug-ins were loading.
|
|
||||||
self._openFile(file_name)
|
|
||||||
|
|
||||||
self._started = True
|
self._started = True
|
||||||
|
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
def getMachineManager(self, *args) -> MachineManager:
|
def getMachineManager(self, *args) -> MachineManager:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user