From d14f6e9ee6d144e14e94583f8043c705839e8883 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 15 May 2018 14:24:29 -1000 Subject: [PATCH] Qt/CodeViewWidget: Dynamic background dimming for dark themes --- .../Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index 7ecffdd9d7..f3dfad215a 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -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)) {