mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
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:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user