summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThibault Meunier <thibault.meunier@isode.com>2016-07-18 09:03:55 (GMT)
committerKevin Smith <kevin.smith@isode.com>2017-02-20 15:58:04 (GMT)
commit9fe83ff62fb48662df7920afc0be71d04dafe3e4 (patch)
tree4805c1e1c0f41145bb4b97dd5e1314294e4c71b8 /SwifTools/EmojiMapper.h
parent407a266b8de87c8cd35b3ab4d0fede20786d4944 (diff)
downloadswift-9fe83ff62fb48662df7920afc0be71d04dafe3e4.zip
swift-9fe83ff62fb48662df7920afc0be71d04dafe3e4.tar.bz2
New Unicode Emojis Dialog
The new selector behaves like the old one. However, selection of an emoji results in the corresponding UTF-8 sequence to be inserted into the input widget instead of a ASCII emoticon. The code is based on the Emojione library which is MIT licensed. Emojione provides a mapping from shortnames to relevant Unicode codepoint, as well as mappings from textual emoticons (e.g. ). This commit does not modify the existing emoticon parser and so does not include any ability to enter emojis via text entry. The part of the Emojione library required to generate the mappings in C++ is included in this patch, specifically the emoji.json file. It is used to generate a corresponding .cpp file. Mapping code can be generated as follows: * cd BuildTools/EmojisGenerator/ * (optional) update emoji.json from https://github.com/Ranks/emojione/blob/master/emoji.json) - Version used with this commit: ba845a7 * npm install * node generate.js Test-information: General * Click the emoji button opens the selector * Change tab * Click an emoji and check it appears correctly * Click outside emoji dialog hides it Emojis * Emojis are well printed on macOS with Qt 5.7.1 * Emojis are black/white on Windows 10 with Qt 5.7.1 * Emojis have the right tooltip (when mouse is hover) * Check emojis are rendered appropriately by the receiving client Tabs * Tabs have the right tooltip * Click an emoji adds to recent tab * Emojis in the Recent tab are ordered by last click date (with a maximum of 50 "recent" emojis) * Recent emojis are saved in the QtSetting under "recentEmojis" Change-Id: Ibd07b8713d6272da6a8a4c9c35ddf866473f662b
Diffstat (limited to 'SwifTools/EmojiMapper.h')
-rw-r--r--SwifTools/EmojiMapper.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/SwifTools/EmojiMapper.h b/SwifTools/EmojiMapper.h
new file mode 100644
index 0000000..e2c599c
--- /dev/null
+++ b/SwifTools/EmojiMapper.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016-2017 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
+
+#pragma once
+
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+namespace Swift {
+ class EmojiMapper {
+ public:
+ static std::string shortnameToUnicode(const std::string& shortname);
+ static std::string unicodeToShortname(const std::string& unicode);
+ static std::vector<std::string> categoryNameToEmojis(const std::string& category);
+ static std::string categoryToFlagshipUnicodeEmoji(const std::string& category);
+ static std::vector<std::string> getCategories();
+
+ public:
+ // \ref shortnameUnicode maps ASCII shortnames (e.g. joy, grin, smiley, …) to a emoji UTF-8 encoded unicode sequence.
+ static const std::unordered_map<std::string, std::string> shortnameUnicode;
+ // \ref unicodeShortname is the reverse mapping of \ref shortnameUnicode.
+ static const std::unordered_map<std::string, std::string> unicodeShortname;
+ // \ref emojisInCategory maps an emoji category name to a \ref std::vector of UTF-8 encoded unicode sequence strings.
+ static const std::unordered_map<std::string, std::vector<std::string>> emojisInCategory;
+ };
+}