Commit af2a7434 authored by Radek Hušek's avatar Radek Hušek
Browse files

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
parent 0a349abc
......@@ -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 {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment