diff --git a/src/plugins/debugger/analyzer/analyzerrunconfigwidget.cpp b/src/plugins/debugger/analyzer/analyzerrunconfigwidget.cpp index 39a3684ab36..0c3479a61c4 100644 --- a/src/plugins/debugger/analyzer/analyzerrunconfigwidget.cpp +++ b/src/plugins/debugger/analyzer/analyzerrunconfigwidget.cpp @@ -27,76 +27,62 @@ #include "analyzerrunconfigwidget.h" #include -#include +#include -#include -#include -#include -#include #include +#include #include +using namespace Utils; + namespace Debugger { AnalyzerRunConfigWidget::AnalyzerRunConfigWidget(ProjectExplorer::GlobalOrProjectAspect *aspect) { - m_aspect = aspect; + using namespace Layouting; - auto globalSetting = new QWidget; - auto globalSettingLayout = new QHBoxLayout(globalSetting); - globalSettingLayout->setContentsMargins(0, 0, 0, 0); + auto settingsCombo = new QComboBox; + settingsCombo->addItem(tr("Global")); + settingsCombo->addItem(tr("Custom")); - m_settingsCombo = new QComboBox(globalSetting); - m_settingsCombo->addItems(QStringList({ - QApplication::translate("ProjectExplorer::Internal::EditorSettingsPropertiesPage", "Global"), - QApplication::translate("ProjectExplorer::Internal::EditorSettingsPropertiesPage", "Custom") - })); - globalSettingLayout->addWidget(m_settingsCombo); - connect(m_settingsCombo, QOverload::of(&QComboBox::activated), - this, &AnalyzerRunConfigWidget::chooseSettings); - m_restoreButton = new QPushButton( - QApplication::translate("ProjectExplorer::Internal::EditorSettingsPropertiesPage", "Restore Global"), - globalSetting); - globalSettingLayout->addWidget(m_restoreButton); - connect(m_restoreButton, &QPushButton::clicked, this, &AnalyzerRunConfigWidget::restoreGlobal); - globalSettingLayout->addStretch(2); + auto restoreButton = new QPushButton(tr("Restore Global")); - QWidget *innerPane = new QWidget; - m_configWidget = aspect->projectSettings()->createConfigWidget(); + auto innerPane = new QWidget; + auto configWidget = aspect->projectSettings()->createConfigWidget(); - auto layout = new QVBoxLayout(innerPane); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(globalSetting); - layout->addWidget(m_configWidget); + auto details = new DetailsWidget; + details->setWidget(innerPane); - m_details = new Utils::DetailsWidget; - m_details->setWidget(innerPane); + Column { + Row { settingsCombo, restoreButton, Stretch() }, + configWidget + }.attachTo(innerPane); - auto outerLayout = new QVBoxLayout(this); - outerLayout->addWidget(m_details); - outerLayout->setContentsMargins(0, 0, 0, 0); + Column { details }.attachTo(this); - chooseSettings(m_aspect->isUsingGlobalSettings() ? 0 : 1); -} + details->layout()->setContentsMargins(0, 0, 0, 0); + innerPane->layout()->setContentsMargins(0, 0, 0, 0); + layout()->setContentsMargins(0, 0, 0, 0); -void AnalyzerRunConfigWidget::chooseSettings(int setting) -{ - QTC_ASSERT(m_aspect, return); - bool isCustom = (setting == 1); + auto chooseSettings = [=](int setting) { + const bool isCustom = (setting == 1); - m_settingsCombo->setCurrentIndex(setting); - m_aspect->setUsingGlobalSettings(!isCustom); - m_configWidget->setEnabled(isCustom); - m_restoreButton->setEnabled(isCustom); - m_details->setSummaryText(isCustom - ? tr("Use Customized Settings") - : tr("Use Global Settings")); -} + settingsCombo->setCurrentIndex(setting); + aspect->setUsingGlobalSettings(!isCustom); + configWidget->setEnabled(isCustom); + restoreButton->setEnabled(isCustom); + details->setSummaryText(isCustom + ? tr("Use Customized Settings") + : tr("Use Global Settings")); + }; -void AnalyzerRunConfigWidget::restoreGlobal() -{ - QTC_ASSERT(m_aspect, return); - m_aspect->resetProjectToGlobalSettings(); + chooseSettings(aspect->isUsingGlobalSettings() ? 0 : 1); + + connect(settingsCombo, QOverload::of(&QComboBox::activated), + this, chooseSettings); + + connect(restoreButton, &QPushButton::clicked, + aspect, &ProjectExplorer::GlobalOrProjectAspect::resetProjectToGlobalSettings); } } // namespace Debugger diff --git a/src/plugins/debugger/analyzer/analyzerrunconfigwidget.h b/src/plugins/debugger/analyzer/analyzerrunconfigwidget.h index ec35f2f5a95..3924dfc61b3 100644 --- a/src/plugins/debugger/analyzer/analyzerrunconfigwidget.h +++ b/src/plugins/debugger/analyzer/analyzerrunconfigwidget.h @@ -30,31 +30,16 @@ #include -QT_BEGIN_NAMESPACE -class QComboBox; -class QPushButton; -QT_END_NAMESPACE - -namespace Utils { class DetailsWidget; } +#include namespace Debugger { class DEBUGGER_EXPORT AnalyzerRunConfigWidget : public QWidget { - Q_OBJECT + Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::Internal::EditorSettingsPropertiesPage); public: AnalyzerRunConfigWidget(ProjectExplorer::GlobalOrProjectAspect *aspect); - -private: - void chooseSettings(int setting); - void restoreGlobal(); - - QWidget *m_configWidget; - ProjectExplorer::GlobalOrProjectAspect *m_aspect; - QComboBox *m_settingsCombo; - QPushButton *m_restoreButton; - Utils::DetailsWidget *m_details; }; } // namespace Debugger