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

@ -2,6 +2,7 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Widgets
import qs.Commons
import qs.Services
import qs.Widgets
@ -42,6 +43,15 @@ Row {
const focusedWindow = CompositorService.getFocusedWindow()
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
NText {
@ -72,13 +82,20 @@ Row {
spacing: Style.marginXS * scaling
// Window icon
NIcon {
id: windowIcon
text: "dialogs"
font.pointSize: Style.fontSizeL * scaling
verticalAlignment: Text.AlignVCenter
anchors.verticalCenter: parent.verticalCenter
visible: getTitle() !== ""
Item {
width: Style.fontSizeL * scaling * 1.2
height: Style.fontSizeL * scaling * 1.2
anchors.verticalCenter: parent.verticalCenter
visible: getTitle() !== "" && Settings.data.bar.showActiveWindowIcon
IconImage {
id: windowIcon
anchors.fill: parent
source: getAppIcon()
asynchronous: true
smooth: true
visible: source !== ""
}
}
NText {