From 00b4fdce2c39ef40dc11fb6631d8283f40f1cc08 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 6 Mar 2024 23:25:52 +0100 Subject: [PATCH] UI: Improvements to Confirmation of Load Factory A more informative confirmation dialog to confirm that the user wishes to load factory startup and settings. Pull Request: https://projects.blender.org/blender/blender/pulls/117153 --- .../blender/windowmanager/intern/wm_files.cc | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index f47f3a3c93b..d065ae13b9c 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -2782,6 +2782,37 @@ void WM_OT_read_homefile(wmOperatorType *ot) /* omit poll to run in background mode */ } +static int wm_read_factory_settings_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) +{ + const bool unsaved = wm_file_or_session_data_has_unsaved_changes(CTX_data_main(C), + CTX_wm_manager(C)); + std::string title; + const bool template_only = U.app_template[0] && + RNA_boolean_get(op->ptr, "use_factory_startup_app_template_only"); + + if (template_only) { + char display_name[FILE_MAX]; + BLI_path_to_display_name(display_name, sizeof(display_name), IFACE_(U.app_template)); + title = fmt::format(IFACE_("Load Factory \"{}\" Startup File and Preferences"), + IFACE_(display_name)); + } + else { + title = IFACE_("Load Factory Default Startup File and Preferences"); + } + + return WM_operator_confirm_ex( + C, + op, + title.c_str(), + unsaved ? IFACE_("To make changes to Preferences permanent, use \"Save " + "Preferences\"\nWarning: Your file is " + "unsaved! Proceeding will abandon your changes.") : + IFACE_("To make changes to Preferences permanent, use \"Save Preferences.\""), + IFACE_("Load"), + ALERT_ICON_WARNING, + false); +} + void WM_OT_read_factory_settings(wmOperatorType *ot) { ot->name = "Load Factory Settings"; @@ -2790,7 +2821,7 @@ void WM_OT_read_factory_settings(wmOperatorType *ot) "Load factory default startup file and preferences. " "To make changes permanent, use \"Save Startup File\" and \"Save Preferences\""; - ot->invoke = WM_operator_confirm; + ot->invoke = wm_read_factory_settings_invoke; ot->exec = wm_homefile_read_exec; /* Omit poll to run in background mode. */