mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Merge branch 'master' of https://github.com/TheDrawingCoder-Gamer/nheko into TheDrawingCoder-Gamer-master
This commit is contained in:
commit
d4b7712a66
12 changed files with 5058 additions and 2967 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@ cscope*
|
|||
/.exrc
|
||||
.gdb_history
|
||||
.hunter
|
||||
resources/complete-emoji.txt
|
||||
|
||||
# GTAGS
|
||||
GTAGS
|
||||
|
|
27
resources/extra_emoji.txt
Normal file
27
resources/extra_emoji.txt
Normal file
|
@ -0,0 +1,27 @@
|
|||
# group: Symbols
|
||||
200C 1F1E6 200C ; fully-qualified # 🇦 E6.0 regional indicator a
|
||||
200C 1F1E7 200C ; fully-qualified # 🇧 E6.0 regional indicator b
|
||||
200C 1F1E8 200C ; fully-qualified # 🇨 E6.0 regional indicator c
|
||||
200C 1F1E9 200C ; fully-qualified # 🇩 E6.0 regional indicator d
|
||||
200C 1F1EA 200C ; fully-qualified # 🇪 E6.0 regional indicator e
|
||||
200C 1F1EB 200C ; fully-qualified # 🇫 E6.0 regional indicator f
|
||||
200C 1F1EC 200C ; fully-qualified # 🇬 E6.0 regional indicator g
|
||||
200C 1F1ED 200C ; fully-qualified # 🇭 E6.0 regional indicator h
|
||||
200C 1F1EE 200C ; fully-qualified # 🇮 E6.0 regional indicator i
|
||||
200C 1F1EF 200C ; fully-qualified # 🇯 E6.0 regional indicator j
|
||||
200C 1F1F0 200C ; fully-qualified # 🇰 E6.0 regional indicator k
|
||||
200C 1F1F1 200C ; fully-qualified # 🇱 E6.0 regional indicator l
|
||||
200C 1F1F2 200C ; fully-qualified # 🇲 E6.0 regional indicator m
|
||||
200C 1F1F3 200C ; fully-qualified # 🇳 E6.0 regional indicator n
|
||||
200C 1F1F4 200C ; fully-qualified # 🇴 E6.0 regional indicator o
|
||||
200C 1F1F5 200C ; fully-qualified # 🇵 E6.0 regional indicator p
|
||||
200C 1F1F6 200C ; fully-qualified # 🇶 E6.0 regional indicator q
|
||||
200C 1F1F7 200C ; fully-qualified # 🇷 E6.0 regional indicator r
|
||||
200C 1F1F8 200C ; fully-qualified # 🇸 E6.0 regional indicator s
|
||||
200C 1F1F9 200C ; fully-qualified # 🇹 E6.0 regional indicator t
|
||||
200C 1F1FA 200C ; fully-qualified # 🇺 E6.0 regional indicator u
|
||||
200C 1F1FB 200C ; fully-qualified # 🇻 E6.0 regional indicator v
|
||||
200C 1F1FC 200C ; fully-qualified # 🇼 E6.0 regional indicator w
|
||||
200C 1F1FD 200C ; fully-qualified # 🇽 E6.0 regional indicator x
|
||||
200C 1F1FE 200C ; fully-qualified # 🇾 E6.0 regional indicator y
|
||||
200C 1F1FF 200C ; fully-qualified # 🇿 E6.0 regional indicator z
|
10
resources/provider-header.txt
Normal file
10
resources/provider-header.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||||
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "emoji/Provider.h"
|
||||
|
||||
using namespace emoji;
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ Menu {
|
|||
width: 48
|
||||
height: 48
|
||||
hoverEnabled: true
|
||||
ToolTip.text: model.shortName
|
||||
ToolTip.text: model.toolTip
|
||||
ToolTip.visible: hovered
|
||||
// TODO: maybe add favorites at some point?
|
||||
onClicked: {
|
||||
|
|
55
resources/shortcodes.txt
Normal file
55
resources/shortcodes.txt
Normal file
|
@ -0,0 +1,55 @@
|
|||
1F62D:sob
|
||||
1F631:scream
|
||||
1F613:sweat
|
||||
1F605:sweat_smile
|
||||
1F604:smile
|
||||
1F923:rofl
|
||||
1F60B:yum
|
||||
1F607:innocent
|
||||
1F917:hugging_face
|
||||
26A1:zap
|
||||
203C FE0F:bangbang
|
||||
2049 FE0F:interrobang
|
||||
2753:question
|
||||
2757:exclamation
|
||||
2754:white_question
|
||||
2755:white_exclamation
|
||||
1F520:big_abcd
|
||||
1F521:abcd
|
||||
1F522:1234
|
||||
1F523:symbols
|
||||
1F524:abc
|
||||
1F60D:heart_eyes
|
||||
1F927:cry_smile
|
||||
1F608:smiling_imp
|
||||
1F47F:imp
|
||||
1F261:rage
|
||||
1F624:triumph
|
||||
1F63A:smiley_cat
|
||||
1F638:smile_cat
|
||||
1F639:joy_cat
|
||||
1F63B:heart_eyes_cat
|
||||
1F63C:smirk_cat
|
||||
1F640:scream_cat
|
||||
1F4AF:100
|
||||
1F44B:wave
|
||||
1F448:point_left
|
||||
1F449:point_right
|
||||
1F446:point_up_2
|
||||
1F447:point_down
|
||||
261D FE0F:point_up
|
||||
1FAF5:point_you
|
||||
1F937:shrug
|
||||
0023 FE0F 20E3:hash
|
||||
002A FE0F 20E3:asterisk
|
||||
0030 FE0F 20E3:zero
|
||||
0031 FE0F 20E3:one
|
||||
0032 FE0F 20E3:two
|
||||
0033 FE0F 20E3:three
|
||||
0034 FE0F 20E3:four
|
||||
0035 FE0F 20E3:five
|
||||
0036 FE0F 20E3:six
|
||||
0037 FE0F 20E3:seven
|
||||
0038 FE0F 20E3:eight
|
||||
0039 FE0F 20E3:nine
|
||||
1F51F:ten
|
7
scripts/codegen.sh
Normal file
7
scripts/codegen.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
ROOT=$(realpath "$PWD/$(dirname "$0")/..")
|
||||
cd $ROOT
|
||||
cat resources/provider-header.txt > src/emoji/Provider.cpp
|
||||
cat resources/extra_emoji.txt resources/emoji-test.txt > resources/complete-emoji.txt
|
||||
scripts/emoji_codegen.py resources/complete-emoji.txt resources/shortcodes.txt >> src/emoji/Provider.cpp
|
||||
cd - > /dev/null
|
|
@ -2,14 +2,15 @@
|
|||
|
||||
import sys
|
||||
import re
|
||||
|
||||
from unidecode import unidecode
|
||||
from jinja2 import Template
|
||||
|
||||
|
||||
class Emoji(object):
|
||||
def __init__(self, code, shortname):
|
||||
def __init__(self, code, shortname, unicodename):
|
||||
self.code = ''.join(['\\U'+c.rjust(8, '0') for c in code.strip().split(' ')])
|
||||
self.shortname = shortname
|
||||
self.unicodename = unicodename
|
||||
|
||||
def generate_qml_list(**kwargs):
|
||||
tmpl = Template('''
|
||||
|
@ -17,20 +18,20 @@ const QVector<Emoji> emoji::Provider::emoji = {
|
|||
{%- for c in kwargs.items() %}
|
||||
// {{ c[0].capitalize() }}
|
||||
{%- for e in c[1] %}
|
||||
Emoji{QStringLiteral(u"{{ e.code }}"), QStringLiteral(u"{{ e.shortname }}"), emoji::Emoji::Category::{{ c[0].capitalize() }}},
|
||||
Emoji{QStringLiteral(u"{{ e.code }}"), QStringLiteral(u"{{ e.shortname }}"), QStringLiteral(u"{{ e.unicodename }}"), emoji::Emoji::Category::{{ c[0].capitalize() }}},
|
||||
{%- endfor %}
|
||||
{%- endfor %}
|
||||
};
|
||||
''')
|
||||
d = dict(kwargs=kwargs)
|
||||
print(tmpl.render(d))
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2:
|
||||
print('usage: emoji_codegen.py /path/to/emoji-test.txt')
|
||||
if len(sys.argv) < 3:
|
||||
print('usage: emoji_codegen.py /path/to/emoji-test.txt /path/to/shortcodes.txt')
|
||||
sys.exit(1)
|
||||
|
||||
filename = sys.argv[1]
|
||||
shortcodefilename = sys.argv[2]
|
||||
|
||||
people = []
|
||||
nature = []
|
||||
|
@ -50,9 +51,14 @@ if __name__ == '__main__':
|
|||
'Activities': activity,
|
||||
'Objects': objects,
|
||||
'Symbols': symbols,
|
||||
'Flags': flags
|
||||
'Flags': flags,
|
||||
'Component': symbols
|
||||
}
|
||||
|
||||
shortcodeDict = {}
|
||||
# for my sanity - this strips newlines
|
||||
for line in open(shortcodefilename, 'r', encoding="utf8"):
|
||||
longname, shortname = line.strip().split(':')
|
||||
shortcodeDict[longname] = shortname
|
||||
current_category = ''
|
||||
for line in open(filename, 'r', encoding="utf8"):
|
||||
if line.startswith('# group:'):
|
||||
|
@ -68,16 +74,65 @@ if __name__ == '__main__':
|
|||
code, qualification, charAndName = segments
|
||||
|
||||
# skip unqualified versions of same unicode
|
||||
if qualification == 'unqualified':
|
||||
if qualification != 'fully-qualified':
|
||||
continue
|
||||
|
||||
if qualification == 'component':
|
||||
continue
|
||||
|
||||
char, name = re.match(r'^(\S+) E\d+\.\d+ (.*)$', charAndName).groups()
|
||||
shortname = name
|
||||
# until skin tone is handled, keep them around
|
||||
# discard skin tone variants for sanity
|
||||
# __contains__ is so stupid i hate prototype languages
|
||||
# if name.__contains__("skin tone") and qualification != 'component':
|
||||
# continue
|
||||
# if qualification == 'component' and not name.__contains__("skin tone"):
|
||||
# continue
|
||||
#TODO: Handle skintone modifiers in a sane way
|
||||
basicallyTheSame = False
|
||||
if code in shortcodeDict:
|
||||
shortname = shortcodeDict[code]
|
||||
else:
|
||||
shortname = shortname.lower()
|
||||
if shortname.endswith(' (blood type)'):
|
||||
shortname = shortname[:-13]
|
||||
if shortname.endswith(': red hair'):
|
||||
shortname = "red_haired_" + shortname[:-10]
|
||||
if shortname.endswith(': curly hair'):
|
||||
shortname = "curly_haired_" + shortname[:-12]
|
||||
if shortname.endswith(': white hair'):
|
||||
shortname = "white_haried_" + shortname[:-12]
|
||||
if shortname.endswith(': bald'):
|
||||
shortname = "bald_" + shortname[:-6]
|
||||
if shortname.endswith(': beard'):
|
||||
shortname = "bearded_" + shortname[:-7]
|
||||
if shortname.endswith(' face'):
|
||||
shortname = shortname[:-5]
|
||||
if shortname.endswith(' button'):
|
||||
shortname = shortname[:-7]
|
||||
if shortname.endswith(' banknote'):
|
||||
shortname = shortname[:-9]
|
||||
|
||||
categories[current_category].append(Emoji(code, name))
|
||||
# FIXME: Is there a better way to do this?
|
||||
matchobj = re.match(r'^flag: (.*)$', shortname)
|
||||
if shortname.startswith("flag: "):
|
||||
country = shortname[5:]
|
||||
shortname = country + " flag"
|
||||
shortname = shortname.replace("u.s.", "us")
|
||||
shortname = shortname.replace("&", "and")
|
||||
|
||||
if shortname == name.lower():
|
||||
basicallyTheSame = True
|
||||
|
||||
shortname = shortname.replace("-", "_")
|
||||
shortname = re.sub(r'\W', '_', shortname)
|
||||
shortname, = re.match(r'^_*(.+)_*$', shortname).groups()
|
||||
shortname = re.sub(r'_{2,}', '_', shortname)
|
||||
shortname = unidecode(shortname)
|
||||
# if basicallyTheSame:
|
||||
# shortname = ""
|
||||
categories[current_category].append(Emoji(code, shortname, name))
|
||||
|
||||
# Use xclip to pipe the output to clipboard.
|
||||
# e.g ./codegen.py emoji.json | xclip -sel clip
|
||||
# alternatively - delete the var from src/emoji/Provider.cpp, and do ./codegen.py emojis shortcodes >> src/emoji/Provider.cpp
|
||||
generate_qml_list(people=people, nature=nature, food=food, activity=activity, travel=travel, objects=objects, symbols=symbols, flags=flags)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
1. Get the latest emoji-test.txt from here: https://unicode.org/Public/emoji/
|
||||
2. Overwrite the existing resources/emoji-test.txt with the new one
|
||||
3. Run `./scripts/emoji_codegen.py resources/emoji-test.txt` and replace the current tail of src/emoji/Provider.cpp with the new output
|
||||
3. Run `./scripts/emoji_codegen.py resources/emoji-test.txt resources/shortcodes.txt` and replace the current tail of src/emoji/Provider.cpp with the new output
|
||||
4. `make lint`
|
||||
5. Compile and test
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ EmojiModel::roleNames() const
|
|||
roles = QAbstractListModel::roleNames();
|
||||
roles[static_cast<int>(EmojiModel::Roles::Unicode)] = QByteArrayLiteral("unicode");
|
||||
roles[static_cast<int>(EmojiModel::Roles::ShortName)] = QByteArrayLiteral("shortName");
|
||||
roles[static_cast<int>(EmojiModel::Roles::UnicodeName)] = QByteArrayLiteral("unicodeName");
|
||||
roles[static_cast<int>(EmojiModel::Roles::Category)] = QByteArrayLiteral("category");
|
||||
roles[static_cast<int>(EmojiModel::Roles::Emoji)] = QByteArrayLiteral("emoji");
|
||||
}
|
||||
|
@ -58,10 +59,12 @@ EmojiModel::data(const QModelIndex &index, int role) const
|
|||
return Provider::emoji[index.row()].unicode;
|
||||
|
||||
case Qt::ToolTipRole:
|
||||
case CompletionModel::SearchRole2:
|
||||
case static_cast<int>(EmojiModel::Roles::UnicodeName):
|
||||
return Provider::emoji[index.row()].unicodeName;
|
||||
case CompletionModel::SearchRole:
|
||||
case static_cast<int>(EmojiModel::Roles::ShortName):
|
||||
return Provider::emoji[index.row()].shortName;
|
||||
|
||||
case static_cast<int>(EmojiModel::Roles::Category):
|
||||
return QVariant::fromValue(Provider::emoji[index.row()].category);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
Unicode = Qt::UserRole, // unicode of emoji
|
||||
Category, // category of emoji
|
||||
ShortName, // shortext of the emoji
|
||||
UnicodeName, // true unicode name of the emoji
|
||||
Emoji, // Contains everything from the Emoji
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -35,11 +35,13 @@ public:
|
|||
|
||||
Q_PROPERTY(const QString &unicode MEMBER unicode)
|
||||
Q_PROPERTY(const QString &shortName MEMBER shortName)
|
||||
Q_PROPERTY(const QString &unicodeName MEMBER unicodeName)
|
||||
Q_PROPERTY(emoji::Emoji::Category category MEMBER category)
|
||||
|
||||
public:
|
||||
QString unicode;
|
||||
QString shortName;
|
||||
QString unicodeName;
|
||||
Category category;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue