diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-07-16 16:22:48 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-07-16 16:22:48 +0800 |
| commit | 042c42805ceecbf7eefa129da990dc79816fe43c (patch) | |
| tree | 660604427b129007e481b8996a4c66cac3fe10d8 /bar | |
| parent | d46258c0d2fc91491d4aa865ae35029a9d65cd91 (diff) | |
power: put int a drawer
Diffstat (limited to 'bar')
| -rw-r--r-- | bar/Power.qml | 99 |
1 files 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; + } + } } } |
