diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-07-14 21:16:03 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-07-14 23:06:58 +0800 |
| commit | f871681c3b1281cf50b6b4143ddde02621ef37d3 (patch) | |
| tree | 3c7ff2edd45a314e5a73507716855c6beb3bd6e7 /bar/ActiveWindow.qml | |
| parent | 05b33cfda103fe64030fdbea66f6ef3b1a10fa1f (diff) | |
activewindow: properly use loader
Diffstat (limited to 'bar/ActiveWindow.qml')
| -rw-r--r-- | bar/ActiveWindow.qml | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/bar/ActiveWindow.qml b/bar/ActiveWindow.qml index 80e3b31..e0b917d 100644 --- a/bar/ActiveWindow.qml +++ b/bar/ActiveWindow.qml @@ -7,40 +7,46 @@ import Quickshell.Widgets import qs.components import qs.config -Rectangle { - id: root - property var toplevel: Hyprland.activeToplevel - property var icon: Quickshell.iconPath(AppSearch.guessIcon(toplevel?.wayland?.appId), "image-missing") - - // use IRect - implicitWidth: rowLayout.implicitWidth + General.rectMargin * 4 - implicitHeight: rowLayout.implicitHeight + General.rectMargin * 2 +Loader { + id: activeWindowLoader anchors.centerIn: parent + active: ToplevelManager.activeToplevel?.activated ? 1 : 0 + sourceComponent: Component { + Rectangle { + id: root + property var toplevel: Hyprland.activeToplevel + property var icon: Quickshell.iconPath(AppSearch.guessIcon(toplevel?.wayland?.appId), "image-missing") - color: Colors.alt - // according to docs, null could happen but doesn't seem to happen in practice so.. - // hypr toplevel.activated is always true and doesn't change either so.. - opacity: ToplevelManager.activeToplevel?.activated ? 1 : 0 + // use IRect + implicitWidth: rowLayout.implicitWidth + General.rectMargin * 4 + implicitHeight: rowLayout.implicitHeight + General.rectMargin * 2 + anchors.centerIn: parent - radius: Style.rounding.smaller + color: Colors.alt + // according to docs, null could happen but doesn't seem to happen in practice so.. + // hypr toplevel.activated is always true and doesn't change either so.. + // opacity: ToplevelManager.activeToplevel?.activated ? 1 : 0 - RowLayout { - id: rowLayout - anchors.centerIn: parent - spacing: Bar.resourceIconTextSpacing + radius: Style.rounding.smaller - IconImage { - source: root.icon - implicitWidth: Bar.appIconSize - implicitHeight: Bar.appIconSize - Layout.fillHeight: true - Layout.fillWidth: false - Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter - } - IText { - // TOOD: if not exist, use lazyloader or something hide this - font.pixelSize: General.fontSize - text: root?.toplevel?.wayland?.title || "" + RowLayout { + id: rowLayout + anchors.centerIn: parent + spacing: Bar.resourceIconTextSpacing + + IconImage { + source: root.icon + implicitWidth: Bar.appIconSize + implicitHeight: Bar.appIconSize + Layout.fillHeight: true + Layout.fillWidth: false + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + } + IText { + font.pixelSize: General.fontSize + text: root?.toplevel?.wayland?.title || "" + } + } } } } |
