From 36f28f7c42957cd8728bf4fb7740be28d5b746cb Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Fri, 23 May 2025 16:50:12 +0800 Subject: bar: switch to embedded style --- modules/bar/components/ActiveWindow.qml | 96 ++++++++++++++++++--------------- modules/bar/components/TrayItem.qml | 4 +- 2 files changed, 55 insertions(+), 45 deletions(-) (limited to 'modules/bar/components') diff --git a/modules/bar/components/ActiveWindow.qml b/modules/bar/components/ActiveWindow.qml index 0e24242..75dfc43 100644 --- a/modules/bar/components/ActiveWindow.qml +++ b/modules/bar/components/ActiveWindow.qml @@ -6,66 +6,76 @@ import "root:/utils" import "root:/config" import QtQuick -StyledRect { +Item { id: root + readonly property bool vertical: parent?.vertical ?? false property color colour: Colours.palette.pink - clip: true + implicitWidth: child.implicitWidth + implicitHeight: child.implicitHeight - MaterialIcon { - id: icon + StyledRect { + id: child - animate: true - text: Icons.getAppCategoryIcon(Hyprland.activeClient?.wmClass, "desktop_windows") - color: root.colour + anchors.centerIn: parent - anchors.horizontalCenter: root.vertical ? parent.horizontalCenter : undefined - } - - AnchorText { - id: text + clip: true - prevAnchor: icon + MaterialIcon { + id: icon - text: metrics.elidedText - font.pointSize: metrics.font.pointSize - font.family: metrics.font.family - color: root.colour + animate: true + text: Icons.getAppCategoryIcon(Hyprland.activeClient?.wmClass, "desktop_windows") + color: root.colour - transform: Rotation { - angle: vertical ? 90 : 0 - origin.x: text.implicitHeight / 2 - origin.y: text.implicitHeight / 2 + anchors.horizontalCenter: root.vertical ? parent.horizontalCenter : undefined } - width: vertical ? implicitHeight : implicitWidth - height: vertical ? implicitWidth : implicitHeight - } + AnchorText { + id: text - TextMetrics { - id: metrics + prevAnchor: icon - text: Hyprland.activeClient?.title ?? qsTr("Desktop") - font.pointSize: Appearance.font.size.smaller - font.family: Appearance.font.family.mono - elide: Qt.ElideRight - elideWidth: root.vertical ? BarConfig.sizes.maxLabelHeight : BarConfig.sizes.maxLabelWidth - } + text: metrics.elidedText + font.pointSize: metrics.font.pointSize + font.family: metrics.font.family + color: root.colour + + transform: Rotation { + angle: vertical ? 90 : 0 + origin.x: text.implicitHeight / 2 + origin.y: text.implicitHeight / 2 + } - Behavior on implicitWidth { - NumberAnimation { - duration: Appearance.anim.durations.normal - easing.type: Easing.BezierSpline - easing.bezierCurve: Appearance.anim.curves.emphasized + width: vertical ? implicitHeight : implicitWidth + height: vertical ? implicitWidth : implicitHeight + } + + TextMetrics { + id: metrics + + text: Hyprland.activeClient?.title ?? qsTr("Desktop") + font.pointSize: Appearance.font.size.smaller + font.family: Appearance.font.family.mono + elide: Qt.ElideRight + elideWidth: root.vertical ? root.height - icon.height : root.width - icon.width + } + + Behavior on implicitWidth { + 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 + Behavior on implicitHeight { + NumberAnimation { + duration: Appearance.anim.durations.normal + easing.type: Easing.BezierSpline + easing.bezierCurve: Appearance.anim.curves.emphasized + } } } } diff --git a/modules/bar/components/TrayItem.qml b/modules/bar/components/TrayItem.qml index 57ec106..202c8bf 100644 --- a/modules/bar/components/TrayItem.qml +++ b/modules/bar/components/TrayItem.qml @@ -15,8 +15,8 @@ MouseArea { required property color colour acceptedButtons: Qt.LeftButton | Qt.RightButton - implicitWidth: Appearance.font.size.smaller * 2 - implicitHeight: Appearance.font.size.smaller * 2 + implicitWidth: Appearance.font.size.small * 2 + implicitHeight: Appearance.font.size.small * 2 onClicked: event => { if (event.button === Qt.LeftButton) -- cgit v1.2.3-freya