fix hover panel position: compute anchorX lazily on show, not at binding time

This commit is contained in:
Damocles 2026-04-13 21:13:37 +02:00
parent ffb869c5cc
commit 1430eeb6d4
4 changed files with 12 additions and 5 deletions

View file

@ -9,7 +9,7 @@ PanelWindow {
id: root
required property bool showPanel
required property real anchorX
required property Item anchorItem
required property color accentColor
property string panelNamespace: "nova-panel"
property real contentWidth: 220
@ -31,7 +31,6 @@ PanelWindow {
anchors.left: true
margins.top: 0
margins.left: Math.max(0, Math.min(Math.round(anchorX - contentWidth / 2), (screen?.width ?? 1920) - contentWidth))
implicitWidth: panelContent.width
implicitHeight: panelContent.height
@ -44,8 +43,16 @@ PanelWindow {
}
}
function _updatePosition() {
const pt = anchorItem.mapToGlobal(anchorItem.width / 2, 0);
const scr = screen;
const sw = scr?.width ?? 1920;
margins.left = Math.max(0, Math.min(Math.round(pt.x - (scr?.x ?? 0) - contentWidth / 2), sw - contentWidth));
}
onShowPanelChanged: {
if (showPanel) {
_updatePosition();
_winVisible = true;
hideAnim.stop();
showAnim.start();