From 139ef3b4fdb6129a2c7aa3405acc00c072cba823 Mon Sep 17 00:00:00 2001 From: Teo Date: Fri, 3 Jul 2026 15:18:32 +0200 Subject: [PATCH] WindowInfo widget --- modules/bar/Bar.qml | 2 + modules/bar/widgets/WindowInfo.qml | 70 ++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 modules/bar/widgets/WindowInfo.qml diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index 7422cc6..0fd8b7d 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -45,6 +45,8 @@ PanelWindow { anchors.verticalCenter: parent.verticalCenter } + WindowInfo {} + } Row { // bar widgets center diff --git a/modules/bar/widgets/WindowInfo.qml b/modules/bar/widgets/WindowInfo.qml new file mode 100644 index 0000000..424fa3a --- /dev/null +++ b/modules/bar/widgets/WindowInfo.qml @@ -0,0 +1,70 @@ +import QtQuick +import Quickshell +import Quickshell.Hyprland +import "../../../config" +import "../states/Apps" + +Item { + id: root + + property real pad: Config.spacing_fun(bar.height) * 1.5 + + anchors.verticalCenter: parent.verticalCenter + + + implicitWidth: contentRow.implicitWidth + pad * 2 + implicitHeight: contentRow.implicitHeight + + readonly property string windowClass: Hyprland.activeToplevel?.wayland?.appId ?? "" + + readonly property string windowTitle: { + const title = Hyprland.activeToplevel?.title; + if (!title) + return qsTr("Desktop"); + return title.split(/\s+[\-\u2013\u2014\|]\s+/).pop(); + } + + readonly property string appIcon: { + if (!root.windowClass) return AppsState.matchIcon(root.windowTitle); + + let icon = AppsState.matchIcon(root.windowClass); + + if (!icon) { + icon = AppsState.matchIcon(root.windowClass.toLowerCase()); + } + + if (!icon) { + icon = AppsState.matchIcon(root.windowTitle); + } + + return icon; + } + + Row { + + id: contentRow + spacing: Config.spacing_fun(bar.height) * 1.25 + anchors.centerIn: parent + + Text { + text: root.windowTitle + anchors.verticalCenter: parent.verticalCenter + elide: Text.ElideRight + maximumLineCount: 1 + width: Math.min(implicitWidth, 250) + + font.pixelSize: Config.iconSize(bar.height) * 0.8 + color: Colors.primary + } + + Text { + text: root.appIcon + visible: text !== "" + anchors.verticalCenter: parent.verticalCenter + + font.pixelSize: Math.round(Config.iconSize(bar.height) * 0.85) + color: Colors.primary + } + + } +} \ No newline at end of file