Merge pull request #13442 from TryTwo/PR_CodeWidget_Layout_Tweak

Debugger CodeWidget: Small layout tweak
This commit is contained in:
JMC47 2025-03-25 13:19:02 -04:00 committed by GitHub
commit eb84b0fb9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 26 additions and 9 deletions

View File

@ -100,16 +100,22 @@ void CodeWidget::showEvent(QShowEvent* event)
void CodeWidget::CreateWidgets()
{
auto* layout = new QGridLayout;
auto* layout = new QHBoxLayout;
layout->setContentsMargins(2, 2, 2, 2);
layout->setSpacing(0);
auto* top_layout = new QHBoxLayout;
m_search_address = new QLineEdit;
m_branch_watch = new QPushButton(tr("Branch Watch"));
m_code_view = new CodeViewWidget;
m_search_address->setPlaceholderText(tr("Search Address"));
m_branch_watch = new QPushButton(tr("Branch Watch"));
top_layout->addWidget(m_search_address);
top_layout->addWidget(m_branch_watch);
auto* right_layout = new QVBoxLayout;
m_code_view = new CodeViewWidget;
right_layout->addLayout(top_layout);
right_layout->addWidget(m_code_view);
m_box_splitter = new QSplitter(Qt::Vertical);
m_box_splitter->setStyleSheet(BOX_SPLITTER_STYLESHEET);
@ -146,12 +152,23 @@ void CodeWidget::CreateWidgets()
m_code_splitter = new QSplitter(Qt::Horizontal);
m_code_splitter->addWidget(m_box_splitter);
m_code_splitter->addWidget(m_code_view);
// right_layout is the searchbar area and the codeview.
QWidget* right_widget = new QWidget;
right_widget->setLayout(right_layout);
layout->addWidget(m_search_address, 0, 0);
layout->addWidget(m_branch_watch, 0, 2);
layout->addWidget(m_code_splitter, 1, 0, -1, -1);
m_code_splitter->addWidget(m_box_splitter);
m_code_splitter->addWidget(right_widget);
layout->addWidget(m_code_splitter);
// Corrects button height mis-aligning the layout. Note: Margin only populates values after this
// point.
const int height_fix =
m_branch_watch->sizeHint().height() - m_search_address->sizeHint().height();
auto margins = right_layout->contentsMargins();
margins.setTop(margins.top() - height_fix / 2);
right_layout->setContentsMargins(margins);
right_layout->setSpacing(right_layout->spacing() - height_fix / 2);
QWidget* widget = new QWidget(this);
widget->setLayout(layout);