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.
This commit is contained in:
@@ -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 */
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user