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);