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
-1
View File
@@ -242,7 +242,6 @@ Item {
text: root.tooltipText
positionLeft: barPosition === "right"
positionRight: barPosition === "left"
positionAbove: Settings.data.bar.position === "bottom"
delay: Style.tooltipDelayLong
}
+2
View File
@@ -111,6 +111,8 @@ Rectangle {
text: I18n.tr("clock.tooltip")
target: clockContainer
positionAbove: Settings.data.bar.position === "bottom"
positionLeft: barPosition === "right"
positionRight: barPosition === "left"
}
MouseArea {
+3
View File
@@ -36,6 +36,9 @@ NIconButton {
// If we have a custom path or distro logo, don't use the theme icon.
icon: (customIconPath === "" && !useDistroLogo) ? customIcon : ""
tooltipText: I18n.tr("tooltips.open-control-center")
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
baseSize: Style.capsuleHeight
compact: (Settings.data.bar.density === "compact")
colorBg: (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent)
+3
View File
@@ -11,6 +11,9 @@ NIconButton {
icon: "dark-mode"
tooltipText: Settings.data.colorSchemes.darkMode ? I18n.tr("tooltips.switch-to-light-mode") : I18n.tr("tooltips.switch-to-dark-mode")
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
compact: (Settings.data.bar.density === "compact")
baseSize: Style.capsuleHeight
colorBg: Settings.data.colorSchemes.darkMode ? (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent) : Color.mPrimary
+3
View File
@@ -15,6 +15,9 @@ NIconButton {
compact: (Settings.data.bar.density === "compact")
icon: IdleInhibitorService.isInhibited ? "keep-awake-on" : "keep-awake-off"
tooltipText: IdleInhibitorService.isInhibited ? I18n.tr("tooltips.disable-keep-awake") : I18n.tr("tooltips.enable-keep-awake")
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
colorBg: IdleInhibitorService.isInhibited ? Color.mPrimary : (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent)
colorFg: IdleInhibitorService.isInhibited ? Color.mOnPrimary : Color.mOnSurface
colorBorder: Color.transparent
+3
View File
@@ -23,6 +23,9 @@ NIconButton {
icon: Settings.data.nightLight.enabled ? (Settings.data.nightLight.forced ? "nightlight-forced" : "nightlight-on") : "nightlight-off"
tooltipText: Settings.data.nightLight.enabled ? (Settings.data.nightLight.forced ? I18n.tr("tooltips.night-light-forced") : I18n.tr("tooltips.night-light-enabled")) : I18n.tr("tooltips.night-light-disabled")
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
onClicked: {
// Check if wlsunset is available before enabling night light
if (!ProgramCheckerService.wlsunsetAvailable) {
@@ -53,6 +53,9 @@ NIconButton {
compact: (Settings.data.bar.density === "compact")
icon: Settings.data.notifications.doNotDisturb ? "bell-off" : "bell"
tooltipText: Settings.data.notifications.doNotDisturb ? I18n.tr("tooltips.open-notification-history-disable-dnd") : I18n.tr("tooltips.open-notification-history-enable-dnd")
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
colorBg: (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent)
colorFg: Color.mOnSurface
colorBorder: Color.transparent
+3
View File
@@ -19,6 +19,9 @@ NIconButton {
tooltipText: I18n.tr("tooltips.power-profile", {
"profile": PowerProfileService.getName()
})
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
compact: (Settings.data.bar.density === "compact")
colorBg: (PowerProfileService.profile === PowerProfile.Balanced) ? (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent) : Color.mPrimary
colorFg: (PowerProfileService.profile === PowerProfile.Balanced) ? Color.mOnSurface : Color.mOnPrimary
+3
View File
@@ -12,6 +12,9 @@ NIconButton {
icon: "camera-video"
tooltipText: ScreenRecorderService.isRecording ? I18n.tr("tooltips.click-to-stop-recording") : I18n.tr("tooltips.click-to-start-recording")
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
compact: (Settings.data.bar.density === "compact")
baseSize: Style.capsuleHeight
colorBg: ScreenRecorderService.isRecording ? Color.mPrimary : (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent)
+3
View File
@@ -15,6 +15,9 @@ NIconButton {
baseSize: Style.capsuleHeight
icon: "power"
tooltipText: I18n.tr("tooltips.session-menu")
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
colorBg: (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent)
colorFg: Color.mError
colorBorder: Color.transparent
+3 -1
View File
@@ -106,7 +106,9 @@ Rectangle {
id: taskbarTooltip
text: taskbarItem.modelData.title || taskbarItem.modelData.appId || "Unknown app."
target: taskbarItem
positionAbove: Settings.data.bar.position === "bottom"
positionAbove: barPosition === "bottom"
positionLeft: barPosition === "right"
positionRight: barPosition === "left"
}
}
}
@@ -15,6 +15,9 @@ NIconButton {
compact: (Settings.data.bar.density === "compact")
icon: "wallpaper-selector"
tooltipText: I18n.tr("tooltips.open-wallpaper-selector")
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
colorBg: (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent)
colorFg: Color.mOnSurface
colorBorder: Color.transparent
+3
View File
@@ -41,6 +41,9 @@ NIconButton {
}
}
tooltipText: I18n.tr("tooltips.manage-wifi")
tooltipPositionAbove: Settings.data.bar.position === "bottom"
tooltipPositionLeft: Settings.data.bar.position === "right"
tooltipPositionRight: Settings.data.bar.position === "left"
onClicked: PanelService.getPanel("wifiPanel")?.toggle(this)
onRightClicked: PanelService.getPanel("wifiPanel")?.toggle(this)
}
+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