From 9a2dd470a09c40fe36117f2c3b8b95c472e13e96 Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Sat, 5 May 2018 01:31:53 -0400 Subject: Qt/debugger: change some colors logic in the codeWidget This commit makes the colors hardcoded except when there is no symbols loaded, in which case, it uses the theme colors, except for the PC which is hardcoded to black on green. This makes a compromise between making use of the corespoinding theme color and the text being nicely readable on all themes. --- Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp') diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index 0705dc5708..f4fb25544d 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -119,6 +119,23 @@ void CodeViewWidget::Update() auto* param_item = new QTableWidgetItem(QString::fromStdString(param)); auto* description_item = new QTableWidgetItem(QString::fromStdString(desc)); + for (auto* item : {bp_item, addr_item, ins_item, param_item, description_item}) + { + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setData(Qt::UserRole, addr); + + if (color != 0xFFFFFF) + { + item->setForeground(QColor(Qt::black)); + item->setBackground(QColor(color)); + } + if (addr == pc && item != bp_item) + { + item->setBackground(QColor(Qt::green)); + item->setForeground(QColor(Qt::black)); + } + } + // look for hex strings to decode branches std::string hex_str; size_t pos = param.find("0x"); @@ -137,20 +154,6 @@ void CodeViewWidget::Update() if (ins == "blr") ins_item->setForeground(Qt::darkGreen); - for (auto* item : {bp_item, addr_item, ins_item, param_item, description_item}) - { - item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setData(Qt::UserRole, addr); - - if (color != 0xFFFFFF) - item->setBackground(QColor(color).darker(110)); - - if (addr == pc && item != bp_item) - { - item->setBackground(QColor(Qt::green).darker(110)); - } - } - if (PowerPC::debug_interface.IsBreakpoint(addr)) { bp_item->setData(Qt::DecorationRole, -- cgit v1.2.3 From 70ca98c8e782353f8885faf5854540cdef305e03 Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Sat, 5 May 2018 04:21:15 -0400 Subject: Qt/debugger: change how the selected line in the code widget looks Not only it colors the entire row instead of just the address, but if the pc is the selected row, the pc color will overwrite the selection, this is done via a stylesheet. --- Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp') diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index f4fb25544d..7bfc4131bd 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -39,6 +39,7 @@ CodeViewWidget::CodeViewWidget() setShowGrid(false); setContextMenuPolicy(Qt::CustomContextMenu); setSelectionMode(QAbstractItemView::SingleSelection); + setSelectionBehavior(QAbstractItemView::SelectRows); verticalScrollBar()->setHidden(true); for (int i = 0; i < columnCount(); i++) @@ -56,6 +57,7 @@ CodeViewWidget::CodeViewWidget() Update(); connect(this, &CodeViewWidget::customContextMenuRequested, this, &CodeViewWidget::OnContextMenu); + connect(this, &CodeViewWidget::itemSelectionChanged, this, &CodeViewWidget::OnSelectionChanged); connect(&Settings::Instance(), &Settings::DebugFontChanged, this, &QWidget::setFont); connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] { m_address = PC; @@ -168,7 +170,7 @@ void CodeViewWidget::Update() if (addr == GetAddress()) { - addr_item->setSelected(true); + selectRow(addr_item->row()); } } @@ -390,6 +392,19 @@ void CodeViewWidget::OnRenameSymbol() } } +void CodeViewWidget::OnSelectionChanged() +{ + if (m_address == PowerPC::ppcState.pc) + { + setStyleSheet(QString::fromStdString( + "QTableView::item:selected {background-color: #00FF00; color: #000000;}")); + } + else if (!styleSheet().isEmpty()) + { + setStyleSheet(QString::fromStdString("")); + } +} + void CodeViewWidget::OnSetSymbolSize() { const u32 addr = GetContextAddress(); -- cgit v1.2.3 From 238c801711f9daa4613e988fa2147bd9e852ba91 Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Sat, 5 May 2018 18:17:06 -0400 Subject: Qt/debugger: properly updates when we break The Host_UpdateDisasmDialog was unimplemented in Qt which is required to get updates when we break. Additionally, this updates the debugger toolbar. --- Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp') diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index 7bfc4131bd..10ac62d7a6 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -187,13 +187,14 @@ u32 CodeViewWidget::GetAddress() const return m_address; } -void CodeViewWidget::SetAddress(u32 address) +void CodeViewWidget::SetAddress(u32 address, SetAddressUpdate update) { if (m_address == address) return; m_address = address; - Update(); + if (update == SetAddressUpdate::WithUpdate) + Update(); } void CodeViewWidget::ReplaceAddress(u32 address, bool blr) @@ -367,7 +368,7 @@ void CodeViewWidget::OnFollowBranch() if (!branch_addr) return; - SetAddress(branch_addr); + SetAddress(branch_addr, SetAddressUpdate::WithUpdate); } void CodeViewWidget::OnRenameSymbol() @@ -533,7 +534,7 @@ void CodeViewWidget::mousePressEvent(QMouseEvent* event) if (column(item) == 0) ToggleBreakpoint(); else - SetAddress(addr); + SetAddress(addr, SetAddressUpdate::WithUpdate); Update(); break; -- cgit v1.2.3 From be6b4edb0c83551e12305603bc90e5bee33a134a Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Fri, 11 May 2018 07:23:37 -0400 Subject: Qt/debugger: only resize the columns of the code view once per update Putting the columns to resizeToContents causes way too much resizes per updates which can cause severe lags and even crashes. This only does one resize at the end of the columns. --- Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp') diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp index 10ac62d7a6..e531fc66c8 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.cpp @@ -44,8 +44,7 @@ CodeViewWidget::CodeViewWidget() for (int i = 0; i < columnCount(); i++) { - horizontalHeader()->setSectionResizeMode(i, i == 0 ? QHeaderView::Fixed : - QHeaderView::ResizeToContents); + horizontalHeader()->setSectionResizeMode(i, QHeaderView::Fixed); } verticalHeader()->hide(); @@ -174,6 +173,7 @@ void CodeViewWidget::Update() } } + resizeColumnsToContents(); setColumnWidth(0, 24 + 5); g_symbolDB.FillInCallers(); -- cgit v1.2.3