From 192e5d65a746798f6bddf897570ff8aba55c9c5a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jul 2018 17:51:31 +0200 Subject: [PATCH] Keymap: add generally useful popups to F-Keys 1..4 This allows key bindings: link/append and user-preferences to be accessed via keys - without having to assign keys to each action. - F1: Context sensitive help. - F2: File Context Menu. - F3: Search. - F4: Window Context Menu. Other keys F5..10, remain free, ideally they can be kept for user actions. --- release/scripts/startup/bl_ui/space_topbar.py | 37 +++++++++++++++++++ .../windowmanager/intern/wm_operators.c | 7 +++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 19516fda301..f54a5903801 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -579,11 +579,48 @@ class INFO_MT_help(Menu): layout.operator("wm.splash", icon='BLENDER') +class TOPBAR_MT_file_specials(Menu): + bl_label = "File Context Menu" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'INVOKE_AREA' + layout.operator("wm.link", text="Link", icon='LINK_BLEND') + layout.operator("wm.append", text="Append", icon='APPEND_BLEND') + + layout.separator() + + layout.menu("INFO_MT_file_import", icon='IMPORT') + layout.menu("INFO_MT_file_export", icon='EXPORT') + + +class TOPBAR_MT_window_specials(Menu): + bl_label = "Window Context Menu" + + def draw(self, context): + layout = self.layout + + layout.operator_context = 'EXEC_AREA' + + layout.operator("wm.window_new") + + layout.operator_context = 'INVOKE_AREA' + + layout.operator("screen.area_dupli") + + layout.separator() + + layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES') + + classes = ( TOPBAR_HT_upper_bar, TOPBAR_HT_lower_bar, TOPBAR_PT_pivot_point, TOPBAR_PT_snapping, + TOPBAR_MT_file_specials, + TOPBAR_MT_window_specials, INFO_MT_editor_menus, INFO_MT_file, INFO_MT_file_import, diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 496c9b1eb19..7a48d7e012c 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3986,11 +3986,14 @@ void wm_window_keymap(wmKeyConfig *keyconf) /* debug/testing */ WM_keymap_verify_item(keymap, "WM_OT_redraw_timer", TKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); +#else + WM_keymap_add_item(keymap, "WM_OT_doc_view_manual_ui_context", F1KEY, KM_PRESS, 0, 0); + WM_keymap_add_menu(keymap, "TOPBAR_MT_file_specials", F2KEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "WM_OT_search_menu", F3KEY, KM_PRESS, 0, 0); + WM_keymap_add_menu(keymap, "TOPBAR_MT_window_specials", F4KEY, KM_PRESS, 0, 0); #endif /* menus that can be accessed anywhere in blender */ - - WM_keymap_add_item(keymap, "WM_OT_search_menu", F3KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "WM_OT_search_menu", ACCENTGRAVEKEY, KM_CLICK, 0, 0); WM_keymap_add_menu(keymap, "SCREEN_MT_user_menu", QKEY, KM_PRESS, 0, 0);