From 70ca98c8e782353f8885faf5854540cdef305e03 Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Sat, 5 May 2018 04:21:15 -0400 Subject: [PATCH] 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. --- .../Core/DolphinQt2/Debugger/CodeViewWidget.cpp | 17 ++++++++++++++++- .../Core/DolphinQt2/Debugger/CodeViewWidget.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) 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(); diff --git a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.h b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.h index 4189588d07..3db80cfc16 100644 --- a/Source/Core/DolphinQt2/Debugger/CodeViewWidget.h +++ b/Source/Core/DolphinQt2/Debugger/CodeViewWidget.h @@ -49,6 +49,7 @@ private: void OnCopyCode(); void OnCopyHex(); void OnRenameSymbol(); + void OnSelectionChanged(); void OnSetSymbolSize(); void OnSetSymbolEndAddress(); void OnRunToHere();