mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 11:17:49 -06:00
Add a preference to use a single instance for loading files
Contributes to #7664
This commit is contained in:
parent
47bf094c52
commit
1b34449242
2 changed files with 34 additions and 1 deletions
|
@ -304,6 +304,7 @@ class CuraApplication(QtApplication):
|
||||||
|
|
||||||
super().initialize()
|
super().initialize()
|
||||||
|
|
||||||
|
self._checkEarlyPreferences()
|
||||||
self.__sendCommandToSingleInstance()
|
self.__sendCommandToSingleInstance()
|
||||||
self._initializeSettingDefinitions()
|
self._initializeSettingDefinitions()
|
||||||
self._initializeSettingFunctions()
|
self._initializeSettingFunctions()
|
||||||
|
@ -314,6 +315,20 @@ class CuraApplication(QtApplication):
|
||||||
self._machine_action_manager = MachineActionManager.MachineActionManager(self)
|
self._machine_action_manager = MachineActionManager.MachineActionManager(self)
|
||||||
self._machine_action_manager.initialize()
|
self._machine_action_manager.initialize()
|
||||||
|
|
||||||
|
def _checkEarlyPreferences(self) -> None:
|
||||||
|
# Check for specific preferences early in the bootstrap process, without spinning up the full Preference singleton yet
|
||||||
|
if self._use_single_instance:
|
||||||
|
return
|
||||||
|
|
||||||
|
preferences_file = Resources.getPath(Resources.Preferences, "{}.cfg".format(self.getApplicationName()))
|
||||||
|
if not os.path.exists(preferences_file):
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(preferences_file) as preferences:
|
||||||
|
if "single_instance = True" in preferences.read():
|
||||||
|
Logger.log("i", "Preference to use a single instance detected")
|
||||||
|
self._use_single_instance = True
|
||||||
|
|
||||||
def __sendCommandToSingleInstance(self):
|
def __sendCommandToSingleInstance(self):
|
||||||
self._single_instance = SingleInstance(self, self._files_to_open)
|
self._single_instance = SingleInstance(self, self._files_to_open)
|
||||||
|
|
||||||
|
@ -508,7 +523,7 @@ class CuraApplication(QtApplication):
|
||||||
preferences.setValue("metadata/setting_version", self.SettingVersion) #Don't make it equal to the default so that the setting version always gets written to the file.
|
preferences.setValue("metadata/setting_version", self.SettingVersion) #Don't make it equal to the default so that the setting version always gets written to the file.
|
||||||
|
|
||||||
preferences.addPreference("cura/active_mode", "simple")
|
preferences.addPreference("cura/active_mode", "simple")
|
||||||
|
preferences.addPreference("cura/single_instance", False)
|
||||||
preferences.addPreference("cura/categories_expanded", "")
|
preferences.addPreference("cura/categories_expanded", "")
|
||||||
preferences.addPreference("cura/jobname_prefix", True)
|
preferences.addPreference("cura/jobname_prefix", True)
|
||||||
preferences.addPreference("cura/select_models_on_load", False)
|
preferences.addPreference("cura/select_models_on_load", False)
|
||||||
|
|
|
@ -72,6 +72,9 @@ UM.PreferencesPage
|
||||||
var defaultTheme = UM.Preferences.getValue("general/theme")
|
var defaultTheme = UM.Preferences.getValue("general/theme")
|
||||||
setDefaultTheme(defaultTheme)
|
setDefaultTheme(defaultTheme)
|
||||||
|
|
||||||
|
UM.Preferences.resetPreference("cura/single_instance")
|
||||||
|
scaleToFitCheckbox.checked = boolCheck(UM.Preferences.getValue("cura/single_instance"))
|
||||||
|
|
||||||
UM.Preferences.resetPreference("physics/automatic_push_free")
|
UM.Preferences.resetPreference("physics/automatic_push_free")
|
||||||
pushFreeCheckbox.checked = boolCheck(UM.Preferences.getValue("physics/automatic_push_free"))
|
pushFreeCheckbox.checked = boolCheck(UM.Preferences.getValue("physics/automatic_push_free"))
|
||||||
UM.Preferences.resetPreference("physics/automatic_drop_down")
|
UM.Preferences.resetPreference("physics/automatic_drop_down")
|
||||||
|
@ -560,6 +563,21 @@ UM.PreferencesPage
|
||||||
text: catalog.i18nc("@label","Opening and saving files")
|
text: catalog.i18nc("@label","Opening and saving files")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UM.TooltipArea
|
||||||
|
{
|
||||||
|
width: childrenRect.width
|
||||||
|
height: childrenRect.height
|
||||||
|
text: catalog.i18nc("@info:tooltip","Should opening files from the desktop or external applications open in the same instance of Cura?")
|
||||||
|
|
||||||
|
CheckBox
|
||||||
|
{
|
||||||
|
id: singleInstanceCheckbox
|
||||||
|
text: catalog.i18nc("@option:check","Use a single instance of Cura")
|
||||||
|
checked: boolCheck(UM.Preferences.getValue("cura/single_instance"))
|
||||||
|
onCheckedChanged: UM.Preferences.setValue("cura/single_instance", checked)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UM.TooltipArea
|
UM.TooltipArea
|
||||||
{
|
{
|
||||||
width: childrenRect.width
|
width: childrenRect.width
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue