summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-08-18 00:30:35 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-08-19 20:15:21 +0800
commit1edfa9b00d61e963148444c79726bc7eb89364db (patch)
tree16058bebf74b59de7120f3b4a63cc8ba08ec247a /services
parent947a9a41c204e0e2aa877e80abf765301ca3c757 (diff)
feat(Emoji): add emoji component and service for emoji selection
Diffstat (limited to 'services')
-rw-r--r--services/Emoji.qml55
1 files changed, 55 insertions, 0 deletions
diff --git a/services/Emoji.qml b/services/Emoji.qml
new file mode 100644
index 0000000..6f6b8d9
--- /dev/null
+++ b/services/Emoji.qml
@@ -0,0 +1,55 @@
+pragma Singleton
+
+import Quickshell
+import Quickshell.Io
+import QtQuick
+import qs.components
+
+Searchable {
+ id: root
+
+ property var _emojis: []
+ property var _emojiFile: FileView {
+ path: "/usr/share/rofi-emoji/all_emojis.txt"
+ onTextChanged: _parseEmojis()
+ }
+
+ list: _emojis
+ key: "searchText"
+ algorithm: Searchable.SearchAlgorithm.Include
+
+ function transformSearch(search) {
+ return search.toLowerCase();
+ }
+
+ function _parseEmojis() {
+ const text = _emojiFile.text();
+ if (!text) {
+ console.warn("Emoji service: failed to load", _emojiFile.path);
+ _emojis = [];
+ return;
+ }
+
+ const lines = text.split("\n").filter(l => l.trim());
+ const out = [];
+ for (let i = 0; i < lines.length; ++i) {
+ const parts = lines[i].split("\t");
+ if (parts.length < 5)
+ continue;
+ const [emoji, category, subcategory, name, keywords] = parts;
+ out.push({
+ emoji: emoji,
+ category: category,
+ subcategory: subcategory,
+ name: name,
+ keywords: keywords,
+ searchText: (name + " " + keywords).toLowerCase()
+ });
+ }
+ _emojis = out;
+ }
+
+ function copy(emoji) {
+ Clip.copy(emoji);
+ }
+}