TrayMenu: improved positionning

This commit is contained in:
ItsLemmy
2025-11-12 23:43:44 -05:00
parent aca82f810c
commit 6083d8242b
3 changed files with 18 additions and 11 deletions
+9 -3
View File
@@ -45,12 +45,18 @@ PopupWindow {
implicitWidth: menuWidth implicitWidth: menuWidth
// Use the content height of the Flickable for implicit height // Use the content height of the Flickable for implicit height
implicitHeight: Math.min(screen ? screen.height * 0.9 : Screen.height * 0.9, flickable.contentHeight + (Style.marginS * 2)) implicitHeight: Math.min(screen.height * 0.9, flickable.contentHeight + (Style.marginS * 2))
visible: false visible: false
color: Color.transparent color: Color.transparent
anchor.item: anchorItem anchor.item: anchorItem
anchor.rect.x: anchorX anchor.rect.x: anchorX
anchor.rect.y: anchorY - (isSubMenu ? 0 : 4) anchor.rect.y: {
if (isSubMenu) {
const offsetY = Settings.data.bar.position === "bottom" ? -10 : 10
return anchorY + offsetY
}
return anchorY + Settings.data.bar.position === "bottom" ? -implicitHeight : Style.barHeight
}
function showAt(item, x, y) { function showAt(item, x, y) {
if (!item) { if (!item) {
@@ -234,7 +240,7 @@ PopupWindow {
} else if (barPosition === "left") { } else if (barPosition === "left") {
openLeft = false openLeft = false
} else { } else {
openLeft = false openLeft = (root.widgetSection === "right")
} }
// Open new submenu // Open new submenu
+8 -7
View File
@@ -262,6 +262,7 @@ Rectangle {
onRightClicked: toggleDrawer(this) onRightClicked: toggleDrawer(this)
} }
// Pinned items
Repeater { Repeater {
id: repeater id: repeater
model: root.filteredItems model: root.filteredItems
@@ -327,12 +328,12 @@ Rectangle {
modelData.activate() modelData.activate()
} }
} else if (mouse.button === Qt.MiddleButton) { } else if (mouse.button === Qt.MiddleButton) {
// Close the menu if it was visible
// Close any open menu first if (trayMenuWindow && trayMenuWindow.visible) {
trayMenuWindow.close()
// TODO RESTORE LATER return
// trayMenuWindow.close() }
// modelData.secondaryActivate && modelData.secondaryActivate() modelData.secondaryActivate && modelData.secondaryActivate()
} else if (mouse.button === Qt.RightButton) { } else if (mouse.button === Qt.RightButton) {
TooltipService.hideImmediately() TooltipService.hideImmediately()
@@ -364,7 +365,7 @@ Rectangle {
} else { } else {
// For horizontal bars: center horizontally and position below // For horizontal bars: center horizontally and position below
menuX = (width / 2) - (trayMenu.item.width / 2) menuX = (width / 2) - (trayMenu.item.width / 2)
menuY = Style.barHeight menuY = (barPosition === "top") ? Style.barHeight : -Style.barHeight
} }
trayMenu.item.trayItem = modelData trayMenu.item.trayItem = modelData
trayMenu.item.widgetSection = root.section trayMenu.item.widgetSection = root.section
+1 -1
View File
@@ -187,7 +187,7 @@ SmartPanel {
} }
} else if (mouse.button === Qt.MiddleButton) { } else if (mouse.button === Qt.MiddleButton) {
// Middle click: activate with middle button // Middle click: activate with middle button
modelData.activate(1) modelData.secondaryActivate && modelData.secondaryActivate()
} else if (mouse.button === Qt.RightButton) { } else if (mouse.button === Qt.RightButton) {
// Right click: open context menu // Right click: open context menu
TooltipService.hideImmediately() TooltipService.hideImmediately()