From c942c10f8a153f13b3070f3af6b7d8effa3b8671 Mon Sep 17 00:00:00 2001 From: Lemmy Date: Sun, 29 Mar 2026 10:52:58 -0400 Subject: [PATCH] fix(widgets): improves disable states by avoiding stacking opacities --- Widgets/NButton.qml | 4 ++-- Widgets/NCheckbox.qml | 2 +- Widgets/NComboBox.qml | 2 +- Widgets/NIconButton.qml | 4 ++-- Widgets/NIconButtonHot.qml | 4 ++-- Widgets/NSearchableComboBox.qml | 1 + Widgets/NSectionEditor.qml | 1 - Widgets/NToggle.qml | 4 +--- 8 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Widgets/NButton.qml b/Widgets/NButton.qml index a579a6f94..fab351423 100644 --- a/Widgets/NButton.qml +++ b/Widgets/NButton.qml @@ -140,9 +140,9 @@ Rectangle { cursorShape: root.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor onEntered: { - root.hovered = true; + root.hovered = root.enabled ? true : false; root.entered(); - if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { + if (hovered && tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.show(root, root.tooltipText); } } diff --git a/Widgets/NCheckbox.qml b/Widgets/NCheckbox.qml index a9c67889f..30e51d04f 100644 --- a/Widgets/NCheckbox.qml +++ b/Widgets/NCheckbox.qml @@ -23,7 +23,6 @@ RowLayout { signal exited Layout.fillWidth: true - opacity: enabled ? 1.0 : 0.6 NLabel { label: root.label @@ -40,6 +39,7 @@ RowLayout { Rectangle { id: box + opacity: enabled ? 1.0 : 0.6 Layout.margins: Style.borderS implicitWidth: Style.toOdd(root.baseSize) implicitHeight: Style.toOdd(root.baseSize) diff --git a/Widgets/NComboBox.qml b/Widgets/NComboBox.qml index c94f317e1..a669696c0 100644 --- a/Widgets/NComboBox.qml +++ b/Widgets/NComboBox.qml @@ -27,7 +27,6 @@ RowLayout { signal selected(string key) spacing: Style.marginL - opacity: enabled ? 1.0 : 0.6 // Less strict comparison with != (instead of !==) so it can properly compare int vs string (ex for FPS: 30 and "30") readonly property bool isValueChanged: (defaultValue !== undefined) && (currentKey != defaultValue) @@ -136,6 +135,7 @@ RowLayout { ComboBox { id: combo + opacity: enabled ? 1.0 : 0.6 Layout.margins: Style.borderS Layout.minimumWidth: Math.round(root.minimumWidth * Style.uiScaleRatio) Layout.preferredHeight: Math.round(root.preferredHeight * Style.uiScaleRatio) diff --git a/Widgets/NIconButton.qml b/Widgets/NIconButton.qml index ade90723c..52f435596 100644 --- a/Widgets/NIconButton.qml +++ b/Widgets/NIconButton.qml @@ -45,7 +45,7 @@ Item { implicitWidth: buttonSize implicitHeight: buttonSize - opacity: root.enabled ? Style.opacityFull : Style.opacityMedium + opacity: enabled ? 1.0 : 0.6 // Visual button - stays at buttonSize, centered in parent Rectangle { @@ -96,7 +96,7 @@ Item { hoverEnabled: true onEntered: { hovering = root.enabled ? true : false; - if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { + if (hovering && tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.show(root, tooltipText, tooltipDirection); } root.entered(); diff --git a/Widgets/NIconButtonHot.qml b/Widgets/NIconButtonHot.qml index f86986ee6..39fdb9278 100644 --- a/Widgets/NIconButtonHot.qml +++ b/Widgets/NIconButtonHot.qml @@ -45,7 +45,7 @@ Rectangle { implicitHeight: applyUiScale ? Math.round(baseSize * Style.uiScaleRatio) : Math.round(baseSize) // Appearance - opacity: root.enabled ? Style.opacityFull : Style.opacityMedium + opacity: enabled ? 1.0 : 0.6 color: { if (root.enabled && root.hovering || pressed) { return colorBgHover; @@ -106,7 +106,7 @@ Rectangle { onEntered: { hovering = root.enabled ? true : false; - if (tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { + if (hovering && tooltipText && (!Array.isArray(tooltipText) || tooltipText.length > 0)) { TooltipService.show(parent, tooltipText, tooltipDirection); } root.entered(); diff --git a/Widgets/NSearchableComboBox.qml b/Widgets/NSearchableComboBox.qml index 03cd49df1..7e5893028 100644 --- a/Widgets/NSearchableComboBox.qml +++ b/Widgets/NSearchableComboBox.qml @@ -172,6 +172,7 @@ RowLayout { ComboBox { id: combo + opacity: enabled ? 1.0 : 0.6 Layout.margins: Style.borderS Layout.minimumWidth: Math.round(root.minimumWidth * Style.uiScaleRatio) Layout.preferredHeight: Math.round(root.preferredHeight * Style.uiScaleRatio) diff --git a/Widgets/NSectionEditor.qml b/Widgets/NSectionEditor.qml index ee770ec03..944719988 100644 --- a/Widgets/NSectionEditor.qml +++ b/Widgets/NSectionEditor.qml @@ -120,7 +120,6 @@ NBox { signal openPluginSettingsRequested(var pluginManifest) color: Color.mSurface - opacity: enabled ? 1.0 : 0.6 Layout.fillWidth: true z: flowDragArea.dragStarted ? 5000 : 0 diff --git a/Widgets/NToggle.qml b/Widgets/NToggle.qml index 744e69a15..6c5158bfa 100644 --- a/Widgets/NToggle.qml +++ b/Widgets/NToggle.qml @@ -21,8 +21,6 @@ RowLayout { signal exited Layout.fillWidth: true - - opacity: enabled ? 1.0 : 0.6 spacing: Style.marginM readonly property bool isValueChanged: (defaultValue !== undefined) && (checked !== defaultValue) @@ -44,9 +42,9 @@ RowLayout { Rectangle { id: switcher + opacity: enabled ? 1.0 : 0.6 Layout.alignment: Qt.AlignVCenter Layout.margins: Style.borderS - implicitWidth: Math.round(root.baseSize * .85) * 2 implicitHeight: Math.round(root.baseSize * .5) * 2 radius: Math.min(Style.iRadiusL, height / 2)