Merge branch 'master' into blender2.8

This commit is contained in:
Campbell Barton 2018-07-14 10:22:15 +02:00
commit 9dbee5ccc2
3 changed files with 13 additions and 5 deletions

View File

@ -295,8 +295,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")
@ -326,7 +328,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

@ -122,7 +122,7 @@ def _kmi_attrs_or_none(level, kmi):
return "".join(lines)
def keyconfig_export_as_data(wm, kc, filepath):
def keyconfig_export_as_data(wm, kc, filepath, *, all_keymaps=False):
# Alternate foramt
# Generate a list of keymaps to export:
@ -140,7 +140,7 @@ def keyconfig_export_as_data(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

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