diff options
author | Joseph Donofry <joedonofry@gmail.com> | 2020-05-13 00:35:26 -0400 |
---|---|---|
committer | Joseph Donofry <joedonofry@gmail.com> | 2020-05-13 00:36:41 -0400 |
commit | ee4dcef90f285f49ee27fec13afb486d93781b8b (patch) | |
tree | e6e4313098ef2c2fa4841fa7d6310825b08c0c4b /scripts | |
parent | Initial support for sending reactions (diff) | |
download | nheko-ee4dcef90f285f49ee27fec13afb486d93781b8b.tar.xz |
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.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/emoji_codegen.py | 17 |
1 files changed, 16 insertions, 1 deletions
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> 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> emoji::Provider::{{ category }} = { d = dict(category=category, emoji=emojis) print(tmpl.render(d)) +def generate_qml_list(**kwargs): + tmpl = Template(''' +const QVector<Emoji> 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 |