blob: 76d4ccd4e5f19317ba667d456069e207af0122eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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()
}
}
}
|