From 290fddaf5582ed4e28f17d3e4a3fdc775ffaaec7 Mon Sep 17 00:00:00 2001 From: k1-801 Date: Fri, 4 Sep 2020 22:52:53 +0400 Subject: [PATCH] Fix incorrect font color detection for DeviceView (threshold 50) --- qt/DeviceView.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qt/DeviceView.cpp b/qt/DeviceView.cpp index c170f15a..0f3d3b72 100644 --- a/qt/DeviceView.cpp +++ b/qt/DeviceView.cpp @@ -503,7 +503,9 @@ void DeviceView::paintEvent(QPaintEvent* /* event */) font.setPixelSize(posh / 2); painter.setFont(font); - if(currentColor.value() > 127) + unsigned int luma = (unsigned int)(0.2126f * currentColor.red() + 0.7152f * currentColor.green() + 0.0722f * currentColor.blue()); + + if(luma > 127) { painter.setPen(Qt::black); }