Skip to content

Commit

Permalink
Merge pull request #6867 from jackoalan/code-view-bg
Browse files Browse the repository at this point in the history
Qt/CodeViewWidget: Dynamic background dimming for dark themes
  • Loading branch information
leoetlino committed May 16, 2018
2 parents 9335400 + d14f6e9 commit 4de2c50
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ void CodeViewWidget::Update()
if (Core::GetState() != Core::State::Paused && PowerPC::debug_interface.IsBreakpoint(pc)) if (Core::GetState() != Core::State::Paused && PowerPC::debug_interface.IsBreakpoint(pc))
Core::SetState(Core::State::Paused); Core::SetState(Core::State::Paused);


const bool dark_theme = qApp->palette().color(QPalette::Base).valueF() < 0.5;

for (int i = 0; i < rowCount(); i++) for (int i = 0; i < rowCount(); i++)
{ {
u32 addr = m_address - ((rowCount() / 2) * 4) + i * 4; u32 addr = m_address - ((rowCount() / 2) * 4) + i * 4;
Expand All @@ -123,15 +125,14 @@ void CodeViewWidget::Update()
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
item->setData(Qt::UserRole, addr); item->setData(Qt::UserRole, addr);


if (color != 0xFFFFFF) if (addr == pc && item != bp_item)
{ {
item->setForeground(Qt::black); item->setBackground(QColor(Qt::green));
item->setBackground(QColor(color)); item->setForeground(QColor(Qt::black));
} }
if (addr == pc && item != bp_item) else if (color != 0xFFFFFF)
{ {
item->setBackground(Qt::green); item->setBackground(dark_theme ? QColor(color).darker(240) : QColor(color));
item->setForeground(Qt::black);
} }
} }


Expand All @@ -151,7 +152,7 @@ void CodeViewWidget::Update()
} }


if (ins == "blr") if (ins == "blr")
ins_item->setForeground(Qt::darkGreen); ins_item->setForeground(dark_theme ? QColor(0xa0FFa0) : Qt::darkGreen);


if (PowerPC::debug_interface.IsBreakpoint(addr)) if (PowerPC::debug_interface.IsBreakpoint(addr))
{ {
Expand Down

0 comments on commit 4de2c50

Please sign in to comment.