From 599068b5843c10152753aed790a1686712f7adf6 Mon Sep 17 00:00:00 2001 From: Lemmy Date: Fri, 13 Mar 2026 11:44:38 -0400 Subject: [PATCH] fix(tooltips): added support for string vs array content everywhere --- Modules/Bar/Extras/BarPill.qml | 2 +- Modules/Bar/Extras/BarPillHorizontal.qml | 2 +- Modules/Bar/Extras/BarPillVertical.qml | 2 +- Widgets/NButton.qml | 10 +++++----- Widgets/NCircleStat.qml | 6 +++--- Widgets/NColorSlider.qml | 8 ++++---- Widgets/NIconButton.qml | 8 ++++---- Widgets/NIconButtonHot.qml | 12 ++++++------ Widgets/NSettingsIndicator.qml | 8 ++++---- Widgets/NSlider.qml | 8 ++++---- Widgets/NTabButton.qml | 9 ++++----- 11 files changed, 37 insertions(+), 38 deletions(-) diff --git a/Modules/Bar/Extras/BarPill.qml b/Modules/Bar/Extras/BarPill.qml index ed50f994b..c988487ed 100644 --- a/Modules/Bar/Extras/BarPill.qml +++ b/Modules/Bar/Extras/BarPill.qml @@ -12,7 +12,7 @@ Item { property string icon: "" property string text: "" property string suffix: "" - property var tooltipText: "" + property var tooltipText property bool autoHide: false property bool forceOpen: false property bool forceClose: false diff --git a/Modules/Bar/Extras/BarPillHorizontal.qml b/Modules/Bar/Extras/BarPillHorizontal.qml index 2843d83de..2076618e9 100644 --- a/Modules/Bar/Extras/BarPillHorizontal.qml +++ b/Modules/Bar/Extras/BarPillHorizontal.qml @@ -13,7 +13,7 @@ Item { property string icon: "" property string text: "" property string suffix: "" - property var tooltipText: "" + property var tooltipText property bool autoHide: false property bool forceOpen: false property bool forceClose: false diff --git a/Modules/Bar/Extras/BarPillVertical.qml b/Modules/Bar/Extras/BarPillVertical.qml index 15eb07f12..caf30af56 100644 --- a/Modules/Bar/Extras/BarPillVertical.qml +++ b/Modules/Bar/Extras/BarPillVertical.qml @@ -13,7 +13,7 @@ Item { property string icon: "" property string text: "" property string suffix: "" - property var tooltipText: "" + property var tooltipText property bool autoHide: false property bool forceOpen: false property bool forceClose: false diff --git a/Widgets/NButton.qml b/Widgets/NButton.qml index d417c6e21..a579a6f94 100644 --- a/Widgets/NButton.qml +++ b/Widgets/NButton.qml @@ -10,7 +10,7 @@ Rectangle { // Public properties property string text: "" property string icon: "" - property string tooltipText + property var tooltipText property color backgroundColor: Color.mPrimary property color textColor: Color.mOnPrimary property color hoverColor: Color.mHover @@ -142,19 +142,19 @@ Rectangle { onEntered: { root.hovered = true; root.entered(); - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.show(root, root.tooltipText); } } onExited: { root.hovered = false; root.exited(); - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.hide(); } } onPressed: mouse => { - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.hide(); } if (mouse.button === Qt.LeftButton) { @@ -168,7 +168,7 @@ Rectangle { onCanceled: { root.hovered = false; - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.hide(); } } diff --git a/Widgets/NCircleStat.qml b/Widgets/NCircleStat.qml index 60e660e18..cb3341ab9 100644 --- a/Widgets/NCircleStat.qml +++ b/Widgets/NCircleStat.qml @@ -13,7 +13,7 @@ Item { property string suffix: "%" property real contentScale: 1.0 property color fillColor: Color.mPrimary - property string tooltipText: "" + property var tooltipText property string tooltipDirection: "top" // Arc geometry constants @@ -151,12 +151,12 @@ Item { anchors.fill: parent hoverEnabled: true onEntered: { - if (root.tooltipText) { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.show(root, root.tooltipText, root.tooltipDirection); } } onExited: { - if (root.tooltipText) { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.hide(); } } diff --git a/Widgets/NColorSlider.qml b/Widgets/NColorSlider.qml index f0397611b..b08aaf39e 100644 --- a/Widgets/NColorSlider.qml +++ b/Widgets/NColorSlider.qml @@ -11,7 +11,7 @@ Slider { property var cutoutColor: Color.mSurface property bool snapAlways: true property real widthRatio: 0.7 - property string tooltipText + property var tooltipText property string tooltipDirection: "auto" property bool hovering: false property color topColor: "white" @@ -212,14 +212,14 @@ Slider { onEntered: { root.hovering = true; - if (root.tooltipText) { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.show(knob, root.tooltipText, root.tooltipDirection); } } onExited: { root.hovering = false; - if (root.tooltipText) { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.hide(); } } @@ -229,7 +229,7 @@ Slider { Connections { target: root function onPressedChanged() { - if (root.pressed && root.tooltipText) { + if (root.pressed && root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.hide(); } } diff --git a/Widgets/NIconButton.qml b/Widgets/NIconButton.qml index de57588dd..ade90723c 100644 --- a/Widgets/NIconButton.qml +++ b/Widgets/NIconButton.qml @@ -11,7 +11,7 @@ Item { property bool applyUiScale: true property string icon - property string tooltipText + property var tooltipText property string tooltipDirection: "auto" property bool allowClickWhenDisabled: false property bool handleWheel: false @@ -96,20 +96,20 @@ Item { hoverEnabled: true onEntered: { hovering = root.enabled ? true : false; - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.show(root, tooltipText, tooltipDirection); } root.entered(); } onExited: { hovering = false; - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.hide(root); } root.exited(); } onClicked: mouse => { - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.hide(root); } if (!root.enabled && !allowClickWhenDisabled) { diff --git a/Widgets/NIconButtonHot.qml b/Widgets/NIconButtonHot.qml index 6f3761dfe..f86986ee6 100644 --- a/Widgets/NIconButtonHot.qml +++ b/Widgets/NIconButtonHot.qml @@ -11,8 +11,8 @@ Rectangle { // Public properties property real baseSize: Style.baseWidgetSize property bool applyUiScale: true - property string icon: "" - property string tooltipText: "" + property string icon + property var tooltipText property string tooltipDirection: "auto" property bool allowClickWhenDisabled: false property bool hot: false @@ -106,7 +106,7 @@ Rectangle { onEntered: { hovering = root.enabled ? true : false; - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.show(parent, tooltipText, tooltipDirection); } root.entered(); @@ -114,7 +114,7 @@ Rectangle { onExited: { hovering = false; - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.hide(); } root.exited(); @@ -124,7 +124,7 @@ Rectangle { if (root.enabled) { root.pressed = true; } - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.hide(); } } @@ -153,7 +153,7 @@ Rectangle { root.hovering = false; root.pressed = false; root.scale = 1.0; - if (tooltipText) { + if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.hide(); } } diff --git a/Widgets/NSettingsIndicator.qml b/Widgets/NSettingsIndicator.qml index 39153acc5..b1aeb8045 100644 --- a/Widgets/NSettingsIndicator.qml +++ b/Widgets/NSettingsIndicator.qml @@ -7,7 +7,7 @@ Rectangle { id: root property bool show: false - property string tooltipText: "" + property var tooltipText implicitWidth: root.show ? 6 * Style.uiScaleRatio : 0 implicitHeight: root.show ? 6 * Style.uiScaleRatio : 0 @@ -26,20 +26,20 @@ Rectangle { } MouseArea { - enabled: root.show && root.tooltipText !== "" + enabled: root.show && root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0) anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.NoButton cursorShape: Qt.PointingHandCursor onEntered: { - if (root.tooltipText) { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.show(root, root.tooltipText); } } onExited: { - if (root.tooltipText) { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.hide(); } } diff --git a/Widgets/NSlider.qml b/Widgets/NSlider.qml index 8732d7403..2d7dd189f 100644 --- a/Widgets/NSlider.qml +++ b/Widgets/NSlider.qml @@ -11,7 +11,7 @@ Slider { property var cutoutColor: Color.mSurface property bool snapAlways: true property real heightRatio: 0.7 - property string tooltipText + property var tooltipText property string tooltipDirection: "auto" property bool hovering: false @@ -226,14 +226,14 @@ Slider { onEntered: { root.hovering = true; - if (root.tooltipText) { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.show(knob, root.tooltipText, root.tooltipDirection); } } onExited: { root.hovering = false; - if (root.tooltipText) { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.hide(); } } @@ -243,7 +243,7 @@ Slider { Connections { target: root function onPressedChanged() { - if (root.pressed && root.tooltipText) { + if (root.pressed && root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.hide(); } } diff --git a/Widgets/NTabButton.qml b/Widgets/NTabButton.qml index d40314d41..ea132a6f8 100644 --- a/Widgets/NTabButton.qml +++ b/Widgets/NTabButton.qml @@ -8,11 +8,10 @@ import qs.Widgets Rectangle { id: root - // Public properties // Public properties property string text: "" property string icon: "" - property string tooltipText: "" + property var tooltipText property bool checked: false property int tabIndex: 0 property real pointSize: Style.fontSizeM @@ -94,7 +93,7 @@ Rectangle { id: tooltipTimer interval: 500 onTriggered: { - if (root.isHovered && root.tooltipText !== "") { + if (root.isHovered && root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.show(root, root.tooltipText); } } @@ -106,14 +105,14 @@ Rectangle { cursorShape: Qt.PointingHandCursor onEntered: { root.isHovered = true; - if (root.tooltipText !== "") { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { tooltipTimer.start(); } } onExited: { root.isHovered = false; tooltipTimer.stop(); - if (root.tooltipText !== "") { + if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) { TooltipService.hide(); } }