summaryrefslogtreecommitdiff
path: root/services/AppSearch.qml
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-09-02 18:26:45 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-09-02 18:26:45 +0800
commitf7a43077fe4e139dd7e3f46f448e0951740ec148 (patch)
treef6a68248fe42bd899e99049bab7fdb7e5d26ea60 /services/AppSearch.qml
parent2f7576faf493b4667b02dcb60ddbf3aa0a9f654b (diff)
fix: qmlfmt
IListView: animation
Diffstat (limited to 'services/AppSearch.qml')
-rw-r--r--services/AppSearch.qml230
1 files changed, 115 insertions, 115 deletions
diff --git a/services/AppSearch.qml b/services/AppSearch.qml
index d56213f..b8294b6 100644
--- a/services/AppSearch.qml
+++ b/services/AppSearch.qml
@@ -6,119 +6,119 @@ import qs.config
import qs.components
Searchable {
- id: root
-
- list: Array.from(DesktopEntries.applications.values).sort((a, b) => a.name.localeCompare(b.name))
- scoreThreshold: General.appSearchFuzzySearchThreshold
- algorithm: Searchable.SearchAlgorithm.Levendist
- keys: ["name", "genericName", "execString", "keywords", "comment", "categories", "icon"]
-
- property var substitutions: ({
- "code-url-handler": "visual-studio-code",
- "Code": "visual-studio-code",
- "gnome-tweaks": "org.gnome.tweaks",
- "pavucontrol-qt": "pavucontrol",
- "wps": "wps-office2019-kprometheus",
- "wpsoffice": "wps-office2019-kprometheus",
- "footclient": "foot",
- "zen": "zen-browser",
- "brave-browser": "brave-desktop"
- })
-
- property var regexSubstitutions: [
- {
- regex: /^steam_app_(\d+)$/,
- replace: "steam_icon_$1"
- },
- {
- regex: /Minecraft.*/,
- replace: "minecraft"
- },
- {
- regex: /.*polkit.*/,
- replace: "system-lock-screen"
- },
- {
- regex: /gcr.prompter/,
- replace: "system-lock-screen"
- }
- ]
-
- property var iconExistsCache: ({})
- property var guessIconCache: ({})
-
- function iconExists(iconName) {
- if (!iconName || iconName.length === 0) {
- return false;
- }
- if (root.iconExistsCache.hasOwnProperty(iconName)) {
- return root.iconExistsCache[iconName];
- }
- const exists = Quickshell.iconPath(iconName, true).length > 0 && !iconName.includes("image-missing");
- root.iconExistsCache[iconName] = exists;
- return exists;
- }
-
- function guessIcon(str) {
- if (!str || str.length === 0) {
- return "image-missing";
- }
- if (root.guessIconCache[str]) {
- return root.guessIconCache[str];
- }
-
- var result;
-
- if (substitutions[str]) {
- result = substitutions[str];
- } else {
- result = null;
- for (var i = 0; i < regexSubstitutions.length; i++) {
- var {
- regex,
- replace
- } = regexSubstitutions[i];
- var replaced = str.replace(regex, replace);
- if (replaced !== str) {
- result = replaced;
- break;
- }
- }
- }
-
- if (!result && root.iconExists(str)) {
- result = str;
- }
-
- if (!result) {
- var guessStr = str.split(".").slice(-1)[0].toLowerCase();
- if (root.iconExists(guessStr)) {
- result = guessStr;
- }
- }
-
- if (!result) {
- var kebab = str.toLowerCase().replace(/\s+/g, "-");
- if (root.iconExists(kebab)) {
- result = kebab;
- }
- }
-
- if (!result) {
- const matches = root.query(str);
- if (matches.length > 0) {
- const candidate = matches[0].icon;
- if (root.iconExists(candidate)) {
- result = candidate;
- }
- }
- }
-
- if (!result) {
- result = str;
- }
-
- root.guessIconCache[str] = result;
- return result;
- }
+ id: root
+
+ list: Array.from(DesktopEntries.applications.values).sort((a, b) => a.name.localeCompare(b.name))
+ scoreThreshold: General.appSearchFuzzySearchThreshold
+ algorithm: Searchable.SearchAlgorithm.Levendist
+ keys: ["name", "genericName", "execString", "keywords", "comment", "categories", "icon"]
+
+ property var substitutions: ({
+ "code-url-handler": "visual-studio-code",
+ "Code": "visual-studio-code",
+ "gnome-tweaks": "org.gnome.tweaks",
+ "pavucontrol-qt": "pavucontrol",
+ "wps": "wps-office2019-kprometheus",
+ "wpsoffice": "wps-office2019-kprometheus",
+ "footclient": "foot",
+ "zen": "zen-browser",
+ "brave-browser": "brave-desktop"
+ })
+
+ property var regexSubstitutions: [
+ {
+ regex: /^steam_app_(\d+)$/,
+ replace: "steam_icon_$1"
+ },
+ {
+ regex: /Minecraft.*/,
+ replace: "minecraft"
+ },
+ {
+ regex: /.*polkit.*/,
+ replace: "system-lock-screen"
+ },
+ {
+ regex: /gcr.prompter/,
+ replace: "system-lock-screen"
+ }
+ ]
+
+ property var iconExistsCache: ({})
+ property var guessIconCache: ({})
+
+ function iconExists(iconName) {
+ if (!iconName || iconName.length === 0) {
+ return false;
+ }
+ if (root.iconExistsCache.hasOwnProperty(iconName)) {
+ return root.iconExistsCache[iconName];
+ }
+ const exists = Quickshell.iconPath(iconName, true).length > 0 && !iconName.includes("image-missing");
+ root.iconExistsCache[iconName] = exists;
+ return exists;
+ }
+
+ function guessIcon(str) {
+ if (!str || str.length === 0) {
+ return "image-missing";
+ }
+ if (root.guessIconCache[str]) {
+ return root.guessIconCache[str];
+ }
+
+ var result;
+
+ if (substitutions[str]) {
+ result = substitutions[str];
+ } else {
+ result = null;
+ for (var i = 0; i < regexSubstitutions.length; i++) {
+ var {
+ regex,
+ replace
+ } = regexSubstitutions[i];
+ var replaced = str.replace(regex, replace);
+ if (replaced !== str) {
+ result = replaced;
+ break;
+ }
+ }
+ }
+
+ if (!result && root.iconExists(str)) {
+ result = str;
+ }
+
+ if (!result) {
+ var guessStr = str.split(".").slice(-1)[0].toLowerCase();
+ if (root.iconExists(guessStr)) {
+ result = guessStr;
+ }
+ }
+
+ if (!result) {
+ var kebab = str.toLowerCase().replace(/\s+/g, "-");
+ if (root.iconExists(kebab)) {
+ result = kebab;
+ }
+ }
+
+ if (!result) {
+ const matches = root.query(str);
+ if (matches.length > 0) {
+ const candidate = matches[0].icon;
+ if (root.iconExists(candidate)) {
+ result = candidate;
+ }
+ }
+ }
+
+ if (!result) {
+ result = str;
+ }
+
+ root.guessIconCache[str] = result;
+ return result;
+ }
}