Added logic to Qt trace logger and ram search to change fore/background color scheme based on style theme.
This commit is contained in:
parent
e42232777e
commit
f4da749a44
|
@ -1467,12 +1467,33 @@ QRamSearchView::QRamSearchView(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
QColor fg(0,0,0), bg(255,255,255);
|
QColor c, fg(0,0,0), bg(255,255,255);
|
||||||
|
bool useDarkTheme = false;
|
||||||
|
|
||||||
pal = this->palette();
|
pal = this->palette();
|
||||||
|
|
||||||
|
// Figure out if we are using a light or dark theme by checking the
|
||||||
|
// default window text grayscale color. If more white, then we will
|
||||||
|
// use white text on black background, else we do the opposite.
|
||||||
|
c = pal.color(QPalette::WindowText);
|
||||||
|
|
||||||
|
if ( qGray( c.red(), c.green(), c.blue() ) > 128 )
|
||||||
|
{
|
||||||
|
useDarkTheme = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( useDarkTheme )
|
||||||
|
{
|
||||||
|
pal.setColor(QPalette::Base , fg );
|
||||||
|
pal.setColor(QPalette::Background, fg );
|
||||||
|
pal.setColor(QPalette::WindowText, bg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pal.setColor(QPalette::Base , bg );
|
pal.setColor(QPalette::Base , bg );
|
||||||
pal.setColor(QPalette::Background, bg );
|
pal.setColor(QPalette::Background, bg );
|
||||||
pal.setColor(QPalette::WindowText, fg );
|
pal.setColor(QPalette::WindowText, fg );
|
||||||
|
}
|
||||||
this->setPalette(pal);
|
this->setPalette(pal);
|
||||||
|
|
||||||
font.setFamily("Courier New");
|
font.setFamily("Courier New");
|
||||||
|
|
|
@ -1056,15 +1056,37 @@ QTraceLogView::QTraceLogView(QWidget *parent)
|
||||||
{
|
{
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
QColor fg("black"), bg("white");
|
QColor fg("black"), bg("white");
|
||||||
|
QColor c;
|
||||||
|
bool useDarkTheme = false;
|
||||||
|
|
||||||
font.setFamily("Courier New");
|
font.setFamily("Courier New");
|
||||||
font.setStyle( QFont::StyleNormal );
|
font.setStyle( QFont::StyleNormal );
|
||||||
font.setStyleHint( QFont::Monospace );
|
font.setStyleHint( QFont::Monospace );
|
||||||
|
|
||||||
pal = this->palette();
|
pal = this->palette();
|
||||||
|
|
||||||
|
// Figure out if we are using a light or dark theme by checking the
|
||||||
|
// default window text grayscale color. If more white, then we will
|
||||||
|
// use white text on black background, else we do the opposite.
|
||||||
|
c = pal.color(QPalette::WindowText);
|
||||||
|
|
||||||
|
if ( qGray( c.red(), c.green(), c.blue() ) > 128 )
|
||||||
|
{
|
||||||
|
useDarkTheme = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( useDarkTheme )
|
||||||
|
{
|
||||||
|
pal.setColor(QPalette::Base , fg );
|
||||||
|
pal.setColor(QPalette::Background, fg );
|
||||||
|
pal.setColor(QPalette::WindowText, bg );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
pal.setColor(QPalette::Base , bg );
|
pal.setColor(QPalette::Base , bg );
|
||||||
pal.setColor(QPalette::Background, bg );
|
pal.setColor(QPalette::Background, bg );
|
||||||
pal.setColor(QPalette::WindowText, fg );
|
pal.setColor(QPalette::WindowText, fg );
|
||||||
|
}
|
||||||
|
|
||||||
this->setPalette(pal);
|
this->setPalette(pal);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue