Better weather placement

This commit is contained in:
David Heinemeier Hansson
2026-05-16 22:48:56 +02:00
parent b37386f084
commit ae3d7efc6e
2 changed files with 18 additions and 0 deletions
@@ -14,6 +14,7 @@ PopupWindow {
property int contentWidth: 280
property int contentHeight: 200
property bool open: false
property bool centerOnBar: false
// "click" — uses HyprlandFocusGrab so clicking outside dismisses the popup.
// "hover" — passive overlay; the owning widget controls open via hover.
property string triggerMode: "click"
@@ -81,6 +82,22 @@ PopupWindow {
var window = target.QsWindow.window
if (!window) return
if (root.centerOnBar) {
if (root.bar.position === "top" || root.bar.position === "bottom") {
localX = window.width / 2 - popupWidth / 2
localY = root.bar.position === "bottom" ? -popupHeight - root.margin : window.height + root.margin
localX = Math.max(root.margin, Math.min(localX, window.width - popupWidth - root.margin))
} else {
localX = root.bar.position === "left" ? window.width + root.margin : -popupWidth - root.margin
localY = window.height / 2 - popupHeight / 2
localY = Math.max(root.margin, Math.min(localY, window.height - popupHeight - root.margin))
}
popupAnchor.rect.x = Math.round(localX)
popupAnchor.rect.y = Math.round(localY)
return
}
if (root.bar.position === "top" || root.bar.position === "bottom") {
localX = Math.max(root.margin, Math.min(localX, window.width - popupWidth - root.margin))
} else {
@@ -178,6 +178,7 @@ Item {
owner: root
bar: root.bar
open: root.popupOpen
centerOnBar: true
triggerMode: "click"
contentWidth: 440
contentHeight: card.implicitHeight + 28