From a7d33dc2b06114a036bc430aeaec5da9f83711ac Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 13 Jun 2025 13:30:26 +0200 Subject: [PATCH] ProjectExplorer: Remove an unnecessarily nested layout Change-Id: Icbde0f82e0f7ae1d6c378256716a0d55abdda075 Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/projectwindow.cpp | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index bdbb841c74a..34b0dde4af3 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -91,6 +91,7 @@ public: explicit ProjectPanel(QWidget *inner, bool addGlobalSettings, bool addStretch) { setWindowTitle(inner->windowTitle()); + setFocusProxy(inner); auto root = new QWidget(nullptr); root->setFocusPolicy(Qt::NoFocus); @@ -102,18 +103,11 @@ public: scroller->setWidgetResizable(true); scroller->setFocusPolicy(Qt::NoFocus); - // The layout holding the individual panels: + // The layout holding the panel. auto topLayout = new QVBoxLayout(root); topLayout->setContentsMargins(PanelVMargin, 0, PanelVMargin, 0); topLayout->setSpacing(0); - m_layout = new QVBoxLayout; - m_layout->setSpacing(0); - - topLayout->addLayout(m_layout); - if (addStretch) - topLayout->addStretch(1); - auto layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); @@ -125,7 +119,6 @@ public: auto widget = dynamic_cast(inner); if (QTC_GUARD(widget)) { if (widget->isUseGlobalSettingsCheckBoxVisible() || widget->isUseGlobalSettingsLabelVisible()) { - m_layout->setContentsMargins(0, 0, 0, 0); const auto useGlobalSettingsCheckBox = new QCheckBox; useGlobalSettingsCheckBox->setChecked(widget->useGlobalSettings()); useGlobalSettingsCheckBox->setEnabled(widget->isUseGlobalSettingsCheckBoxEnabled()); @@ -161,21 +154,19 @@ public: }); } horizontalLayout->addStretch(1); - m_layout->addLayout(horizontalLayout); - m_layout->addWidget(Layouting::createHr()); + topLayout->addLayout(horizontalLayout); + topLayout->addWidget(Layouting::createHr()); } } } inner->setContentsMargins(0, CONTENTS_MARGIN, 0, BELOW_CONTENTS_MARGIN); inner->setParent(root); - m_layout->addWidget(inner); + topLayout->addWidget(inner); - setFocusProxy(inner); + if (addStretch) + topLayout->addStretch(1); } - -private: - QVBoxLayout *m_layout; };