Qt/CodeViewWidget: Dynamic background dimming for dark themes

This commit is contained in:
Jack Andersen 2018-05-15 14:24:29 -10:00
parent 51ce30e09d
commit d14f6e9ee6

View File

@ -100,6 +100,8 @@ void CodeViewWidget::Update()
if (Core::GetState() != Core::State::Paused && PowerPC::debug_interface.IsBreakpoint(pc))
Core::SetState(Core::State::Paused);
const bool dark_theme = qApp->palette().color(QPalette::Base).valueF() < 0.5;
for (int i = 0; i < rowCount(); i++)
{
u32 addr = m_address - ((rowCount() / 2) * 4) + i * 4;
@ -123,15 +125,14 @@ void CodeViewWidget::Update()
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
item->setData(Qt::UserRole, addr);
if (color != 0xFFFFFF)
{
item->setForeground(Qt::black);
item->setBackground(QColor(color));
}
if (addr == pc && item != bp_item)
{
item->setBackground(Qt::green);
item->setForeground(Qt::black);
item->setBackground(QColor(Qt::green));
item->setForeground(QColor(Qt::black));
}
else if (color != 0xFFFFFF)
{
item->setBackground(dark_theme ? QColor(color).darker(240) : QColor(color));
}
}
@ -151,7 +152,7 @@ void CodeViewWidget::Update()
}
if (ins == "blr")
ins_item->setForeground(Qt::darkGreen);
ins_item->setForeground(dark_theme ? QColor(0xa0FFa0) : Qt::darkGreen);
if (PowerPC::debug_interface.IsBreakpoint(addr))
{