From 3f8ed91cd37adced761925e2e795326647e0845b Mon Sep 17 00:00:00 2001 From: kossLAN Date: Sun, 8 Jun 2025 23:43:42 -0400 Subject: [PATCH] bar/systray: add arrow for entries with children --- bar/Bar.qml | 4 ++- bar/BatteryIndicator.qml | 50 ----------------------------------- bar/popups/MenuWindow.qml | 26 +++++++++++++----- bar/systray/TrayMenuEntry.qml | 35 +++++++++++++++--------- 4 files changed, 44 insertions(+), 71 deletions(-) delete mode 100644 bar/BatteryIndicator.qml diff --git a/bar/Bar.qml b/bar/Bar.qml index dffcfc7..4015632 100644 --- a/bar/Bar.qml +++ b/bar/Bar.qml @@ -1,6 +1,7 @@ import QtQuick import QtQuick.Layouts import Quickshell +import "battery" import "control" as Control import "systray" as SysTray import "notifications" as Notifications @@ -55,7 +56,7 @@ PanelWindow { // Right RowLayout { - spacing: 15 + spacing: 10 anchors { top: parent.top @@ -76,6 +77,7 @@ PanelWindow { BatteryIndicator { id: batteryIndicator + popup: root.popup } // Control.Button { diff --git a/bar/BatteryIndicator.qml b/bar/BatteryIndicator.qml deleted file mode 100644 index 4269186..0000000 --- a/bar/BatteryIndicator.qml +++ /dev/null @@ -1,50 +0,0 @@ -pragma ComponentBehavior: Bound - -import QtQuick -import Qt5Compat.GraphicalEffects -import Quickshell.Widgets -import Quickshell.Services.UPower -import ".." - -Item { - id: root - - implicitWidth: 22 - implicitHeight: 22 - visible: UPower.displayDevice.isLaptopBattery - - layer.enabled: true - layer.effect: OpacityMask { - source: Rectangle { - width: root.width - height: root.height - color: "white" - } - - maskSource: IconImage { - implicitSize: root.width - source: "root:resources/battery/battery.svg" - } - } - - Rectangle { - id: batteryBackground - color: Qt.color(ShellSettings.settings.colors["surface"]).lighter(4) - opacity: 0.75 - anchors { - fill: parent - margins: 2 - } - } - - Rectangle { - id: batteryPercentage - width: (parent.width - 4) * UPower.displayDevice.percentage - color: ShellSettings.settings.colors["inverse_surface"] - anchors { - left: batteryBackground.left - top: batteryBackground.top - bottom: batteryBackground.bottom - } - } -} diff --git a/bar/popups/MenuWindow.qml b/bar/popups/MenuWindow.qml index 0f5fa3f..9ad5cf1 100644 --- a/bar/popups/MenuWindow.qml +++ b/bar/popups/MenuWindow.qml @@ -1,4 +1,5 @@ import Quickshell +import Quickshell.Hyprland import Quickshell.Widgets import QtQuick import QtQuick.Effects @@ -62,6 +63,7 @@ PopupWindow { } function show() { + grab.active = true; isOpen = true; root.visible = true; // set and leave open root.content.visible = true; @@ -70,6 +72,7 @@ PopupWindow { } function hide() { + grab.active = false; isOpen = false; popupContainer.opacity = 0; popupContent.opacity = 0; @@ -137,13 +140,22 @@ PopupWindow { } } - HoverHandler { - id: hover - enabled: true - acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad - onHoveredChanged: { - if (hovered == false) - root.hide(); + // broken for elements in the popup that have hover/mousearea's + // HoverHandler { + // id: hover + // enabled: true + // acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + // onHoveredChanged: { + // if (hovered == false) + // root.hide(); + // } + // } + + HyprlandFocusGrab { + id: grab + windows: [root, root.bar] + onCleared: { + root.hide(); } } diff --git a/bar/systray/TrayMenuEntry.qml b/bar/systray/TrayMenuEntry.qml index 930074f..4bfaae3 100644 --- a/bar/systray/TrayMenuEntry.qml +++ b/bar/systray/TrayMenuEntry.qml @@ -3,11 +3,12 @@ import Quickshell.Widgets import QtQuick import QtQuick.Controls import QtQuick.Layouts +import "../../widgets" as Widgets import "../.." ColumnLayout { id: root - required property var menuData + required property QsMenuEntry menuData signal interacted WrapperRectangle { @@ -92,24 +93,32 @@ ColumnLayout { Layout.fillWidth: true Layout.fillHeight: true - - Connections { - target: root.menuData - - function onTextChanged() { - console.log("Hi"); - } - } - } - - Item { - Layout.fillWidth: true } Item { Layout.preferredHeight: 20 Layout.preferredWidth: 20 Layout.rightMargin: 5 + + Widgets.IconButton { + id: arrowButton + visible: root.menuData?.hasChildren + activeRectangle: false + source: "root:resources/general/right-arrow.svg" + rotation: subTrayMenu.visible ? 90 : 0 + anchors.fill: parent + + Behavior on rotation { + NumberAnimation { + duration: 150 + easing.type: Easing.OutCubic + } + } + + onClicked: { + root.expanded = !root.expanded; + } + } } } }