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 | | --- | --- | | <img alt="Registers widget (before)" title="Registers widget (before)" src="https://github.com/user-attachments/assets/8a6644f9-1081-4ac8-9fff-c79ddb73e103" /> | <img alt="Registers widget (after)" title="Registers widget (after)" src="https://github.com/user-attachments/assets/67f799d0-8afd-4081-bb40-3d7a76ddc705" /> |
This commit is contained in:
@@ -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<RegisterColumn*>(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);
|
||||
|
||||
@@ -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<u64()> get_reg, std::function<void(u64)> set_reg);
|
||||
|
||||
Reference in New Issue
Block a user