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:
authorCampbell Barton <ideasman42@gmail.com>2018-11-20 02:06:02 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-20 02:06:02 +0300
commit47139c69d7e46975c273a8f6981aca9e5cdda1d1 (patch)
treec20f21cdfa23f46ac018ff33af1839e5dc7a66fa /source/blender/windowmanager
parent750690ae7a5c5331921dede7e62b095619154c70 (diff)
Keymap: only use delete confirmation for X-key
Only use confirmation w/ X-key since this is more likely to be pressed by accident. Delete-key delete doesn't confirm. Part of D3953 by @Zachman w/ edits
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_api.h4
-rw-r--r--source/blender/windowmanager/intern/wm_operator_props.c9
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c12
3 files changed, 24 insertions, 1 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 7628217d88f..8e12ac96ea3 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -287,7 +287,8 @@ void WM_menu_name_call(struct bContext *C, const char *menu_name, short context
int WM_enum_search_invoke_previews(struct bContext *C, struct wmOperator *op, short prv_cols, short prv_rows);
int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
/* invoke callback, confirm menu + exec */
-int WM_operator_confirm (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
+int WM_operator_confirm(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
+int WM_operator_confirm_or_exec(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
/* invoke callback, file selector "filepath" unset + exec */
int WM_operator_filesel (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
bool WM_operator_filesel_ensure_ext_imtype(wmOperator *op, const struct ImageFormatData *im_format);
@@ -348,6 +349,7 @@ bool WM_operator_last_properties_store(struct wmOperator *op);
/* wm_operator_props.c */
+void WM_operator_properties_confirm_or_exec(struct wmOperatorType *ot);
void WM_operator_properties_filesel(
struct wmOperatorType *ot, int filter, short type, short action,
short flag, short display, short sort);
diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c
index 4515223f829..f8fa652ed63 100644
--- a/source/blender/windowmanager/intern/wm_operator_props.c
+++ b/source/blender/windowmanager/intern/wm_operator_props.c
@@ -44,6 +44,15 @@
#include "WM_api.h"
#include "WM_types.h"
+
+void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_boolean(ot->srna, "confirm", true, "Confirm", "Prompt for confirmation");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+}
+
/* default properties for fileselect */
void WM_operator_properties_filesel(
wmOperatorType *ot, int filter, short type, short action,
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 1bb79755e46..e0bd48dfec1 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -863,6 +863,18 @@ int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event
return WM_operator_confirm_message(C, op, NULL);
}
+int WM_operator_confirm_or_exec(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ const bool confirm = RNA_boolean_get(op->ptr, "confirm");
+ if (confirm) {
+ return WM_operator_confirm_message(C, op, NULL);
+ }
+ else {
+ return op->type->exec(C, op);
+ }
+}
+
+
/* op->invoke, opens fileselect if path property not set, otherwise executes */
int WM_operator_filesel(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{