From a201b8a2c81ef69612139dff689f223782b47698 Mon Sep 17 00:00:00 2001 From: loner <2788892716@qq.com> Date: Mon, 17 Nov 2025 10:08:12 +0800 Subject: [PATCH] fix: Fix overlapping opacity in BarPill components --- Modules/Bar/Extras/BarPillHorizontal.qml | 30 +++++++++++++++++------- Modules/Bar/Extras/BarPillVertical.qml | 29 ++++++++++++++++------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/Modules/Bar/Extras/BarPillHorizontal.qml b/Modules/Bar/Extras/BarPillHorizontal.qml index 145631b5..230eb0fe 100644 --- a/Modules/Bar/Extras/BarPillHorizontal.qml +++ b/Modules/Bar/Extras/BarPillHorizontal.qml @@ -72,6 +72,25 @@ Item { } } + // Unified background for the entire pill area to avoid overlapping opacity + Rectangle { + id: pillBackground + width: root.width + height: pillHeight + radius: halfPillHeight + color: hovered ? Color.mHover : Settings.data.bar.showCapsule ? Qt.alpha(Color.mSurfaceVariant, Settings.data.bar.capsuleOpacity) : Color.transparent + anchors.verticalCenter: parent.verticalCenter + + readonly property int halfPillHeight: Math.round(pillHeight * 0.5) + + Behavior on color { + ColorAnimation { + duration: Style.animationNormal + easing.type: Easing.InOutQuad + } + } + } + Rectangle { id: pill @@ -82,7 +101,7 @@ Item { (iconCircle.x + iconCircle.width / 2) - width // Opens left opacity: revealed ? Style.opacityFull : Style.opacityNone - color: Settings.data.bar.showCapsule ? Qt.alpha(Color.mSurfaceVariant, Settings.data.bar.capsuleOpacity) : Color.transparent + color: Color.transparent // Make pill background transparent to avoid double opacity readonly property int halfPillHeight: Math.round(pillHeight * 0.5) @@ -135,18 +154,11 @@ Item { width: pillHeight height: pillHeight radius: width * 0.5 - color: hovered ? Color.mHover : Settings.data.bar.showCapsule ? Qt.alpha(Color.mSurfaceVariant, Settings.data.bar.capsuleOpacity) : Color.transparent + color: Color.transparent // Make icon background transparent to avoid double opacity anchors.verticalCenter: parent.verticalCenter x: oppositeDirection ? 0 : (parent.width - width) - Behavior on color { - ColorAnimation { - duration: Style.animationNormal - easing.type: Easing.InOutQuad - } - } - NIcon { icon: root.icon pointSize: iconSize diff --git a/Modules/Bar/Extras/BarPillVertical.qml b/Modules/Bar/Extras/BarPillVertical.qml index b30660f0..fc5f2ecc 100644 --- a/Modules/Bar/Extras/BarPillVertical.qml +++ b/Modules/Bar/Extras/BarPillVertical.qml @@ -83,6 +83,24 @@ Item { } } + // Unified background for the entire pill area to avoid overlapping opacity + Rectangle { + id: pillBackground + width: buttonSize + height: revealed ? (buttonSize + maxPillHeight - pillOverlap) : buttonSize + radius: halfButtonSize + color: hovered ? Color.mHover : Settings.data.bar.showCapsule ? Qt.alpha(Color.mSurfaceVariant, Settings.data.bar.capsuleOpacity) : Color.transparent + + readonly property int halfButtonSize: Math.round(buttonSize * 0.5) + + Behavior on color { + ColorAnimation { + duration: Style.animationNormal + easing.type: Easing.InOutQuad + } + } + } + Rectangle { id: pill @@ -94,7 +112,7 @@ Item { y: openUpward ? (iconCircle.y + iconCircle.height / 2 - height) : (iconCircle.y + iconCircle.height / 2) opacity: revealed ? Style.opacityFull : Style.opacityNone - color: Settings.data.bar.showCapsule ? Qt.alpha(Color.mSurfaceVariant, Settings.data.bar.capsuleOpacity) : Color.transparent + color: Color.transparent // Make pill background transparent to avoid double opacity readonly property int halfButtonSize: Math.round(buttonSize * 0.5) @@ -158,20 +176,13 @@ Item { width: buttonSize height: buttonSize radius: width * 0.5 - color: hovered ? Color.mHover : Settings.data.bar.showCapsule ? Qt.alpha(Color.mSurfaceVariant, Settings.data.bar.capsuleOpacity) : Color.transparent + color: Color.transparent // Make icon background transparent to avoid double opacity // Icon positioning based on direction x: 0 y: openUpward ? (parent.height - height) : 0 anchors.horizontalCenter: parent.horizontalCenter - Behavior on color { - ColorAnimation { - duration: Style.animationNormal - easing.type: Easing.InOutQuad - } - } - NIcon { icon: root.icon pointSize: iconSize