mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-31 00:42:50 -05:00
qmlformat file
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Widgets
|
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
|
import Quickshell.Widgets
|
||||||
import qs.Common
|
import qs.Common
|
||||||
|
|
||||||
PanelWindow {
|
PanelWindow {
|
||||||
@@ -15,11 +15,9 @@ PanelWindow {
|
|||||||
property var currentTrayItem: null
|
property var currentTrayItem: null
|
||||||
|
|
||||||
visible: showTrayMenu
|
visible: showTrayMenu
|
||||||
|
|
||||||
WlrLayershell.layer: WlrLayershell.Overlay
|
WlrLayershell.layer: WlrLayershell.Overlay
|
||||||
WlrLayershell.exclusiveZone: -1
|
WlrLayershell.exclusiveZone: -1
|
||||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
|
||||||
|
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
@@ -31,6 +29,7 @@ PanelWindow {
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: menuContainer
|
id: menuContainer
|
||||||
|
|
||||||
x: trayMenuX
|
x: trayMenuX
|
||||||
y: trayMenuY
|
y: trayMenuY
|
||||||
width: Math.max(180, Math.min(300, menuList.maxTextWidth + Theme.spacingL * 2))
|
width: Math.max(180, Math.min(300, menuList.maxTextWidth + Theme.spacingL * 2))
|
||||||
@@ -39,6 +38,9 @@ PanelWindow {
|
|||||||
radius: Theme.cornerRadiusLarge
|
radius: Theme.cornerRadiusLarge
|
||||||
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
|
||||||
border.width: 1
|
border.width: 1
|
||||||
|
// Material 3 animations
|
||||||
|
opacity: showTrayMenu ? 1 : 0
|
||||||
|
scale: showTrayMenu ? 1 : 0.85
|
||||||
|
|
||||||
// Material 3 drop shadow
|
// Material 3 drop shadow
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -52,63 +54,49 @@ PanelWindow {
|
|||||||
z: parent.z - 1
|
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 {
|
Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Theme.spacingS
|
anchors.margins: Theme.spacingS
|
||||||
|
|
||||||
QsMenuOpener {
|
QsMenuOpener {
|
||||||
id: menuOpener
|
id: menuOpener
|
||||||
|
|
||||||
menu: currentTrayItem ? currentTrayItem.menu : null
|
menu: currentTrayItem ? currentTrayItem.menu : null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom menu styling using ListView
|
// Custom menu styling using ListView
|
||||||
ListView {
|
ListView {
|
||||||
id: menuList
|
id: menuList
|
||||||
anchors.fill: parent
|
|
||||||
spacing: 1
|
|
||||||
|
|
||||||
// Calculate maximum text width for dynamic menu sizing
|
// Calculate maximum text width for dynamic menu sizing
|
||||||
property real maxTextWidth: {
|
property real maxTextWidth: {
|
||||||
let maxWidth = 0
|
let maxWidth = 0;
|
||||||
if (model && model.values) {
|
if (model && model.values) {
|
||||||
for (let i = 0; i < model.values.length; i++) {
|
for (let i = 0; i < model.values.length; i++) {
|
||||||
const item = model.values[i]
|
const item = model.values[i];
|
||||||
if (item && item.text) {
|
if (item && item.text) {
|
||||||
const textWidth = textMetrics.advanceWidth * item.text.length * 0.6
|
const textWidth = textMetrics.advanceWidth * item.text.length * 0.6;
|
||||||
maxWidth = Math.max(maxWidth, textWidth)
|
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 {
|
TextMetrics {
|
||||||
id: textMetrics
|
id: textMetrics
|
||||||
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
text: "M"
|
text: "M"
|
||||||
}
|
}
|
||||||
|
|
||||||
model: ScriptModel {
|
model: ScriptModel {
|
||||||
values: menuOpener.children ? [...menuOpener.children.values].filter(item => {
|
values: menuOpener.children ? [pe_unknown].filter((item) => {
|
||||||
// Filter out empty items and separators
|
// 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;
|
||||||
}) : []
|
}) : []
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,8 +104,7 @@ PanelWindow {
|
|||||||
width: ListView.view.width
|
width: ListView.view.width
|
||||||
height: modelData.isSeparator ? 5 : 28
|
height: modelData.isSeparator ? 5 : 28
|
||||||
radius: modelData.isSeparator ? 0 : Theme.cornerRadiusSmall
|
radius: modelData.isSeparator ? 0 : Theme.cornerRadiusSmall
|
||||||
color: modelData.isSeparator ? "transparent" :
|
color: modelData.isSeparator ? "transparent" : (menuItemArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent")
|
||||||
(menuItemArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : "transparent")
|
|
||||||
|
|
||||||
// Separator line
|
// Separator line
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -144,20 +131,21 @@ PanelWindow {
|
|||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
maximumLineCount: 1
|
maximumLineCount: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: menuItemArea
|
id: menuItemArea
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: modelData.isSeparator ? Qt.ArrowCursor : Qt.PointingHandCursor
|
cursorShape: modelData.isSeparator ? Qt.ArrowCursor : Qt.PointingHandCursor
|
||||||
enabled: !modelData.isSeparator
|
enabled: !modelData.isSeparator
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (modelData.triggered) {
|
if (modelData.triggered)
|
||||||
modelData.triggered()
|
modelData.triggered();
|
||||||
}
|
|
||||||
showTrayMenu = false
|
showTrayMenu = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,10 +154,31 @@ PanelWindow {
|
|||||||
duration: Theme.shortDuration
|
duration: Theme.shortDuration
|
||||||
easing.type: Theme.standardEasing
|
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
|
// Click outside to close
|
||||||
@@ -177,7 +186,8 @@ PanelWindow {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
z: -1
|
z: -1
|
||||||
onClicked: {
|
onClicked: {
|
||||||
showTrayMenu = false
|
showTrayMenu = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user