Merge pull request #7697 from TryTwo/Debugger_UI_CodeView_Font_Based_Sizing
Qt/Debugger: Improve Code View
This commit is contained in:
commit
3bcee22f17
|
@ -45,23 +45,21 @@ CodeViewWidget::CodeViewWidget()
|
||||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
for (int i = 0; i < columnCount(); i++)
|
|
||||||
{
|
|
||||||
horizontalHeader()->setSectionResizeMode(i, QHeaderView::Fixed);
|
|
||||||
}
|
|
||||||
|
|
||||||
verticalHeader()->hide();
|
verticalHeader()->hide();
|
||||||
horizontalHeader()->hide();
|
horizontalHeader()->hide();
|
||||||
horizontalHeader()->setStretchLastSection(true);
|
|
||||||
|
|
||||||
setFont(Settings::Instance().GetDebugFont());
|
setFont(Settings::Instance().GetDebugFont());
|
||||||
|
|
||||||
Update();
|
FontBasedSizing();
|
||||||
|
|
||||||
connect(this, &CodeViewWidget::customContextMenuRequested, this, &CodeViewWidget::OnContextMenu);
|
connect(this, &CodeViewWidget::customContextMenuRequested, this, &CodeViewWidget::OnContextMenu);
|
||||||
connect(this, &CodeViewWidget::itemSelectionChanged, this, &CodeViewWidget::OnSelectionChanged);
|
connect(this, &CodeViewWidget::itemSelectionChanged, this, &CodeViewWidget::OnSelectionChanged);
|
||||||
connect(&Settings::Instance(), &Settings::DebugFontChanged, this, &QWidget::setFont);
|
connect(&Settings::Instance(), &Settings::DebugFontChanged, this, &QWidget::setFont);
|
||||||
|
connect(&Settings::Instance(), &Settings::DebugFontChanged, this,
|
||||||
|
&CodeViewWidget::FontBasedSizing);
|
||||||
|
|
||||||
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] {
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] {
|
||||||
m_address = PC;
|
m_address = PC;
|
||||||
Update();
|
Update();
|
||||||
|
@ -82,6 +80,16 @@ static u32 GetBranchFromAddress(u32 addr)
|
||||||
return std::stoul(hex, nullptr, 16);
|
return std::stoul(hex, nullptr, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeViewWidget::FontBasedSizing()
|
||||||
|
{
|
||||||
|
const QFontMetrics fm(Settings::Instance().GetDebugFont());
|
||||||
|
const int rowh = fm.height() + 1;
|
||||||
|
verticalHeader()->setMaximumSectionSize(rowh);
|
||||||
|
horizontalHeader()->setMinimumSectionSize(rowh + 5);
|
||||||
|
setColumnWidth(0, rowh + 5);
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
void CodeViewWidget::Update()
|
void CodeViewWidget::Update()
|
||||||
{
|
{
|
||||||
if (m_updating)
|
if (m_updating)
|
||||||
|
@ -98,8 +106,11 @@ void CodeViewWidget::Update()
|
||||||
|
|
||||||
setRowCount(rows);
|
setRowCount(rows);
|
||||||
|
|
||||||
|
const QFontMetrics fm(Settings::Instance().GetDebugFont());
|
||||||
|
const int rowh = fm.height() + 1;
|
||||||
|
|
||||||
for (int i = 0; i < rows; i++)
|
for (int i = 0; i < rows; i++)
|
||||||
setRowHeight(i, 24);
|
setRowHeight(i, rowh);
|
||||||
|
|
||||||
u32 pc = PowerPC::ppcState.pc;
|
u32 pc = PowerPC::ppcState.pc;
|
||||||
|
|
||||||
|
@ -122,9 +133,17 @@ void CodeViewWidget::Update()
|
||||||
std::string param = (split == std::string::npos ? "" : disas.substr(split + 1));
|
std::string param = (split == std::string::npos ? "" : disas.substr(split + 1));
|
||||||
std::string desc = PowerPC::debug_interface.GetDescription(addr);
|
std::string desc = PowerPC::debug_interface.GetDescription(addr);
|
||||||
|
|
||||||
auto* ins_item = new QTableWidgetItem(QString::fromStdString(ins));
|
// Adds whitespace and a minimum size to ins and param. Helps to prevent frequent resizing while
|
||||||
auto* param_item = new QTableWidgetItem(QString::fromStdString(param));
|
// scrolling.
|
||||||
auto* description_item = new QTableWidgetItem(QString::fromStdString(desc));
|
const QString ins_formatted =
|
||||||
|
QStringLiteral("%1").arg(QString::fromStdString(ins), -7, QLatin1Char(' '));
|
||||||
|
const QString param_formatted =
|
||||||
|
QStringLiteral("%1").arg(QString::fromStdString(param), -19, QLatin1Char(' '));
|
||||||
|
const QString desc_formatted = QStringLiteral("%1 ").arg(QString::fromStdString(desc));
|
||||||
|
|
||||||
|
auto* ins_item = new QTableWidgetItem(ins_formatted);
|
||||||
|
auto* param_item = new QTableWidgetItem(param_formatted);
|
||||||
|
auto* description_item = new QTableWidgetItem(desc_formatted);
|
||||||
|
|
||||||
for (auto* item : {bp_item, addr_item, ins_item, param_item, description_item})
|
for (auto* item : {bp_item, addr_item, ins_item, param_item, description_item})
|
||||||
{
|
{
|
||||||
|
@ -162,8 +181,9 @@ void CodeViewWidget::Update()
|
||||||
|
|
||||||
if (PowerPC::debug_interface.IsBreakpoint(addr))
|
if (PowerPC::debug_interface.IsBreakpoint(addr))
|
||||||
{
|
{
|
||||||
bp_item->setData(Qt::DecorationRole,
|
bp_item->setData(
|
||||||
Resources::GetScaledThemeIcon("debugger_breakpoint").pixmap(QSize(24, 24)));
|
Qt::DecorationRole,
|
||||||
|
Resources::GetScaledThemeIcon("debugger_breakpoint").pixmap(QSize(rowh - 2, rowh - 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
setItem(i, 0, bp_item);
|
setItem(i, 0, bp_item);
|
||||||
|
@ -179,8 +199,6 @@ void CodeViewWidget::Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeColumnsToContents();
|
resizeColumnsToContents();
|
||||||
setColumnWidth(0, 24 + 5);
|
|
||||||
|
|
||||||
g_symbolDB.FillInCallers();
|
g_symbolDB.FillInCallers();
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
|
|
|
@ -30,6 +30,8 @@ public:
|
||||||
u32 GetContextAddress() const;
|
u32 GetContextAddress() const;
|
||||||
void SetAddress(u32 address, SetAddressUpdate update);
|
void SetAddress(u32 address, SetAddressUpdate update);
|
||||||
|
|
||||||
|
// Set tighter row height. Set BP column sizing. This needs to run when font type changes.
|
||||||
|
void FontBasedSizing();
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
void ToggleBreakpoint();
|
void ToggleBreakpoint();
|
||||||
|
|
Loading…
Reference in New Issue