From ca41548626f5f49a769dc018ab54d7ed06c05489 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 24 Apr 2019 17:45:34 +0200 Subject: UI: Simple confirm dialog when loading new file I also had to make the "New" operator a submenu in the `File Context Menu`, so that you can still select the template. This partially solves T61599. Currently the confirm dialog is not shown when an already existing file is opened. Implementing that requires a bit more work and will be done in a separate patch. Reviewers: brecht Differential Revision: https://developer.blender.org/D4732 --- source/blender/windowmanager/intern/wm_files.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index c3642e7f7e7..d75853d623d 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1846,6 +1846,17 @@ static int wm_homefile_read_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static int wm_homefile_read_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + wmWindowManager *wm = CTX_wm_manager(C); + if (U.uiflag & USER_SAVE_PROMPT && !wm->file_saved) { + return WM_operator_confirm_message(C, op, "Changes in current file will be lost. Continue?"); + } + else { + return wm_homefile_read_exec(C, op); + } +} + void WM_OT_read_homefile(wmOperatorType *ot) { PropertyRNA *prop; @@ -1853,6 +1864,7 @@ void WM_OT_read_homefile(wmOperatorType *ot) ot->idname = "WM_OT_read_homefile"; ot->description = "Open the default file (doesn't save the current file)"; + ot->invoke = wm_homefile_read_invoke; ot->exec = wm_homefile_read_exec; prop = RNA_def_string_file_path( -- cgit v1.2.3