forked from bartvdbraak/blender
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:
parent
43973410f3
commit
50e3cd0bb3
@ -296,8 +296,10 @@ def _kmistr(kmi, is_modal):
|
|||||||
return "".join(s)
|
return "".join(s)
|
||||||
|
|
||||||
|
|
||||||
def keyconfig_export(wm, kc, filepath):
|
def keyconfig_export(
|
||||||
|
wm, kc, filepath, *,
|
||||||
|
all_keymaps=False,
|
||||||
|
):
|
||||||
f = open(filepath, "w")
|
f = open(filepath, "w")
|
||||||
|
|
||||||
f.write("import bpy\n")
|
f.write("import bpy\n")
|
||||||
@ -327,7 +329,7 @@ def keyconfig_export(wm, kc, filepath):
|
|||||||
keymaps = []
|
keymaps = []
|
||||||
edited_kc = FakeKeyConfig()
|
edited_kc = FakeKeyConfig()
|
||||||
for km in wm.keyconfigs.user.keymaps:
|
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)
|
edited_kc.keymaps.append(km)
|
||||||
# merge edited keymaps with non-default keyconfig, if it exists
|
# merge edited keymaps with non-default keyconfig, if it exists
|
||||||
if kc != wm.keyconfigs.default:
|
if kc != wm.keyconfigs.default:
|
||||||
|
@ -1629,6 +1629,11 @@ class WM_OT_keyconfig_export(Operator):
|
|||||||
bl_idname = "wm.keyconfig_export"
|
bl_idname = "wm.keyconfig_export"
|
||||||
bl_label = "Export Key Configuration..."
|
bl_label = "Export Key Configuration..."
|
||||||
|
|
||||||
|
all_keymaps = BoolProperty(
|
||||||
|
name="All Keymaps",
|
||||||
|
default=False,
|
||||||
|
description="Write all keymaps (not just user modified)",
|
||||||
|
)
|
||||||
filepath = StringProperty(
|
filepath = StringProperty(
|
||||||
subtype='FILE_PATH',
|
subtype='FILE_PATH',
|
||||||
default="keymap.py",
|
default="keymap.py",
|
||||||
@ -1664,6 +1669,7 @@ class WM_OT_keyconfig_export(Operator):
|
|||||||
wm,
|
wm,
|
||||||
wm.keyconfigs.active,
|
wm.keyconfigs.active,
|
||||||
self.filepath,
|
self.filepath,
|
||||||
|
all_keymaps=self.all_keymaps,
|
||||||
)
|
)
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
Loading…
Reference in New Issue
Block a user