From be3a001edc38ff860394f86a1e92da4e6ceec485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Bari?= Date: Wed, 15 Oct 2025 15:12:07 +0200 Subject: [PATCH] fix: ensuring contrasting text color for highlighted menuitems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tamás Bari --- src/gui/tray/CurrentAccountHeaderButton.qml | 6 +++--- src/gui/tray/UserLine.qml | 8 ++++---- theme/Style/Style.qml | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/gui/tray/CurrentAccountHeaderButton.qml b/src/gui/tray/CurrentAccountHeaderButton.qml index 13dffc7af5..e944494ed5 100644 --- a/src/gui/tray/CurrentAccountHeaderButton.qml +++ b/src/gui/tray/CurrentAccountHeaderButton.qml @@ -147,7 +147,7 @@ Button { color: !parent.enabled ? parent.palette.mid : (parent.highlighted || parent.down - ? parent.palette.highlightedText + ? Style.contrastingColor( parent.palette.highlight ) : parent.palette.text) } } @@ -171,7 +171,7 @@ Button { color: !parent.enabled ? parent.palette.mid : (parent.highlighted || parent.down - ? parent.palette.highlightedText + ? Style.contrastingColor( parent.palette.highlight ) : parent.palette.text) } } @@ -195,7 +195,7 @@ Button { color: !parent.enabled ? parent.palette.mid : (parent.highlighted || parent.down - ? parent.palette.highlightedText + ? Style.contrastingColor( parent.palette.highlight ) : parent.palette.text) } } diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index f3793dd51a..5f0ad8e2f6 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -83,7 +83,7 @@ AbstractButton { color: !userLine.parent.enabled ? userLine.parent.palette.mid : (userLine.parent.highlighted || userLine.parent.down - ? userLine.parent.palette.highlightedText + ? Style.contrastingColor( parent.palette.highlight ) : userLine.parent.palette.text) } @@ -103,7 +103,7 @@ AbstractButton { color: !userLine.parent.enabled ? userLine.parent.palette.mid : (userLine.parent.highlighted || userLine.parent.down - ? userLine.parent.palette.highlightedText + ? Style.contrastingColor( parent.palette.highlight ) : userLine.parent.palette.text) } @@ -135,7 +135,7 @@ AbstractButton { color: !userLine.parent.enabled ? userLine.parent.palette.mid : (userLine.parent.highlighted || userLine.parent.down - ? userLine.parent.palette.highlightedText + ? Style.contrastingColor( parent.palette.highlight ) : userLine.parent.palette.text) } } @@ -159,7 +159,7 @@ AbstractButton { property var iconColor: !userLine.parent.enabled ? userLine.parent.palette.mid : (!hovered && (userLine.parent.highlighted || userLine.parent.down) - ? userLine.parent.palette.highlightedText + ? Style.contrastingColor( parent.palette.highlight ) : userLine.parent.palette.text) icon.source: "image://svgimage-custom-color/more.svg/" + iconColor diff --git a/theme/Style/Style.qml b/theme/Style/Style.qml index 98856f8c8e..3f86f73c05 100644 --- a/theme/Style/Style.qml +++ b/theme/Style/Style.qml @@ -211,4 +211,10 @@ QtObject { function colorWithoutTransparency(color) { return Qt.rgba(color.r, color.g, color.b, 1) } + + function contrastingColor(color) { + // sRGB relative luminance formula + const luminance = 0.299 * color.r + 0.587 * color.g + 0.114 * color.b + return luminance > 0.5 ? Qt.darker( color, 2.0 ) : Qt.lighter( color, 2.0 ) + } }