From 112ed0d6de08dfde12f1eeac437bfa943ac1aa7e Mon Sep 17 00:00:00 2001 From: Benjamin Palko Date: Sun, 7 Sep 2025 09:31:19 -0400 Subject: [PATCH] simplify StyledPopupWindow --- components/StyledPopupWindow.qml | 27 ++++++++----------- .../components/bluetooth/BluetoothMenu.qml | 5 ---- .../notifications/NotificationMenu.qml | 4 --- modules/bar/components/tray/menu/Menu.qml | 4 --- 4 files changed, 11 insertions(+), 29 deletions(-) diff --git a/components/StyledPopupWindow.qml b/components/StyledPopupWindow.qml index 44e5553..cf87fb1 100644 --- a/components/StyledPopupWindow.qml +++ b/components/StyledPopupWindow.qml @@ -1,39 +1,34 @@ +import qs.config import QtQuick import Quickshell import Quickshell.Hyprland -import Quickshell.Widgets PopupWindow { id: root - property bool opened: false - property int animationDuration: 200 - property alias margins: background.margin - property alias backgroundColor: background.color - property alias radius: background.radius - property alias state: background.state + required property Component content + implicitWidth: background.width + implicitHeight: background.height color: "transparent" - function toggle() { - root.state = root.state == "opened" ? "closed" : "opened"; - } - HyprlandFocusGrab { id: grab active: root.visible windows: [root] onCleared: { - root.state = "closed"; + background.state = "closed"; } } - implicitWidth: background.width - implicitHeight: background.height + function toggle() { + background.state = background.state == "opened" ? "closed" : "opened"; + } - WrapperRectangle { + StyledWrapperRectangle { id: background + margin: 16 focus: true onFocusChanged: { if (!focus) { @@ -43,7 +38,7 @@ PopupWindow { Behavior on opacity { NumberAnimation { - duration: root.animationDuration + duration: Styling.animations.speed.normal } } diff --git a/modules/bar/components/bluetooth/BluetoothMenu.qml b/modules/bar/components/bluetooth/BluetoothMenu.qml index b9bc688..7e953cf 100644 --- a/modules/bar/components/bluetooth/BluetoothMenu.qml +++ b/modules/bar/components/bluetooth/BluetoothMenu.qml @@ -1,7 +1,6 @@ pragma ComponentBehavior: Bound import qs.components -import qs.config import QtQuick import QtQuick.Layouts import Quickshell @@ -10,10 +9,6 @@ import Quickshell.Bluetooth StyledPopupWindow { id: root - backgroundColor: Styling.theme.base300 - margins: 16 - radius: 8 - content: ColumnLayout { spacing: 8 StyledWrapperRectangle { diff --git a/modules/bar/components/notifications/NotificationMenu.qml b/modules/bar/components/notifications/NotificationMenu.qml index 877f30f..d608fd8 100644 --- a/modules/bar/components/notifications/NotificationMenu.qml +++ b/modules/bar/components/notifications/NotificationMenu.qml @@ -9,10 +9,6 @@ import QtQuick.Layouts StyledPopupWindow { id: root - backgroundColor: Styling.theme.base300 - margins: 16 - radius: 8 - content: GridLayout { columns: 2 diff --git a/modules/bar/components/tray/menu/Menu.qml b/modules/bar/components/tray/menu/Menu.qml index 43ce6b5..db54cfc 100644 --- a/modules/bar/components/tray/menu/Menu.qml +++ b/modules/bar/components/tray/menu/Menu.qml @@ -9,10 +9,6 @@ import Quickshell StyledPopupWindow { id: window - backgroundColor: Styling.theme.base300 - margins: 14 - radius: 8 - property QsMenuOpener menuOpener content: ColumnLayout {