forked from qt-creator/qt-creator
Debugger: Use LayoutBuilder for AnalyzerRunConfigWidget
Less noise. Change-Id: Ieeb853d8bb3661582e7cda275f7c420b8246a046 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -27,76 +27,62 @@
|
||||
#include "analyzerrunconfigwidget.h"
|
||||
|
||||
#include <utils/detailswidget.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QComboBox>
|
||||
#include <QLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
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<int>::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
|
||||
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<int>::of(&QComboBox::activated),
|
||||
this, chooseSettings);
|
||||
|
||||
connect(restoreButton, &QPushButton::clicked,
|
||||
aspect, &ProjectExplorer::GlobalOrProjectAspect::resetProjectToGlobalSettings);
|
||||
}
|
||||
|
||||
} // namespace Debugger
|
||||
|
@@ -30,31 +30,16 @@
|
||||
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils { class DetailsWidget; }
|
||||
#include <QCoreApplication>
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user