From ee4dcef90f285f49ee27fec13afb486d93781b8b Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Wed, 13 May 2020 00:35:26 -0400 Subject: Add new QML-based emoji picker (work in progress) This is necessary to support having a picker within QML. Eventually, this should replace the existing widget-based one. --- scripts/emoji_codegen.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/emoji_codegen.py b/scripts/emoji_codegen.py index 634887b2..4dbb382d 100755 --- a/scripts/emoji_codegen.py +++ b/scripts/emoji_codegen.py @@ -14,8 +14,9 @@ class Emoji(object): def generate_code(emojis, category): tmpl = Template(''' const std::vector emoji::Provider::{{ category }} = { + // {{ category.capitalize() }} {%- for e in emoji %} - Emoji{QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}"}, + {QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", emoji::Emoji::Category::{{ category.capitalize() }}}, {%- endfor %} }; ''') @@ -23,6 +24,19 @@ const std::vector emoji::Provider::{{ category }} = { d = dict(category=category, emoji=emojis) print(tmpl.render(d)) +def generate_qml_list(**kwargs): + tmpl = Template(''' +const QVector emoji::Provider::emoji = { + {%- for c in kwargs.items() %} + // {{ c[0].capitalize() }} + {%- for e in c[1] %} + {QString::fromUtf8("{{ e.code }}"), "{{ e.shortname }}", emoji::Emoji::Category::{{ c[0].capitalize() }}}, + {%- endfor %} + {%- endfor %} +}; + ''') + d = dict(kwargs=kwargs) + print(tmpl.render(d)) if __name__ == '__main__': if len(sys.argv) < 2: @@ -87,3 +101,4 @@ if __name__ == '__main__': generate_code(objects, 'objects') generate_code(symbols, 'symbols') generate_code(flags, 'flags') + generate_qml_list(people=people, nature=nature, food=food, activity=activity, travel=travel, objects=objects, symbols=symbols, flags=flags) \ No newline at end of file -- cgit 1.4.1