Preferences: support loading factory preferences

Previously it was only possible to load factory startup & preferences.
This commit is contained in:
2019-05-13 13:25:51 +10:00
parent ac94c219ae
commit a279bbbee5
5 changed files with 16 additions and 2 deletions

View File

@@ -84,6 +84,7 @@ class USERPREF_PT_save_preferences(Panel):
col = layout.column(align=True)
col.operator("wm.save_userpref")
col.operator("wm.read_userpref")
col.operator("wm.read_factory_userpref")
# Panel mix-in.

View File

@@ -438,7 +438,9 @@ bool BKE_blendfile_read_from_memory(bContext *C,
bfd = BLO_read_from_memory(filebuf, filelength, params->skip_flags, reports);
if (bfd) {
if (update_defaults) {
BLO_update_defaults_startup_blend(bfd->main, NULL);
if ((params->skip_flags & BLO_READ_SKIP_DATA) == 0) {
BLO_update_defaults_startup_blend(bfd->main, NULL);
}
}
setup_app_blend_file_data(C, bfd, "<memory2>", params, reports);

View File

@@ -1767,7 +1767,7 @@ static int wm_userpref_read_exec(bContext *C, wmOperator *op)
{
const bool use_data = false;
const bool use_userdef = true;
const bool use_factory_settings = false; /* TODO, support this. */
const bool use_factory_settings = STREQ(op->type->idname, "WM_OT_read_factory_userpref");
UserDef U_backup = U;
@@ -1810,6 +1810,15 @@ void WM_OT_read_userpref(wmOperatorType *ot)
ot->exec = wm_userpref_read_exec;
}
void WM_OT_read_factory_userpref(wmOperatorType *ot)
{
ot->name = "Load Factory Preferences";
ot->idname = "WM_OT_read_factory_userpref";
ot->invoke = WM_operator_confirm;
ot->exec = wm_userpref_read_exec;
}
static int wm_history_file_read_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
{
ED_file_read_bookmarks();

View File

@@ -3505,6 +3505,7 @@ void wm_operatortypes_register(void)
WM_operatortype_append(WM_OT_save_homefile);
WM_operatortype_append(WM_OT_save_userpref);
WM_operatortype_append(WM_OT_read_userpref);
WM_operatortype_append(WM_OT_read_factory_userpref);
WM_operatortype_append(WM_OT_userpref_autoexec_path_add);
WM_operatortype_append(WM_OT_userpref_autoexec_path_remove);
WM_operatortype_append(WM_OT_window_fullscreen_toggle);

View File

@@ -45,6 +45,7 @@ void WM_OT_userpref_autoexec_path_add(struct wmOperatorType *ot);
void WM_OT_userpref_autoexec_path_remove(struct wmOperatorType *ot);
void WM_OT_save_userpref(struct wmOperatorType *ot);
void WM_OT_read_userpref(struct wmOperatorType *ot);
void WM_OT_read_factory_userpref(struct wmOperatorType *ot);
void WM_OT_read_history(struct wmOperatorType *ot);
void WM_OT_read_homefile(struct wmOperatorType *ot);
void WM_OT_read_factory_settings(struct wmOperatorType *ot);