From fc0033ede6b0bb88d737752b8db359194cb4e41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Hu=C5=A1ek?= Date: Mon, 12 Mar 2018 13:32:28 +0100 Subject: [PATCH] KDE logout screen background color fix Summary: The patch D5036 did calculate wrong whether the background color is light or not which resulted in always black background. The problem was that color reported by plasma is in range 0.0 -- 1.0 not 0 -- 255. Now the background is black only when button background color is dark and otherwise it respects button background color. BUG: 382264 Reviewers: mart, #plasma Reviewed By: mart, #plasma Subscribers: fredrik, ngraham, abetts, broulik, mvourlakos, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D11262 --- lookandfeel/contents/logout/Logout.qml | 33 +++----------------------- 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/lookandfeel/contents/logout/Logout.qml b/lookandfeel/contents/logout/Logout.qml index 180dd5ae2..d25a868c3 100644 --- a/lookandfeel/contents/logout/Logout.qml +++ b/lookandfeel/contents/logout/Logout.qml @@ -83,42 +83,15 @@ PlasmaCore.ColorScope { onTriggered: remainingTime-- } - function rgbToHsv(color) { - var max = Math.max(color.r, color.g, color.b); - var min = Math.min(color.r, color.g, color.b); - var d = max - min; - var h; - var s = (max === 0 ? 0 : d / max); - var v = max / 255; - - switch (max) { - case min: - h = 0; - break; - case color.r: - h = (color.g - color.b) + d * (color.g < color.b ? 6: 0); - h /= 6 * d; - break; - case color.g: - h = (color.b - color.r) + d * 2; h /= 6 * d; - break; - case color.b: - h = (color.r - color.g) + d * 4; h /= 6 * d; - break; - } - - return { - h: h, - s: s, - v: v - }; + function isLightColor(color) { + return Math.max(color.r, color.g, color.b) > 0.5 } Rectangle { id: backgroundRect anchors.fill: parent //use "black" because this is intended to look like a general darkening of the scene. a dark gray as normal background would just look too "washed out" - color: root.rgbToHsv(PlasmaCore.ColorScope.backgroundColor).v > 128 ? PlasmaCore.ColorScope.backgroundColor : "black" + color: root.isLightColor(PlasmaCore.ColorScope.backgroundColor) ? PlasmaCore.ColorScope.backgroundColor : "black" opacity: 0.5 } MouseArea {