From 086c5c9f0239b230d75c8365da0ab365bafaf0c1 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sun, 18 May 2025 00:23:21 +0800 Subject: feat: dashboard user --- utils/Icons.qml | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'utils') diff --git a/utils/Icons.qml b/utils/Icons.qml index 312ae6d..504cdc5 100644 --- a/utils/Icons.qml +++ b/utils/Icons.qml @@ -151,6 +151,7 @@ Singleton { }) property string osIcon: "" + property string osName function getAppCategoryIcon(name: string, fallback: string): string { const categories = DesktopEntries.applications.values.find(app => app.id === name)?.categories; @@ -187,14 +188,22 @@ Singleton { FileView { path: "/etc/os-release" onLoaded: { - const osId = this.text().split("\n").find(l => l.startsWith("ID="))?.split("=")[1]; + const lines = text().split("\n"); + let osId = lines.find(l => l.startsWith("ID="))?.split("=")[1]; if (root.osIcons.hasOwnProperty(osId)) - return root.osIcon = root.osIcons[osId]; - const osIdLike = this.text().split("\n").find(l => l.startsWith("ID_LIKE="))?.split("=")[1]; - if (osIdLike) - for (const id of osIdLike.split(" ")) - if (root.osIcons.hasOwnProperty(id)) - return root.osIcon = root.osIcons[id]; + root.osIcon = root.osIcons[osId]; + else { + const osIdLike = lines.find(l => l.startsWith("ID_LIKE="))?.split("=")[1]; + if (osIdLike) + for (const id of osIdLike.split(" ")) + if (root.osIcons.hasOwnProperty(id)) + return root.osIcon = root.osIcons[id]; + } + + let nameLine = lines.find(l => l.startsWith("PRETTY_NAME=")); + if (!nameLine) + nameLine = lines.find(l => l.startsWith("NAME=")); + root.osName = nameLine.split("=")[1].slice(1, -1); } } } -- cgit v1.2.3-freya