From 042c42805ceecbf7eefa129da990dc79816fe43c Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 16 Jul 2025 16:22:48 +0800 Subject: power: put int a drawer --- bar/Power.qml | 99 ++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 21 deletions(-) diff --git a/bar/Power.qml b/bar/Power.qml index 66278f0..9cce1c7 100644 --- a/bar/Power.qml +++ b/bar/Power.qml @@ -7,9 +7,13 @@ import qs.config import qs.components Item { + id: root + implicitWidth: container.implicitWidth implicitHeight: container.implicitHeight + property bool collapsed: true + Rectangle { id: container @@ -26,41 +30,94 @@ Item { RowLayout { id: layout + + anchors.fill: parent + spacing: Bar.resourceIconTextSpacing + Item { Layout.fillWidth: true } - anchors.fill: parent - spacing: Bar.resourceIconTextSpacing Icon { + id: powerIcon text: Icons.power.shutdown font.pixelSize: Style.font.size.large color: Colors.red } - // Icon { - // text: Icons.power.dpms - // font.pixelSize: Style.fontSize.large - // } - // - // Icon { - // text: Icons.power.lock - // font.pixelSize: Style.fontSize.large - // } - // - // Icon { - // text: Icons.power.suspend - // font.pixelSize: Style.fontSize.large - // } - // - // Icon { - // text: Icons.power.reboot - // font.pixelSize: Style.fontSize.large - // } + Item { + implicitWidth: root.collapsed ? 0 : loader.width + visible: root.collapsed ? false : true + Loader { + id: loader + anchors.verticalCenter: parent.verticalCenter + active: !root.collapsed + sourceComponent: Component { + RowLayout { + spacing: Bar.resourceIconTextSpacing + Icon { + text: Icons.power.dpms + font.pixelSize: Style.font.size.large + } + + Icon { + text: Icons.power.lock + font.pixelSize: Style.font.size.large + } + + Icon { + text: Icons.power.suspend + font.pixelSize: Style.font.size.large + } + + Icon { + text: Icons.power.reboot + font.pixelSize: Style.font.size.large + } + SequentialAnimation { + running: true + NumberAnimation { + target: parent + property: "opacity" + from: 0 + to: 1 + duration: General.animateDuration / 2 + easing.type: Easing.InOutQuad + } + } + } + } + } + Behavior on implicitWidth { + NumberAnimation { + duration: General.animateDuration / 4 + easing.type: Easing.InOutQuad + } + } + + // no idea why when collapsing the width animation won't trigger + Behavior on visible { + NumberAnimation { + duration: General.animateDuration / 4 + easing.type: Easing.InOutQuad + } + } + } Item { Layout.fillWidth: true } } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: { + root.collapsed = false; + } + onExited: { + root.collapsed = true; + } + } } } -- cgit v1.2.3