summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-08-19 20:46:55 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-08-19 21:50:03 +0800
commit00364bf0ce9cf7ed55575c7ccf9cbd2acb35dbd3 (patch)
tree8f0f5c7fe16e7c714d749cd4561d50937b28005e
parent68e1a276192872c57931e9e43911a479d4619c4a (diff)
Revert "refactor(Emoji, Spell): optimize cell dimensions and selection logic"
This reverts commit 47b7722e4dcc750bdad71731977e0cdb1d95b022.
-rw-r--r--popups/launcher/components/Emoji.qml12
-rw-r--r--popups/launcher/components/Spell.qml10
2 files changed, 12 insertions, 10 deletions
diff --git a/popups/launcher/components/Emoji.qml b/popups/launcher/components/Emoji.qml
index d1343e6..d4bc54f 100644
--- a/popups/launcher/components/Emoji.qml
+++ b/popups/launcher/components/Emoji.qml
@@ -13,6 +13,10 @@ IComponent {
property var emojis: active ? Emoji.query(input) : []
property int selectedIndex: -1
+ property int cols: Math.max(1, Math.floor(innerLoader.width / Math.max(1, Math.round(Launcher.widgetFontSize * 4))))
+ property int cellWidth: Math.floor(innerLoader.width / cols)
+ property int cellHeight: Math.ceil(Launcher.widgetFontSize * 2) + Launcher.innerMargin * 2
+
name: "Emoji"
prefix: name.toLowerCase() + " "
@@ -72,13 +76,11 @@ IComponent {
selectedIndex++;
}
up: function () {
- const cols = loader.view ? Math.max(1, Math.floor(loader.view.width / loader.view.cellWidth)) : 1;
if (selectedIndex - cols < 0)
return true;
selectedIndex -= cols;
}
down: function () {
- const cols = loader.view ? Math.max(1, Math.floor(loader.view.width / loader.view.cellWidth)) : 1;
if (selectedIndex + cols >= emojis.length)
return true;
selectedIndex += cols;
@@ -119,14 +121,14 @@ IComponent {
flow: GridView.FlowLeftToRight
snapMode: GridView.NoSnap
- cellWidth: Math.min(width / Math.max(1, Math.floor(width / (Launcher.widgetFontSize * 5))), width / 3)
- cellHeight: Launcher.widgetFontSize * 2.2 + Launcher.innerMargin * 2
+ cellWidth: root.cellWidth
+ cellHeight: root.cellHeight
delegate: Item {
required property var modelData
required property int index
width: grid.cellWidth
- height: grid.cellHeight
+ height: chipContent.implicitHeight + Launcher.innerMargin * 2
scale: index === selectedIndex ? 1.03 : 0.97
IRect {
diff --git a/popups/launcher/components/Spell.qml b/popups/launcher/components/Spell.qml
index fe01c3f..b081caa 100644
--- a/popups/launcher/components/Spell.qml
+++ b/popups/launcher/components/Spell.qml
@@ -94,14 +94,14 @@ IComponent {
}
up: function () {
- const cols = loader.view ? Math.max(1, Math.floor(loader.view.width / loader.view.cellWidth)) : 1;
+ const cols = Math.max(1, Math.floor(innerLoader.width / Math.max(1, Math.round(Launcher.widgetFontSize * 6))));
if (selectedIndex - cols < 0)
return true;
selectedIndex -= cols;
}
down: function () {
- const cols = loader.view ? Math.max(1, Math.floor(loader.view.width / loader.view.cellWidth)) : 1;
+ const cols = Math.max(1, Math.floor(innerLoader.width / Math.max(1, Math.round(Launcher.widgetFontSize * 6))));
if (selectedIndex + cols >= aspell.length)
return true;
selectedIndex += cols;
@@ -144,15 +144,15 @@ IComponent {
flow: GridView.FlowLeftToRight
snapMode: GridView.NoSnap
- cellWidth: Math.min(width / Math.max(1, Math.floor(width / (Launcher.widgetFontSize * 4))), width / 2)
- cellHeight: Launcher.widgetFontSize * 1.4 + Launcher.innerMargin * 2
+ cellWidth: Math.floor(width / Math.max(1, Math.floor(width / Math.max(1, Math.round(Launcher.widgetFontSize * 6)))))
+ cellHeight: Math.ceil(Launcher.widgetFontSize * 1.6) + Launcher.innerMargin * 2
delegate: Item {
required property var modelData
required property int index
width: grid.cellWidth
- height: grid.cellHeight
+ height: chipContent.implicitHeight + Launcher.innerMargin * 2
scale: index === selectedIndex ? 1.03 : 0.97
IRect {