From a051acec9186511b248fc9e30e37b9ad5055430b Mon Sep 17 00:00:00 2001 From: cristian64 Date: Fri, 27 Mar 2026 09:30:31 +0000 Subject: [PATCH] DolphinQt: Size adjustments in **Registers** widget based on selected debug font. - Row height is no longer hardcoded to `24`; instead, the height is determined by the font height of the currently selected debug font. - Header height has been reduced (a factor of the font height) as it only serves as a column resizer. - A `OnDebugFontChanged()` slot has been connected to properly update the widget on debug font changes. | Before | After | | --- | --- | | Registers widget (before) | Registers widget (after) | --- .../DolphinQt/Debugger/RegisterWidget.cpp | 21 ++++++++++++++++--- .../Core/DolphinQt/Debugger/RegisterWidget.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp b/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp index 80cd55f674..84b7e7b74f 100644 --- a/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp @@ -80,10 +80,10 @@ void RegisterWidget::CreateWidgets() m_table->setColumnCount(9); m_table->verticalHeader()->setVisible(false); - m_table->verticalHeader()->setDefaultSectionSize(24); m_table->setContextMenuPolicy(Qt::CustomContextMenu); m_table->setSelectionMode(QAbstractItemView::NoSelection); - m_table->setFont(Settings::Instance().GetDebugFont()); + + OnDebugFontChanged(Settings::Instance().GetDebugFont()); QStringList empty_list; @@ -106,7 +106,8 @@ void RegisterWidget::ConnectWidgets() connect(m_table, &QTableWidget::customContextMenuRequested, this, &RegisterWidget::ShowContextMenu); connect(m_table, &QTableWidget::itemChanged, this, &RegisterWidget::OnItemChanged); - connect(&Settings::Instance(), &Settings::DebugFontChanged, m_table, &RegisterWidget::setFont); + connect(&Settings::Instance(), &Settings::DebugFontChanged, this, + &RegisterWidget::OnDebugFontChanged); } void RegisterWidget::OnItemChanged(QTableWidgetItem* item) @@ -115,6 +116,20 @@ void RegisterWidget::OnItemChanged(QTableWidgetItem* item) static_cast(item)->SetValue(); } +void RegisterWidget::OnDebugFontChanged(const QFont& font) +{ + if (m_table) + { + m_table->setFont(font); + const auto fontHeight = m_table->fontMetrics().height(); + m_table->verticalHeader()->setDefaultSectionSize(fontHeight); + + // Header height doesn't have to be great. As there are no labels, its only purpose is to make + // columns resizable. + m_table->horizontalHeader()->setFixedHeight(fontHeight * 5 / 4); + } +} + void RegisterWidget::ShowContextMenu() { QMenu* menu = new QMenu(this); diff --git a/Source/Core/DolphinQt/Debugger/RegisterWidget.h b/Source/Core/DolphinQt/Debugger/RegisterWidget.h index 8f02089379..81baae1bd5 100644 --- a/Source/Core/DolphinQt/Debugger/RegisterWidget.h +++ b/Source/Core/DolphinQt/Debugger/RegisterWidget.h @@ -46,6 +46,7 @@ private: void ShowContextMenu(); void OnItemChanged(QTableWidgetItem* item); + void OnDebugFontChanged(const QFont& font); void AddRegister(int row, int column, RegisterType type, std::string register_name, std::function get_reg, std::function set_reg);