ProjectExplorer: Prepare more flexibility to aspect layouting

This hides the explicit use of a QFormLayout from the aspect
interface in a new LayoutBuilder class. That currently works
only on a QFormLayout in the back, but opens the possibility
to use e.g. a QGridLayout as use on the Kits and some option
pages.

The aspects now only announce sub-widgets they like to add,
actuall positioning is does by a new LayoutBuilder class,
also cramming several widgets in an hbox in the right column
of the QFormLayout is done there.

Change-Id: I2b788192c465f2ab82261849d34e514697c5a491
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-10-15 17:20:51 +02:00
parent 02350520c2
commit 6eaf239777
20 changed files with 251 additions and 140 deletions

View File

@@ -62,7 +62,7 @@ class DebuggerLanguageAspect : public ProjectConfigurationAspect
public:
DebuggerLanguageAspect() = default;
void addToConfigurationLayout(QFormLayout *layout) override;
void addToLayout(LayoutBuilder &builder) override;
bool value() const;
void setValue(bool val);
@@ -91,35 +91,29 @@ public:
std::function<void(bool)> m_clickCallBack;
};
void DebuggerLanguageAspect::addToConfigurationLayout(QFormLayout *layout)
void DebuggerLanguageAspect::addToLayout(LayoutBuilder &builder)
{
QTC_CHECK(!m_checkBox);
m_checkBox = new QCheckBox(m_label, layout->parentWidget());
m_checkBox = new QCheckBox(m_label);
m_checkBox->setChecked(m_value);
QTC_CHECK(m_clickCallBack);
connect(m_checkBox, &QAbstractButton::clicked, this, m_clickCallBack, Qt::QueuedConnection);
auto innerLayout = new QHBoxLayout;
innerLayout->setContentsMargins(0, 0, 0, 0);
connect(m_checkBox.data(), &QAbstractButton::clicked, this, [this] {
m_value = m_checkBox->isChecked() ? EnabledLanguage : DisabledLanguage;
emit changed();
});
innerLayout->addWidget(m_checkBox);
builder.addItem(m_checkBox.data());
if (!m_infoLabelText.isEmpty()) {
QTC_CHECK(!m_infoLabel);
m_infoLabel = new QLabel(m_infoLabelText, layout->parentWidget());
m_infoLabel = new QLabel(m_infoLabelText);
connect(m_infoLabel, &QLabel::linkActivated, [](const QString &link) {
Core::HelpManager::showHelpUrl(link);
});
innerLayout->addWidget(m_infoLabel);
builder.addItem(m_infoLabel.data());
}
innerLayout->addStretch();
layout->addRow(innerLayout);
}
void DebuggerLanguageAspect::setAutoSettingsKey(const QString &settingsKey)
@@ -172,18 +166,19 @@ DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(Target *target)
setConfigWidgetCreator([this] {
QWidget *w = new QWidget;
auto layout = new QFormLayout;
layout->setContentsMargins(0, 0, 0, 0);
m_cppAspect->addToConfigurationLayout(layout);
m_qmlAspect->addToConfigurationLayout(layout);
m_overrideStartupAspect->addToConfigurationLayout(layout);
LayoutBuilder builder(w);
m_cppAspect->addToLayout(builder);
builder.startNewRow();
m_qmlAspect->addToLayout(builder);
builder.startNewRow();
m_overrideStartupAspect->addToLayout(builder);
static const QByteArray env = qgetenv("QTC_DEBUGGER_MULTIPROCESS");
if (env.toInt())
m_multiProcessAspect->addToConfigurationLayout(layout);
if (env.toInt()) {
builder.startNewRow();
m_multiProcessAspect->addToLayout(builder);
}
w->setLayout(layout);
return w;
});