Merge pull request #117 from ThatOneCalculator/fix/app-icons

app icon fetching adjustments
This commit is contained in:
Lemmy 2025-08-20 20:44:52 -04:00 committed by GitHub
commit a240eb027c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 14 deletions

View file

@ -111,6 +111,7 @@ Singleton {
bar: JsonObject { bar: JsonObject {
property string position: "top" // Possible values: "top", "bottom" property string position: "top" // Possible values: "top", "bottom"
property bool showActiveWindow: true property bool showActiveWindow: true
property bool showActiveWindowIcon: true
property bool showSystemInfo: false property bool showSystemInfo: false
property bool showMedia: false property bool showMedia: false
property bool showBrightness: true property bool showBrightness: true

View file

@ -2,6 +2,7 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell import Quickshell
import Quickshell.Widgets
import qs.Commons import qs.Commons
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
@ -42,6 +43,15 @@ Row {
const focusedWindow = CompositorService.getFocusedWindow() const focusedWindow = CompositorService.getFocusedWindow()
return focusedWindow ? (focusedWindow.title || focusedWindow.appId || "") : "" return focusedWindow ? (focusedWindow.title || focusedWindow.appId || "") : ""
} }
function getAppIcon() {
const focusedWindow = CompositorService.getFocusedWindow();
if (!focusedWindow || !focusedWindow.appId)
return "";
let icon = Quickshell.iconPath(DesktopEntries.byId(focusedWindow.appId).icon);
return icon || "";
}
// A hidden text element to safely measure the full title width // A hidden text element to safely measure the full title width
NText { NText {
@ -72,13 +82,20 @@ Row {
spacing: Style.marginXS * scaling spacing: Style.marginXS * scaling
// Window icon // Window icon
NIcon { Item {
id: windowIcon width: Style.fontSizeL * scaling * 1.2
text: "dialogs" height: Style.fontSizeL * scaling * 1.2
font.pointSize: Style.fontSizeL * scaling anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter visible: getTitle() !== "" && Settings.data.bar.showActiveWindowIcon
anchors.verticalCenter: parent.verticalCenter
visible: getTitle() !== "" IconImage {
id: windowIcon
anchors.fill: parent
source: getAppIcon()
asynchronous: true
smooth: true
visible: source !== ""
}
} }
NText { NText {

View file

@ -159,13 +159,7 @@ Loader {
function getAppIcon(toplevel: Toplevel): string { function getAppIcon(toplevel: Toplevel): string {
if (!toplevel) if (!toplevel)
return "" return ""
let icon = Quickshell.iconPath(toplevel.appId?.toLowerCase(), true) let icon = Quickshell.iconPath(DesktopEntries.byId(toplevel.appId?.toLowerCase()).icon);
if (!icon)
icon = Quickshell.iconPath(toplevel.appId, true)
if (!icon)
icon = Quickshell.iconPath(toplevel.title?.toLowerCase(), true)
if (!icon)
icon = Quickshell.iconPath(toplevel.title, true)
return icon || Quickshell.iconPath("application-x-executable", true) return icon || Quickshell.iconPath("application-x-executable", true)
} }

View file

@ -87,6 +87,15 @@ ColumnLayout {
} }
} }
NToggle {
label: "Show App Icon Next To Active Window"
description: "Display the app icon next to the title of the currently focused window."
checked: Settings.data.bar.showActiveWindowIcon
onToggled: checked => {
Settings.data.bar.showActiveWindowIcon = checked
}
}
NToggle { NToggle {
label: "Show System Info" label: "Show System Info"
description: "Display system statistics (CPU, RAM, Temperature)." description: "Display system statistics (CPU, RAM, Temperature)."