|
| 1 | +import QtQuick |
| 2 | +import QtQuick.Layouts |
| 3 | +import Quickshell |
| 4 | +import Quickshell.Io |
| 5 | +import Quickshell.Wayland |
| 6 | + |
| 7 | +Variants { |
| 8 | + id: root |
| 9 | + property color backgroundColor: "#e60c0c0c" |
| 10 | + property color buttonColor: "#1e1e1e" |
| 11 | + property color buttonHoverColor: "#3700b3" |
| 12 | + default property list<WlButton> buttons |
| 13 | + |
| 14 | + variants: Quickshell.screens.map(screen => ({ screen })) |
| 15 | + PanelWindow { |
| 16 | + id: w |
| 17 | + |
| 18 | + exclusionMode: ExclusionMode.Ignore |
| 19 | + WlrLayershell.layer: Layer.Overlay |
| 20 | + WlrLayershell.keyboardFocus: KeyboardFocus.Exclusive |
| 21 | + |
| 22 | + color: "transparent" |
| 23 | + |
| 24 | + contentItem { |
| 25 | + focus: true |
| 26 | + Keys.onPressed: event => { |
| 27 | + if (event.key == Qt.Key_Escape) Qt.quit(); |
| 28 | + else { |
| 29 | + for (let i = 0; i < buttons.length; i++) { |
| 30 | + let button = buttons[i]; |
| 31 | + if (event.key == button.keybind) button.exec(); |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + anchors { |
| 38 | + top: true |
| 39 | + left: true |
| 40 | + bottom: true |
| 41 | + right: true |
| 42 | + } |
| 43 | + |
| 44 | + Rectangle { |
| 45 | + color: backgroundColor; |
| 46 | + anchors.fill: parent |
| 47 | + |
| 48 | + MouseArea { |
| 49 | + anchors.fill: parent |
| 50 | + onClicked: Qt.quit() |
| 51 | + |
| 52 | + GridLayout { |
| 53 | + anchors.centerIn: parent |
| 54 | + |
| 55 | + width: parent.width * 0.75 |
| 56 | + height: parent.height * 0.75 |
| 57 | + |
| 58 | + columns: 3 |
| 59 | + columnSpacing: 0 |
| 60 | + rowSpacing: 0 |
| 61 | + |
| 62 | + Repeater { |
| 63 | + model: buttons |
| 64 | + delegate: Rectangle { |
| 65 | + required property WlButton modelData; |
| 66 | + |
| 67 | + Layout.fillWidth: true |
| 68 | + Layout.fillHeight: true |
| 69 | + |
| 70 | + color: ma.containsMouse ? buttonHoverColor : buttonColor |
| 71 | + border.color: "black" |
| 72 | + border.width: ma.containsMouse ? 0 : 1 |
| 73 | + |
| 74 | + MouseArea { |
| 75 | + id: ma |
| 76 | + anchors.fill: parent |
| 77 | + hoverEnabled: true |
| 78 | + onClicked: modelData.exec() |
| 79 | + } |
| 80 | + |
| 81 | + Image { |
| 82 | + id: icon |
| 83 | + anchors.centerIn: parent |
| 84 | + source: `icons/${modelData.icon}.png` |
| 85 | + width: parent.width * 0.25 |
| 86 | + height: parent.width * 0.25 |
| 87 | + } |
| 88 | + |
| 89 | + Text { |
| 90 | + anchors { |
| 91 | + top: icon.bottom |
| 92 | + topMargin: 20 |
| 93 | + horizontalCenter: parent.horizontalCenter |
| 94 | + } |
| 95 | + |
| 96 | + text: modelData.text |
| 97 | + font.pointSize: 20 |
| 98 | + color: "white" |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | +} |
0 commit comments