summaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 251e2b15..488a9b01 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1326,12 +1326,12 @@ void ColorSettings::setColorSeparatorScrollbar(bool b)
QColor ColorSettings::idealTextColor(const QColor& rBackgroundColor)
{
- if (rBackgroundColor.alpha() == 0)
+ if (rBackgroundColor.alpha() < 50)
return QColor(Qt::black);
- const int THRESHOLD = 106 * 255.0f / rBackgroundColor.alpha();
- int BackgroundDelta = (rBackgroundColor.red() * 0.299) + (rBackgroundColor.green() * 0.587) + (rBackgroundColor.blue() * 0.114);
- return QColor((255 - BackgroundDelta <= THRESHOLD) ? Qt::black : Qt::white);
+ // "inverse' of luminance of the background
+ int iLuminance = (rBackgroundColor.red() * 0.299) + (rBackgroundColor.green() * 0.587) + (rBackgroundColor.blue() * 0.114);
+ return QColor(iLuminance >= 128 ? Qt::black : Qt::white);
}