Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-05-14 05:23:55 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-14 05:37:07 +0300
commit9c9081d9ef5bf97b39f316d68651f7e72266ac5d (patch)
treedb408338842281594a9c61e0b3e757620e547553
parent34da7f8fddcae003aa9740ba304e624b0154e4d8 (diff)
Preferences: file menu item to temporarily load factory settings
It's common to load factory settings as a test without wanting to overwrite your own settings on exit.
-rw-r--r--release/scripts/startup/bl_ui/space_topbar.py23
-rw-r--r--source/blender/blenkernel/BKE_global.h4
-rw-r--r--source/blender/windowmanager/intern/wm_files.c36
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c8
4 files changed, 46 insertions, 25 deletions
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index cb949560936..6da08a15db1 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -172,6 +172,7 @@ class TOPBAR_MT_file(Menu):
def draw(self, context):
layout = self.layout
+ prefs = context.preferences
layout.operator_context = 'INVOKE_AREA'
layout.menu("TOPBAR_MT_file_new", text="New", icon='FILE_NEW')
@@ -195,20 +196,26 @@ class TOPBAR_MT_file(Menu):
layout.operator_context = 'INVOKE_AREA'
if any(bpy.utils.app_template_paths()):
- app_template = context.preferences.app_template
+ app_template = prefs.app_template
else:
app_template = None
if app_template:
layout.label(text=bpy.path.display_name(app_template, has_ext=False))
- layout.operator("wm.save_homefile")
- layout.operator(
+
+ layout.operator("wm.save_homefile")
+ props = layout.operator("wm.read_factory_settings")
+ if app_template:
+ props.app_template = app_template
+
+ if prefs.use_preferences_save:
+ props = layout.operator(
"wm.read_factory_settings",
- text="Load Factory Settings",
- ).app_template = app_template
- else:
- layout.operator("wm.save_homefile")
- layout.operator("wm.read_factory_settings")
+ text="Load Factory Settings (Temporary)"
+ )
+ if app_template:
+ props.app_template = app_template
+ props.use_temporary_preferences = True
layout.separator()
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 2c19c1e2006..387e7f2182b 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -111,6 +111,7 @@ enum {
G_FLAG_PICKSEL = (1 << 2),
/** Support simulating events (for testing). */
G_FLAG_EVENT_SIMULATE = (1 << 3),
+ G_FLAG_USERPREF_NO_SAVE_ON_EXIT = (1 << 4),
G_FLAG_SCRIPT_AUTOEXEC = (1 << 13),
/** When this flag is set ignore the prefs #USER_SCRIPT_AUTOEXEC_DISABLE. */
@@ -121,7 +122,8 @@ enum {
/** Don't overwrite these flags when reading a file. */
#define G_FLAG_ALL_RUNTIME \
- (G_FLAG_SCRIPT_AUTOEXEC | G_FLAG_SCRIPT_OVERRIDE_PREF | G_FLAG_EVENT_SIMULATE)
+ (G_FLAG_SCRIPT_AUTOEXEC | G_FLAG_SCRIPT_OVERRIDE_PREF | G_FLAG_EVENT_SIMULATE | \
+ G_FLAG_USERPREF_NO_SAVE_ON_EXIT)
/** Flags to read from blend file. */
#define G_FLAG_ALL_READFILE 0
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 32bf3a9856f..cf02709f051 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1882,6 +1882,7 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
PropertyRNA *prop_app_template = RNA_struct_find_property(op->ptr, "app_template");
const bool use_splash = !use_factory_settings && RNA_boolean_get(op->ptr, "use_splash");
const bool use_empty_data = RNA_boolean_get(op->ptr, "use_empty");
+ const bool use_temporary_preferences = RNA_boolean_get(op->ptr, "use_temporary_preferences");
if (prop_app_template && RNA_property_is_set(op->ptr, prop_app_template)) {
RNA_property_string_get(op->ptr, prop_app_template, app_template_buf);
@@ -1912,6 +1913,8 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op)
if (use_splash) {
WM_init_splash(C);
}
+ SET_FLAG_FROM_TEST(G.f, use_temporary_preferences, G_FLAG_USERPREF_NO_SAVE_ON_EXIT);
+
return OPERATOR_FINISHED;
}
@@ -1926,6 +1929,24 @@ static int wm_homefile_read_invoke(bContext *C, wmOperator *op, const wmEvent *U
}
}
+static void read_homefile_props(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_string(ot->srna, "app_template", "Template", sizeof(U.app_template), "", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+
+ prop = RNA_def_boolean(ot->srna, "use_empty", false, "Empty", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+
+ prop = RNA_def_boolean(ot->srna,
+ "use_temporary_preferences",
+ false,
+ "Temporary Preferences",
+ "Don't save preferences on exit");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+}
+
void WM_OT_read_homefile(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -1945,23 +1966,17 @@ void WM_OT_read_homefile(wmOperatorType *ot)
ot->srna, "load_ui", true, "Load UI", "Load user interface setup from the .blend file");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
- prop = RNA_def_boolean(ot->srna, "use_empty", false, "Empty", "");
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
-
/* So the splash can be kept open after loading a file (for templates). */
prop = RNA_def_boolean(ot->srna, "use_splash", false, "Splash", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
- prop = RNA_def_string(ot->srna, "app_template", "Template", sizeof(U.app_template), "", "");
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ read_homefile_props(ot);
/* omit poll to run in background mode */
}
void WM_OT_read_factory_settings(wmOperatorType *ot)
{
- PropertyRNA *prop;
-
ot->name = "Load Factory Settings";
ot->idname = "WM_OT_read_factory_settings";
ot->description = "Load default file and preferences";
@@ -1969,12 +1984,7 @@ void WM_OT_read_factory_settings(wmOperatorType *ot)
ot->invoke = WM_operator_confirm;
ot->exec = wm_homefile_read_exec;
- prop = RNA_def_string(ot->srna, "app_template", "Template", sizeof(U.app_template), "", "");
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
-
- prop = RNA_def_boolean(ot->srna, "use_empty", false, "Empty", "");
- RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
-
+ read_homefile_props(ot);
/* omit poll to run in background mode */
}
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index 797a2edd937..04a3115992f 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -475,9 +475,11 @@ void WM_exit_ext(bContext *C, const bool do_python)
ED_screen_exit(C, win, WM_window_get_active_screen(win));
}
- if (U.runtime.is_dirty && !G.background) {
- if (U.pref_flag & USER_PREF_FLAG_SAVE) {
- BKE_blendfile_userdef_write_all(NULL);
+ if (!G.background) {
+ if ((U.pref_flag & USER_PREF_FLAG_SAVE) && ((G.f & G_FLAG_USERPREF_NO_SAVE_ON_EXIT) == 0)) {
+ if (U.runtime.is_dirty) {
+ BKE_blendfile_userdef_write_all(NULL);
+ }
}
}
}