Keymap: option to export all keymaps

Useful to store a snapshot of the current keymap state
so changes to the default keymap are ignored.

Also useful for testing keymap export works properly.
This commit is contained in:
Campbell Barton 2018-07-14 10:15:46 +02:00
parent 43973410f3
commit 50e3cd0bb3
2 changed files with 11 additions and 3 deletions

View File

@ -296,8 +296,10 @@ def _kmistr(kmi, is_modal):
return "".join(s)
def keyconfig_export(wm, kc, filepath):
def keyconfig_export(
wm, kc, filepath, *,
all_keymaps=False,
):
f = open(filepath, "w")
f.write("import bpy\n")
@ -327,7 +329,7 @@ def keyconfig_export(wm, kc, filepath):
keymaps = []
edited_kc = FakeKeyConfig()
for km in wm.keyconfigs.user.keymaps:
if km.is_user_modified:
if all_keymaps or km.is_user_modified:
edited_kc.keymaps.append(km)
# merge edited keymaps with non-default keyconfig, if it exists
if kc != wm.keyconfigs.default:

View File

@ -1629,6 +1629,11 @@ class WM_OT_keyconfig_export(Operator):
bl_idname = "wm.keyconfig_export"
bl_label = "Export Key Configuration..."
all_keymaps = BoolProperty(
name="All Keymaps",
default=False,
description="Write all keymaps (not just user modified)",
)
filepath = StringProperty(
subtype='FILE_PATH',
default="keymap.py",
@ -1664,6 +1669,7 @@ class WM_OT_keyconfig_export(Operator):
wm,
wm.keyconfigs.active,
self.filepath,
all_keymaps=self.all_keymaps,
)
return {'FINISHED'}