UI: default to searching menus instead of operators

Menus from the top-bar, space-header and key bindings are used
to gather menus to populate the search popup.

Giving better context and default options for operators.

Part of T74157

Enabling "Developer Extras" exposes operator search in the Edit menu,
as this can be useful for developers to run operators
without first exposing them in the interface.
This commit is contained in:
2020-04-16 00:32:30 +10:00
parent f83ccbc673
commit debd8aab4a
5 changed files with 20 additions and 31 deletions

View File

@@ -580,6 +580,8 @@ class TOPBAR_MT_edit(Menu):
def draw(self, context):
layout = self.layout
show_developer = context.preferences.view.show_developer_ui
layout.operator("ed.undo")
layout.operator("ed.redo")
@@ -598,8 +600,9 @@ class TOPBAR_MT_edit(Menu):
layout.separator()
layout.operator("wm.search_menu",
text="Operator Search...", icon='VIEWZOOM')
layout.operator("wm.search_menu", text="Menu Search...", icon='VIEWZOOM')
if show_developer:
layout.operator("wm.search_operator", text="Operator Search...", icon='VIEWZOOM')
layout.separator()

View File

@@ -2158,16 +2158,6 @@ class USERPREF_PT_experimental_virtual_reality(ExperimentalPanel, Panel):
)
"""
class USERPREF_PT_experimental_ui(ExperimentalPanel, Panel):
bl_label = "UI"
def draw(self, context):
self._draw_items(
context, (
({"property": "use_menu_search"}, "T74157"),
),
)
class USERPREF_PT_experimental_system(ExperimentalPanel, Panel):
bl_label = "System"
@@ -2270,7 +2260,6 @@ classes = (
# Popovers.
USERPREF_PT_ndof_settings,
USERPREF_PT_experimental_ui,
USERPREF_PT_experimental_system,
# Add dynamically generated editor theme panels last,

View File

@@ -619,9 +619,8 @@ typedef struct UserDef_FileSpaceData {
typedef struct UserDef_Experimental {
char use_undo_speedup;
char use_menu_search;
/** `makesdna` does not allow empty structs. */
char _pad0[6];
char _pad0[7];
} UserDef_Experimental;
#define USER_EXPERIMENTAL_TEST(userdef, member) \

View File

@@ -6063,10 +6063,6 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
prop,
"Undo Speedup",
"Use new undo speedup (WARNING: can lead to crashes and serious .blend file corruption)");
prop = RNA_def_property(srna, "use_menu_search", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "use_menu_search", 1);
RNA_def_property_ui_text(prop, "Menu Search", "Search actions by menus instead of operators");
}
static void rna_def_userdef_addon_collection(BlenderRNA *brna, PropertyRNA *cprop)

View File

@@ -1794,13 +1794,12 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *eve
}
}
PropertyRNA *prop = op->type->prop;
int search_type;
if (RNA_property_is_set(op->ptr, prop)) {
search_type = RNA_property_enum_get(op->ptr, prop);
if (STREQ(op->type->idname, "WM_OT_search_menu")) {
search_type = SEARCH_TYPE_MENU;
}
else {
search_type = U.experimental.use_menu_search ? SEARCH_TYPE_MENU : SEARCH_TYPE_OPERATOR;
search_type = SEARCH_TYPE_OPERATOR;
}
static struct SearchPopupInit_Data data;
@@ -1818,20 +1817,22 @@ static void WM_OT_search_menu(wmOperatorType *ot)
{
ot->name = "Search Menu";
ot->idname = "WM_OT_search_menu";
ot->description = "Pop-up a search menu over all available operators in current context";
ot->description = "Pop-up a search over all menus in the current context";
ot->invoke = wm_search_menu_invoke;
ot->exec = wm_search_menu_exec;
ot->poll = WM_operator_winactive;
}
static const EnumPropertyItem search_type_items[] = {
{SEARCH_TYPE_OPERATOR, "OPERATOR", 0, "Operator", "Search all operators"},
{SEARCH_TYPE_MENU, "MENU", 0, "Menu", "Search active menu items"},
{0, NULL, 0, NULL, NULL},
};
static void WM_OT_search_operator(wmOperatorType *ot)
{
ot->name = "Search Operator";
ot->idname = "WM_OT_search_operator";
ot->description = "Pop-up a search over all available operators in current context";
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", search_type_items, SEARCH_TYPE_OPERATOR, "Type", "");
ot->invoke = wm_search_menu_invoke;
ot->exec = wm_search_menu_exec;
ot->poll = WM_operator_winactive;
}
static int wm_call_menu_exec(bContext *C, wmOperator *op)
@@ -3806,6 +3807,7 @@ void wm_operatortypes_register(void)
WM_operatortype_append(WM_OT_operator_defaults);
WM_operatortype_append(WM_OT_splash);
WM_operatortype_append(WM_OT_search_menu);
WM_operatortype_append(WM_OT_search_operator);
WM_operatortype_append(WM_OT_call_menu);
WM_operatortype_append(WM_OT_call_menu_pie);
WM_operatortype_append(WM_OT_call_panel);