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:
authorJacques Lucke <mail@jlucke.com>2019-04-24 18:45:34 +0300
committerJacques Lucke <mail@jlucke.com>2019-04-24 18:45:34 +0300
commitca41548626f5f49a769dc018ab54d7ed06c05489 (patch)
tree6027ec36289a41d6914a117f6196469e113c2c32 /source/blender/windowmanager
parentea8026438104f7be178fcb06562932e4e3d2f094 (diff)
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
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c12
1 files changed, 12 insertions, 0 deletions
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(