Tooltip: different approach to get the current screen.

This commit is contained in:
ItsLemmy
2025-10-03 23:27:07 -04:00
parent b85576653a
commit 86127660fe
33 changed files with 32 additions and 83 deletions
+12 -19
View File
@@ -8,6 +8,10 @@ import qs.Widgets
PopupWindow {
id: root
property real scaling: 1.0
property int screenWidth: 0
property int screenHeight: 0
property string text: ""
property string direction: "auto" // "auto", "left", "right", "top", "bottom"
property int margin: Style.marginXS // distance from target
@@ -15,7 +19,7 @@ PopupWindow {
property int delay: 0
property int hideDelay: 0
property int maxWidth: 320
property real scaling: 1.0
property int animationDuration: Style.animationFast
property real animationScale: 0.85
@@ -106,11 +110,15 @@ PopupWindow {
}
// Function to show tooltip
function show(target, tipText, customDirection, showDelay) {
if (!target || !tipText || tipText === "")
function show(screen, target, tipText, customDirection, showDelay) {
if (!screen || !target || !tipText || tipText === "")
return
delay = showDelay
root.scaling = ScalingService.getScreenScaleByName(screen.name)
root.screenWidth = screen.width
root.screenHeight = screen.height
root.delay = showDelay
// Stop any running timers and animations
hideTimer.stop()
@@ -144,21 +152,6 @@ PopupWindow {
return
}
// Get screen dimensions - try multiple methods
var screenWidth = Screen.width
var screenHeight = Screen.height
// Try to get screen from target item
if (targetItem) {
if (targetItem.screen) {
screenWidth = targetItem.screen.width
screenHeight = targetItem.screen.height
scaling = ScalingService.getScreenScale(targetItem.screen)
} else {
Logger.warn("Tooltip", "Could not get screen scale for targetItem:", targetItem)
}
}
// Calculate tooltip dimensions
const tipWidth = Math.min(tooltipText.implicitWidth + (padding * 2 * scaling), maxWidth * scaling)
root.implicitWidth = tipWidth