Customtray #3
@@ -0,0 +1,91 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Hyprland
|
||||
|
||||
PopupWindow {
|
||||
id: root
|
||||
required property QsMenuHandle menu
|
||||
property int height: entryCount * ( entryHeight + 3 )
|
||||
property int entryHeight: 30
|
||||
property int entryCount: 0
|
||||
implicitWidth: 300
|
||||
implicitHeight: height
|
||||
color: "transparent"
|
||||
|
||||
QsMenuOpener {
|
||||
id: menuOpener
|
||||
menu: root.menu
|
||||
}
|
||||
|
||||
HyprlandFocusGrab {
|
||||
id: grab
|
||||
windows: [ root ]
|
||||
onCleared: {
|
||||
root.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
grab.active = root.visible;
|
||||
}
|
||||
Rectangle {
|
||||
id: menuRect
|
||||
anchors.fill: parent
|
||||
color: "#90000000"
|
||||
radius: 8
|
||||
border.color: "#10FFFFFF"
|
||||
ColumnLayout {
|
||||
id: columnLayout
|
||||
anchors.fill: parent
|
||||
anchors.margins: 5
|
||||
spacing: 2
|
||||
Repeater {
|
||||
id: repeater
|
||||
model: menuOpener.children
|
||||
Rectangle {
|
||||
id: menuItem
|
||||
width: root.implicitWidth
|
||||
Layout.maximumWidth: parent.width
|
||||
Layout.fillHeight: true
|
||||
height: root.entryHeight
|
||||
color: mouseArea.containsMouse && !modelData.isSeparator ? "#15FFFFFF" : "transparent"
|
||||
radius: 4
|
||||
visible: modelData.isSeparator ? false : true
|
||||
required property QsMenuEntry modelData
|
||||
|
||||
Component.onCompleted: {
|
||||
if ( !modelData.isSeparator ) {
|
||||
root.entryCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
preventStealing: true
|
||||
propagateComposedEvents: true
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onClicked: {
|
||||
if ( !menuItem.modelData.hasChildren ) {
|
||||
menuItem.modelData.triggered();
|
||||
root.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 10
|
||||
text: menuItem.modelData.text
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
-2
@@ -32,6 +32,7 @@ PopupWindow {
|
||||
grab.active = root.visible;
|
||||
}
|
||||
Rectangle {
|
||||
id: menuRect
|
||||
anchors.fill: parent
|
||||
color: "#90000000"
|
||||
radius: 8
|
||||
@@ -69,10 +70,22 @@ PopupWindow {
|
||||
propagateComposedEvents: true
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onClicked: {
|
||||
menuItem.modelData.triggered();
|
||||
root.visible = false;
|
||||
if ( !menuItem.modelData.hasChildren ) {
|
||||
menuItem.modelData.triggered();
|
||||
root.visible = false;
|
||||
} else {
|
||||
subMenuComponent.createObject( null, {
|
||||
menu: menuItem.modelData,
|
||||
anchor: {
|
||||
item: menuItem,
|
||||
edges: Edges.Right
|
||||
},
|
||||
visible: true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
@@ -84,4 +97,8 @@ PopupWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: subMenuComponent
|
||||
SubMenu {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
import Quickshell.Wayland
|
||||
|
||||
Scope {
|
||||
Variants {
|
||||
model: Quickshell.screens
|
||||
PanelWindow {
|
||||
id: root
|
||||
required property var modelData
|
||||
screen: modelData
|
||||
WlrLayershell.exclusionMode: ExclusionMode.Ignore
|
||||
WlrLayershell.layer: WlrLayer.Bottom
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
left: true
|
||||
right: true
|
||||
bottom: true
|
||||
}
|
||||
Image {
|
||||
id: wallpaperImage
|
||||
anchors.fill: parent
|
||||
source: "/mnt/IronWolf/SDImages/SWWW_Wals/ComfyUI_00037_.png"
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user