Tooltip: removed auto-positionning relative to the bar. as many tooltips are used in panels

- still a few edge cases to work on
This commit is contained in:
ItsLemmy
2025-09-27 14:57:11 -04:00
parent 4c516200dc
commit 8e248f6795
15 changed files with 44 additions and 23 deletions
+6 -1
View File
@@ -11,6 +11,9 @@ Rectangle {
property string icon
property string tooltipText
property bool tooltipPositionAbove: false
property bool tooltipPositionLeft: false
property bool tooltipPositionRight: false
property bool enabled: true
property bool allowClickWhenDisabled: false
property bool hovering: false
@@ -65,7 +68,9 @@ Rectangle {
NTooltip {
id: tooltip
target: root
positionAbove: Settings.data.bar.position === "bottom"
positionAbove: root.tooltipPositionAbove
positionLeft: root.tooltipPositionLeft
positionRight: root.tooltipPositionRight
text: root.tooltipText
}
+3 -20
View File
@@ -48,34 +48,17 @@ Window {
return
}
// Auto-detect positioning based on bar position if not explicitly set
var shouldPositionLeft = positionLeft
var shouldPositionRight = positionRight
var shouldPositionAbove = positionAbove
// If no explicit positioning is set, auto-detect based on bar position
if (!positionLeft && !positionRight && !positionAbove) {
if (barPosition === "left") {
shouldPositionRight = true
} else if (barPosition === "right") {
shouldPositionLeft = true
} else if (barPosition === "bottom") {
shouldPositionAbove = true
}
// For "top" bar, default to below (no change needed)
}
if (shouldPositionLeft) {
if (positionLeft) {
// Position tooltip to the left of the target
var pos = target.mapToGlobal(0, 0)
x = pos.x - width - 12 // 12 px margin to the left
y = pos.y - height / 2 + target.height / 2
} else if (shouldPositionRight) {
} else if (positionRight) {
// Position tooltip to the right of the target
var pos = target.mapToGlobal(target.width, 0)
x = pos.x + 12 // 12 px margin to the right
y = pos.y - height / 2 + target.height / 2
} else if (shouldPositionAbove) {
} else if (positionAbove) {
// Position tooltip above the target
var pos = target.mapToGlobal(0, 0)
x = pos.x - width / 2 + target.width / 2