fix hover panel position: compute anchorX lazily on show, not at binding time
This commit is contained in:
parent
ffb869c5cc
commit
1430eeb6d4
4 changed files with 12 additions and 5 deletions
|
|
@ -99,7 +99,7 @@ M.BarSection {
|
||||||
id: hoverPanel
|
id: hoverPanel
|
||||||
showPanel: root._showPanel
|
showPanel: root._showPanel
|
||||||
screen: QsWindow.window?.screen ?? null
|
screen: QsWindow.window?.screen ?? null
|
||||||
anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0)
|
anchorItem: root
|
||||||
accentColor: root.accentColor
|
accentColor: root.accentColor
|
||||||
panelNamespace: "nova-backlight"
|
panelNamespace: "nova-backlight"
|
||||||
contentWidth: 200
|
contentWidth: 200
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ PanelWindow {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property bool showPanel
|
required property bool showPanel
|
||||||
required property real anchorX
|
required property Item anchorItem
|
||||||
required property color accentColor
|
required property color accentColor
|
||||||
property string panelNamespace: "nova-panel"
|
property string panelNamespace: "nova-panel"
|
||||||
property real contentWidth: 220
|
property real contentWidth: 220
|
||||||
|
|
@ -31,7 +31,6 @@ PanelWindow {
|
||||||
anchors.left: true
|
anchors.left: true
|
||||||
|
|
||||||
margins.top: 0
|
margins.top: 0
|
||||||
margins.left: Math.max(0, Math.min(Math.round(anchorX - contentWidth / 2), (screen?.width ?? 1920) - contentWidth))
|
|
||||||
|
|
||||||
implicitWidth: panelContent.width
|
implicitWidth: panelContent.width
|
||||||
implicitHeight: panelContent.height
|
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: {
|
onShowPanelChanged: {
|
||||||
if (showPanel) {
|
if (showPanel) {
|
||||||
|
_updatePosition();
|
||||||
_winVisible = true;
|
_winVisible = true;
|
||||||
hideAnim.stop();
|
hideAnim.stop();
|
||||||
showAnim.start();
|
showAnim.start();
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ M.BarSection {
|
||||||
id: hoverPanel
|
id: hoverPanel
|
||||||
showPanel: root._showPanel
|
showPanel: root._showPanel
|
||||||
screen: QsWindow.window?.screen ?? null
|
screen: QsWindow.window?.screen ?? null
|
||||||
anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0)
|
anchorItem: root
|
||||||
accentColor: root.accentColor
|
accentColor: root.accentColor
|
||||||
panelNamespace: "nova-mpris"
|
panelNamespace: "nova-mpris"
|
||||||
contentWidth: 280
|
contentWidth: 280
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ M.BarSection {
|
||||||
id: hoverPanel
|
id: hoverPanel
|
||||||
showPanel: root._showPanel
|
showPanel: root._showPanel
|
||||||
screen: QsWindow.window?.screen ?? null
|
screen: QsWindow.window?.screen ?? null
|
||||||
anchorX: root.mapToGlobal(root.width / 2, 0).x - (QsWindow.window?.screen?.x ?? 0)
|
anchorItem: root
|
||||||
accentColor: root.accentColor
|
accentColor: root.accentColor
|
||||||
panelNamespace: "nova-volume"
|
panelNamespace: "nova-volume"
|
||||||
contentWidth: 220
|
contentWidth: 220
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue