mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 03:37:48 -06:00
Add use_gui flag in application, don't use theme functions when not using gui
This commit is contained in:
parent
1a05fd5989
commit
bd1bf2caaf
2 changed files with 19 additions and 2 deletions
|
@ -142,6 +142,7 @@ class CuraApplication(QtApplication):
|
|||
if not hasattr(sys, "frozen"):
|
||||
Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources"))
|
||||
|
||||
self._use_gui = True
|
||||
self._open_file_queue = [] # Files to open when plug-ins are loaded.
|
||||
|
||||
# Need to do this before ContainerRegistry tries to load the machines
|
||||
|
@ -451,7 +452,7 @@ class CuraApplication(QtApplication):
|
|||
elif choice == "always_keep":
|
||||
# don't show dialog and KEEP the profile
|
||||
self.discardOrKeepProfileChangesClosed("keep")
|
||||
else:
|
||||
elif self._use_gui:
|
||||
# ALWAYS ask whether to keep or discard the profile
|
||||
self.showDiscardOrKeepProfileChanges.emit()
|
||||
has_user_interaction = True
|
||||
|
@ -676,10 +677,13 @@ class CuraApplication(QtApplication):
|
|||
|
||||
## Run Cura without GUI elements and interaction (server mode).
|
||||
def runWithoutGUI(self):
|
||||
self._use_gui = False
|
||||
self.closeSplash()
|
||||
|
||||
## Run Cura with GUI (desktop mode).
|
||||
def runWithGUI(self):
|
||||
self._use_gui = True
|
||||
|
||||
self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Setting up scene..."))
|
||||
|
||||
controller = self.getController()
|
||||
|
@ -732,6 +736,9 @@ class CuraApplication(QtApplication):
|
|||
# Hide the splash screen
|
||||
self.closeSplash()
|
||||
|
||||
def hasGui(self):
|
||||
return self._use_gui
|
||||
|
||||
def getMachineManager(self, *args) -> MachineManager:
|
||||
if self._machine_manager is None:
|
||||
self._machine_manager = MachineManager.createMachineManager()
|
||||
|
@ -1344,6 +1351,7 @@ class CuraApplication(QtApplication):
|
|||
pass
|
||||
|
||||
fileLoaded = pyqtSignal(str)
|
||||
fileCompleted = pyqtSignal(str)
|
||||
|
||||
def _reloadMeshFinished(self, job):
|
||||
# TODO; This needs to be fixed properly. We now make the assumption that we only load a single mesh!
|
||||
|
@ -1353,6 +1361,10 @@ class CuraApplication(QtApplication):
|
|||
else:
|
||||
Logger.log("w", "Could not find a mesh in reloaded node.")
|
||||
|
||||
## Import a file from disk
|
||||
def openFile(self, filename):
|
||||
self._openFile(filename)
|
||||
|
||||
def _openFile(self, filename):
|
||||
self.readLocalFile(QUrl.fromLocalFile(filename))
|
||||
|
||||
|
@ -1514,6 +1526,8 @@ class CuraApplication(QtApplication):
|
|||
op.push()
|
||||
scene.sceneChanged.emit(node)
|
||||
|
||||
self.fileCompleted.emit(filename)
|
||||
|
||||
def addNonSliceableExtension(self, extension):
|
||||
self._non_sliceable_extensions.append(extension)
|
||||
|
||||
|
|
|
@ -24,7 +24,10 @@ class ConvexHullNode(SceneNode):
|
|||
self._original_parent = parent
|
||||
|
||||
# Color of the drawn convex hull
|
||||
if Application.getInstance().hasGui():
|
||||
self._color = Color(*Application.getInstance().getTheme().getColor("convex_hull").getRgb())
|
||||
else:
|
||||
self._color = Color(0, 0, 0)
|
||||
|
||||
# The y-coordinate of the convex hull mesh. Must not be 0, to prevent z-fighting.
|
||||
self._mesh_height = 0.1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue