1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

qmlformat file

This commit is contained in:
bbedward
2025-07-17 18:00:31 -04:00
parent 023b6bc0d1
commit 26ad3810b4

View File

@@ -1,36 +1,35 @@
import QtQuick
import QtQuick.Controls
import Quickshell
import Quickshell.Widgets
import Quickshell.Wayland
import Quickshell.Widgets
import qs.Common
PanelWindow {
id: root
property bool showTrayMenu: false
property real trayMenuX: 0
property real trayMenuY: 0
property var currentTrayMenu: null
property var currentTrayItem: null
visible: showTrayMenu
WlrLayershell.layer: WlrLayershell.Overlay
WlrLayershell.exclusiveZone: -1
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
color: "transparent"
anchors {
top: true
left: true
right: true
bottom: true
}
Rectangle {
id: menuContainer
x: trayMenuX
y: trayMenuY
width: Math.max(180, Math.min(300, menuList.maxTextWidth + Theme.spacingL * 2))
@@ -39,7 +38,10 @@ PanelWindow {
radius: Theme.cornerRadiusLarge
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
border.width: 1
// Material 3 animations
opacity: showTrayMenu ? 1 : 0
scale: showTrayMenu ? 1 : 0.85
// Material 3 drop shadow
Rectangle {
anchors.fill: parent
@@ -51,74 +53,59 @@ PanelWindow {
color: Qt.rgba(0, 0, 0, 0.15)
z: parent.z - 1
}
// Material 3 animations
opacity: showTrayMenu ? 1.0 : 0.0
scale: showTrayMenu ? 1.0 : 0.85
Behavior on opacity {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
Behavior on scale {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
Item {
anchors.fill: parent
anchors.margins: Theme.spacingS
QsMenuOpener {
id: menuOpener
menu: currentTrayItem ? currentTrayItem.menu : null
}
// Custom menu styling using ListView
ListView {
id: menuList
anchors.fill: parent
spacing: 1
// Calculate maximum text width for dynamic menu sizing
property real maxTextWidth: {
let maxWidth = 0
let maxWidth = 0;
if (model && model.values) {
for (let i = 0; i < model.values.length; i++) {
const item = model.values[i]
const item = model.values[i];
if (item && item.text) {
const textWidth = textMetrics.advanceWidth * item.text.length * 0.6
maxWidth = Math.max(maxWidth, textWidth)
const textWidth = textMetrics.advanceWidth * item.text.length * 0.6;
maxWidth = Math.max(maxWidth, textWidth);
}
}
}
return Math.min(maxWidth, 280) // Cap at reasonable width
return Math.min(maxWidth, 280); // Cap at reasonable width
}
anchors.fill: parent
spacing: 1
TextMetrics {
id: textMetrics
font.pixelSize: Theme.fontSizeSmall
text: "M"
}
model: ScriptModel {
values: menuOpener.children ? [...menuOpener.children.values].filter(item => {
values: menuOpener.children ? [pe_unknown].filter((item) => {
// Filter out empty items and separators
return item && item.text && item.text.trim().length > 0 && !item.isSeparator
return item && item.text && item.text.trim().length > 0 && !item.isSeparator;
}) : []
}
delegate: Rectangle {
width: ListView.view.width
height: modelData.isSeparator ? 5 : 28
radius: modelData.isSeparator ? 0 : Theme.cornerRadiusSmall
color: modelData.isSeparator ? "transparent" :
(menuItemArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent")
color: modelData.isSeparator ? "transparent" : (menuItemArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent")
// Separator line
Rectangle {
visible: modelData.isSeparator
@@ -127,7 +114,7 @@ PanelWindow {
height: 1
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
}
// Menu item content
Row {
visible: !modelData.isSeparator
@@ -135,7 +122,7 @@ PanelWindow {
anchors.leftMargin: Theme.spacingS
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingXS
Text {
text: modelData.text || ""
font.pixelSize: Theme.fontSizeSmall
@@ -144,40 +131,63 @@ PanelWindow {
elide: Text.ElideRight
maximumLineCount: 1
}
}
MouseArea {
id: menuItemArea
anchors.fill: parent
hoverEnabled: true
cursorShape: modelData.isSeparator ? Qt.ArrowCursor : Qt.PointingHandCursor
enabled: !modelData.isSeparator
onClicked: {
if (modelData.triggered) {
modelData.triggered()
}
showTrayMenu = false
if (modelData.triggered)
modelData.triggered();
showTrayMenu = false;
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
}
}
Behavior on opacity {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
Behavior on scale {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
}
// Click outside to close
MouseArea {
anchors.fill: parent
z: -1
onClicked: {
showTrayMenu = false
showTrayMenu = false;
}
}
}
}