diff options
Diffstat (limited to 'modules/system/quickshell/AnchoredPopup.qml')
| -rw-r--r-- | modules/system/quickshell/AnchoredPopup.qml | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/modules/system/quickshell/AnchoredPopup.qml b/modules/system/quickshell/AnchoredPopup.qml new file mode 100644 index 0000000..76d4ccd --- /dev/null +++ b/modules/system/quickshell/AnchoredPopup.qml @@ -0,0 +1,77 @@ +import QtQuick +import Quickshell +import Quickshell.Wayland + +Scope { + id: root + + property string popupName: "" + property var anchorWindow + property var anchorItem + property int popupGap: Theme.popupGap + readonly property bool open: GlobalState.activePopup === popupName + default property alias content: contentRoot.data + + signal opened + signal closed + + PanelWindow { + visible: root.open + anchors { + top: true + bottom: true + left: true + right: true + } + WlrLayershell.layer: WlrLayer.Top + WlrLayershell.margins.top: Theme.barHeight + WlrLayershell.keyboardFocus: WlrKeyboardFocus.None + exclusionMode: ExclusionMode.Ignore + color: Theme.transparent + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.AllButtons + hoverEnabled: true + onClicked: GlobalState.close() + onWheel: wheel => wheel.accepted = true + } + } + + PopupWindow { + id: popup + visible: root.open + grabFocus: true + implicitWidth: contentRoot.childrenRect.width + implicitHeight: contentRoot.childrenRect.height + + anchor { + window: root.anchorWindow + item: root.anchorItem + edges: Edges.Bottom + gravity: Edges.Bottom + margins.top: root.popupGap + } + + color: Theme.transparent + + onVisibleChanged: { + if (visible) { + anchor.updateAnchor(); + contentRoot.forceActiveFocus(); + root.opened(); + } else { + root.closed(); + } + } + + Item { + id: contentRoot + focus: true + width: childrenRect.width + height: childrenRect.height + + Keys.onEscapePressed: GlobalState.close() + } + } +} |
