diff --git a/ui/annotwindow.cpp b/ui/annotwindow.cpp --- a/ui/annotwindow.cpp +++ b/ui/annotwindow.cpp @@ -276,6 +276,8 @@ pl.setColor( QPalette::Base, m_color ); textEdit->setPalette( pl ); } + auto bgLuminance = m_color.redF() * 0.2126 + m_color.greenF() * 0.7152 + m_color.blueF() * 0.0722; // Magic formula from "A Standard Default Color Space for the Internet - sRGB" + textEdit->setTextColor( ( bgLuminance > 0.65 ) ? Qt::black : Qt::white ); m_title->setAuthor( m_annot->author() ); m_title->setDate( m_annot->modificationDate() ); }