From 3710df29f588c2aa430d9797a36afa1cbd85b128 Mon Sep 17 00:00:00 2001 From: Laurens Duin <85798751+Laurens256@users.noreply.github.com> Date: Wed, 13 Aug 2025 06:31:48 +0200 Subject: bar: allow hiding items and reordering (#379) * feat: reorder bar, no popout yet * chore: cleanup * refactor: use DelegateChooser * feat: popouts * chore: cleanup * better popout check + fix async stuff + bar interaction + a bunch of other fixes * fix activewindow and bar vertical padding * readme: add config opt * bar: fix top/bottom padding * bar: better wheel behaviour --------- Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> --- modules/bar/components/ActiveWindow.qml | 97 +++++++++++++++------------------ 1 file changed, 43 insertions(+), 54 deletions(-) (limited to 'modules/bar/components/ActiveWindow.qml') diff --git a/modules/bar/components/ActiveWindow.qml b/modules/bar/components/ActiveWindow.qml index de0f0ad..3bea956 100644 --- a/modules/bar/components/ActiveWindow.qml +++ b/modules/bar/components/ActiveWindow.qml @@ -9,73 +9,62 @@ import QtQuick Item { id: root + required property var bar required property Brightness.Monitor monitor property color colour: Colours.palette.m3primary - readonly property Item child: child - implicitWidth: child.implicitWidth - implicitHeight: child.implicitHeight - - Item { - id: child - - property Item current: text1 - - anchors.centerIn: parent + readonly property int maxHeight: { + const otherModules = bar.children.filter(c => c.id && c.item !== this && c.id !== "spacer"); + const otherHeight = otherModules.reduce((acc, curr) => acc + curr.height, 0); + // Length - 2 cause repeater counts as a child + return bar.height - otherHeight - bar.spacing * (bar.children.length - 1) - bar.vPadding * 2; + } + property Title current: text1 - clip: true - implicitWidth: Math.max(icon.implicitWidth, current.implicitHeight) - implicitHeight: icon.implicitHeight + current.implicitWidth + current.anchors.topMargin + clip: true + implicitWidth: Math.max(icon.implicitWidth, current.implicitHeight) + implicitHeight: icon.implicitHeight + current.implicitWidth + current.anchors.topMargin - MaterialIcon { - id: icon + MaterialIcon { + id: icon - animate: true - text: Icons.getAppCategoryIcon(Hyprland.activeToplevel?.lastIpcObject.class, "desktop_windows") - color: root.colour + anchors.horizontalCenter: parent.horizontalCenter - anchors.horizontalCenter: parent.horizontalCenter - } + animate: true + text: Icons.getAppCategoryIcon(Hyprland.activeToplevel?.lastIpcObject.class, "desktop_windows") + color: root.colour + } - Title { - id: text1 - } + Title { + id: text1 + } - Title { - id: text2 - } + Title { + id: text2 + } - TextMetrics { - id: metrics + TextMetrics { + id: metrics - text: Hyprland.activeToplevel?.title ?? qsTr("Desktop") - font.pointSize: Appearance.font.size.smaller - font.family: Appearance.font.family.mono - elide: Qt.ElideRight - elideWidth: root.height - icon.height + text: Hyprland.activeToplevel?.title ?? qsTr("Desktop") + font.pointSize: Appearance.font.size.smaller + font.family: Appearance.font.family.mono + elide: Qt.ElideRight + elideWidth: root.maxHeight - icon.height - onTextChanged: { - const next = child.current === text1 ? text2 : text1; - next.text = elidedText; - child.current = next; - } - onElideWidthChanged: child.current.text = elidedText - } - - Behavior on implicitWidth { - NumberAnimation { - duration: Appearance.anim.durations.normal - easing.type: Easing.BezierSpline - easing.bezierCurve: Appearance.anim.curves.emphasized - } + onTextChanged: { + const next = root.current === text1 ? text2 : text1; + next.text = elidedText; + root.current = next; } + onElideWidthChanged: root.current.text = elidedText + } - Behavior on implicitHeight { - NumberAnimation { - duration: Appearance.anim.durations.normal - easing.type: Easing.BezierSpline - easing.bezierCurve: Appearance.anim.curves.emphasized - } + Behavior on implicitHeight { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.emphasized } } @@ -89,7 +78,7 @@ Item { font.pointSize: metrics.font.pointSize font.family: metrics.font.family color: root.colour - opacity: child.current === this ? 1 : 0 + opacity: root.current === this ? 1 : 0 transform: Rotation { angle: 90 -- cgit v1.2.3-freya