Layouting: Handle attach types via setter

Change-Id: I862f5cd109db3582b4f029787ec0cded2da39ce6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2023-05-02 12:51:03 +02:00
parent 70b02d23e1
commit 50084f6b0e
65 changed files with 265 additions and 160 deletions

View File

@@ -68,8 +68,9 @@ public:
Tr::tr("Description:"), description, br, Tr::tr("Description:"), description, br,
Tr::tr("Copyright:"), copyright, br, Tr::tr("Copyright:"), copyright, br,
Tr::tr("License:"), license, br, Tr::tr("License:"), license, br,
Tr::tr("Dependencies:"), dependencies Tr::tr("Dependencies:"), dependencies,
}.attachTo(q, WithoutMargins); noMargin
}.attachTo(q);
// clang-format on // clang-format on
} }

View File

@@ -45,8 +45,9 @@ public:
Form { Form {
Tr::tr("State:"), state, br, Tr::tr("State:"), state, br,
Tr::tr("Error message:"), errorString Tr::tr("Error message:"), errorString,
}.attachTo(q, WithoutMargins); noMargin,
}.attachTo(q);
} }
PluginErrorView *q = nullptr; PluginErrorView *q = nullptr;

View File

@@ -79,17 +79,19 @@ struct LayoutBuilder::Slice
Slice() = default; Slice() = default;
Slice(QLayout *l) : layout(l) {} Slice(QLayout *l) : layout(l) {}
Slice(QWidget *w) : widget(w) {} Slice(QWidget *w) : widget(w) {}
Slice(QWidget *w, AttachType a) : widget(w), attachType(a) {}
QLayout *layout = nullptr; QLayout *layout = nullptr;
QWidget *widget = nullptr; QWidget *widget = nullptr;
void flush(); void flush();
// Grid-specific
int currentGridColumn = 0; int currentGridColumn = 0;
int currentGridRow = 0; int currentGridRow = 0;
bool isFormAlignment = false;
Qt::Alignment align = {}; // Can be changed to
AttachType attachType = WithMargins; // Grid or Form
QList<ResultItem> pendingItems; QList<ResultItem> pendingItems;
}; };
@@ -192,9 +194,6 @@ void LayoutBuilder::Slice::flush()
} else if (auto gridLayout = qobject_cast<QGridLayout *>(layout)) { } else if (auto gridLayout = qobject_cast<QGridLayout *>(layout)) {
for (const ResultItem &item : std::as_const(pendingItems)) { for (const ResultItem &item : std::as_const(pendingItems)) {
Qt::Alignment align = {};
// if (attachType == Layouting::WithFormAlignment && currentGridColumn == 0)
// align = Qt::Alignment(m_widget->style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
if (item.widget) if (item.widget)
gridLayout->addWidget(item.widget, currentGridRow, currentGridColumn, 1, item.span, align); gridLayout->addWidget(item.widget, currentGridRow, currentGridColumn, 1, item.span, align);
else if (item.layout) else if (item.layout)
@@ -374,18 +373,18 @@ void LayoutItem::addItems(const LayoutItems &items)
This operation can only be performed once per LayoutBuilder instance. This operation can only be performed once per LayoutBuilder instance.
*/ */
void LayoutItem::attachTo(QWidget *w, AttachType attachType) const void LayoutItem::attachTo(QWidget *w) const
{ {
LayoutBuilder builder; LayoutBuilder builder;
builder.stack.append({w, attachType}); builder.stack.append(w);
addItemHelper(builder, *this); addItemHelper(builder, *this);
} }
QWidget *LayoutItem::emerge(Layouting::AttachType attachType) QWidget *LayoutItem::emerge()
{ {
auto w = new QWidget; auto w = new QWidget;
attachTo(w, attachType); attachTo(w);
return w; return w;
} }
@@ -398,8 +397,6 @@ static void layoutExit(LayoutBuilder &builder)
{ {
builder.stack.last().flush(); builder.stack.last().flush();
QLayout *layout = builder.stack.last().layout; QLayout *layout = builder.stack.last().layout;
if (builder.stack.back().attachType == WithoutMargins)
layout->setContentsMargins(0, 0, 0, 0);
builder.stack.pop_back(); builder.stack.pop_back();
if (QWidget *widget = builder.stack.last().widget) if (QWidget *widget = builder.stack.last().widget)
@@ -411,8 +408,6 @@ static void layoutExit(LayoutBuilder &builder)
static void widgetExit(LayoutBuilder &builder) static void widgetExit(LayoutBuilder &builder)
{ {
QWidget *widget = builder.stack.last().widget; QWidget *widget = builder.stack.last().widget;
if (builder.stack.back().attachType == WithoutMargins)
widget->setContentsMargins(0, 0, 0, 0);
builder.stack.pop_back(); builder.stack.pop_back();
builder.stack.last().pendingItems.append(ResultItem(widget)); builder.stack.last().pendingItems.append(ResultItem(widget));
} }
@@ -473,6 +468,58 @@ LayoutItem empty()
return {}; return {};
} }
LayoutItem hr()
{
LayoutItem item;
item.onAdd = [](LayoutBuilder &builder) { doAddWidget(builder, createHr()); };
return item;
}
LayoutItem st()
{
LayoutItem item;
item.onAdd = [](LayoutBuilder &builder) { doAddStretch(builder, Stretch(1)); };
return item;
}
LayoutItem noMargin()
{
LayoutItem item;
item.onAdd = [](LayoutBuilder &builder) {
if (auto layout = builder.stack.last().layout)
layout->setContentsMargins(0, 0, 0, 0);
else if (auto widget = builder.stack.last().widget)
widget->setContentsMargins(0, 0, 0, 0);
};
return item;
}
LayoutItem normalMargin()
{
LayoutItem item;
item.onAdd = [](LayoutBuilder &builder) {
if (auto layout = builder.stack.last().layout)
layout->setContentsMargins(9, 9, 9, 9);
else if (auto widget = builder.stack.last().widget)
widget->setContentsMargins(9, 9, 9, 9);
};
return item;
}
LayoutItem withFormAlignment()
{
LayoutItem item;
item.onAdd = [](LayoutBuilder &builder) {
if (builder.stack.size() >= 2) {
if (auto widget = builder.stack.at(builder.stack.size() - 2).widget) {
const Qt::Alignment align(widget->style()->styleHint(QStyle::SH_FormLayoutLabelAlignment));
builder.stack.last().align = align;
}
}
};
return item;
}
/*! /*!
Constructs a layout extender to extend an existing \a layout. Constructs a layout extender to extend an existing \a layout.
@@ -481,13 +528,12 @@ LayoutItem empty()
new items will be added below existing ones. new items will be added below existing ones.
*/ */
LayoutExtender::LayoutExtender(QLayout *layout, Layouting::AttachType attachType) LayoutExtender::LayoutExtender(QLayout *layout)
{ {
Slice slice; Slice slice;
slice.layout = layout; slice.layout = layout;
if (auto gridLayout = qobject_cast<QGridLayout *>(layout)) if (auto gridLayout = qobject_cast<QGridLayout *>(layout))
slice.currentGridRow = gridLayout->rowCount(); slice.currentGridRow = gridLayout->rowCount();
slice.attachType = attachType;
stack.append(slice); stack.append(slice);
} }
@@ -700,18 +746,4 @@ void createItem(LayoutItem *item, const Span &t)
}; };
} }
LayoutItem hr()
{
LayoutItem item;
item.onAdd = [](LayoutBuilder &builder) { doAddWidget(builder, createHr()); };
return item;
}
LayoutItem st()
{
LayoutItem item;
item.onAdd = [](LayoutBuilder &builder) { doAddStretch(builder, Stretch(1)); };
return item;
}
} // Layouting } // Layouting

View File

@@ -24,12 +24,6 @@ QT_END_NAMESPACE
namespace Layouting { namespace Layouting {
enum AttachType {
WithMargins,
WithoutMargins,
WithFormAlignment, // Handle Grid similar to QFormLayout, i.e. use special alignment for the first column on Mac
};
class LayoutBuilder; class LayoutBuilder;
class LayoutItem; class LayoutItem;
class Span; class Span;
@@ -88,8 +82,8 @@ public:
createItem(this, t); createItem(this, t);
} }
void attachTo(QWidget *w, AttachType attachType = WithMargins) const; void attachTo(QWidget *w) const;
QWidget *emerge(AttachType attachType = WithMargins); QWidget *emerge();
void addItem(const LayoutItem &item); void addItem(const LayoutItem &item);
void addItems(const LayoutItems &items); void addItems(const LayoutItems &items);
@@ -193,6 +187,9 @@ QTCREATOR_UTILS_EXPORT LayoutItem br();
QTCREATOR_UTILS_EXPORT LayoutItem st(); QTCREATOR_UTILS_EXPORT LayoutItem st();
QTCREATOR_UTILS_EXPORT LayoutItem empty(); QTCREATOR_UTILS_EXPORT LayoutItem empty();
QTCREATOR_UTILS_EXPORT LayoutItem hr(); QTCREATOR_UTILS_EXPORT LayoutItem hr();
QTCREATOR_UTILS_EXPORT LayoutItem noMargin();
QTCREATOR_UTILS_EXPORT LayoutItem normalMargin();
QTCREATOR_UTILS_EXPORT LayoutItem withFormAlignment();
// "Properties" // "Properties"
@@ -238,7 +235,7 @@ public:
class QTCREATOR_UTILS_EXPORT LayoutExtender : public LayoutBuilder class QTCREATOR_UTILS_EXPORT LayoutExtender : public LayoutBuilder
{ {
public: public:
explicit LayoutExtender(QLayout *layout, AttachType attachType); explicit LayoutExtender(QLayout *layout);
~LayoutExtender(); ~LayoutExtender();
}; };

View File

@@ -137,8 +137,9 @@ AndroidBuildApkWidget::AndroidBuildApkWidget(AndroidBuildApkStep *step)
createSignPackageGroup(), createSignPackageGroup(),
createApplicationGroup(), createApplicationGroup(),
createAdvancedGroup(), createAdvancedGroup(),
createAdditionalLibrariesGroup() createAdditionalLibrariesGroup(),
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
connect(m_step->buildConfiguration(), &BuildConfiguration::buildTypeChanged, connect(m_step->buildConfiguration(), &BuildConfiguration::buildTypeChanged,
this, &AndroidBuildApkWidget::updateSigningWarning); this, &AndroidBuildApkWidget::updateSigningWarning);

View File

@@ -606,7 +606,8 @@ QWidget *AndroidDeployQtStep::createConfigWidget()
Layouting::Form builder; Layouting::Form builder;
builder.addRow({m_uninstallPreviousPackage}); builder.addRow({m_uninstallPreviousPackage});
builder.addRow({installCustomApkButton}); builder.addRow({installCustomApkButton});
builder.attachTo(widget, Layouting::WithoutMargins); builder.addItem(Layouting::noMargin);
builder.attachTo(widget);
return widget; return widget;
} }

View File

@@ -141,14 +141,16 @@ AndroidSdkManagerWidget::AndroidSdkManagerWidget(AndroidConfig &config,
} }
}, },
optionsButton optionsButton
} },
}.attachTo(m_packagesStack, WithoutMargins); noMargin
}.attachTo(m_packagesStack);
Column { Column {
m_outputEdit, m_outputEdit,
Row { m_sdkLicenseLabel, m_sdkLicenseButtonBox }, Row { m_sdkLicenseLabel, m_sdkLicenseButtonBox },
m_operationProgress, m_operationProgress,
}.attachTo(m_outputStack, WithoutMargins); noMargin
}.attachTo(m_outputStack);
Column { Column {
m_viewStack, m_viewStack,

View File

@@ -65,8 +65,9 @@ public:
Tr::tr("Email:"), emailLineEdit, br, Tr::tr("Email:"), emailLineEdit, br,
Tr::tr("Fixed bugs:"), fixedBugsLineEdit Tr::tr("Fixed bugs:"), fixedBugsLineEdit
} }
} },
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
} }
QLineEdit *branchLineEdit; QLineEdit *branchLineEdit;

View File

@@ -90,8 +90,9 @@ ArtisticStyleOptionsPageWidget::ArtisticStyleOptionsPageWidget(ArtisticStyleSett
m_useOtherFiles, m_useOtherFiles,
Row { m_useSpecificConfigFile, m_specificConfigFile }, Row { m_useSpecificConfigFile, m_specificConfigFile },
m_useHomeFile, m_useHomeFile,
Row { m_useCustomStyle, m_configurations } Row { m_useCustomStyle, m_configurations },
}.attachTo(options, WithoutMargins); noMargin,
}.attachTo(options);
Column { Column {
Group { Group {

View File

@@ -32,8 +32,9 @@ ConfigurationPanel::ConfigurationPanel(QWidget *parent)
m_configurations, m_configurations,
m_edit, m_edit,
m_remove, m_remove,
add add,
}.attachTo(this, WithoutMargins); noMargin,
}.attachTo(this);
connect(add, &QPushButton::clicked, this, &ConfigurationPanel::add); connect(add, &QPushButton::clicked, this, &ConfigurationPanel::add);
connect(m_edit, &QPushButton::clicked, this, &ConfigurationPanel::edit); connect(m_edit, &QPushButton::clicked, this, &ConfigurationPanel::edit);

View File

@@ -60,8 +60,9 @@ ClangFormatGlobalConfigWidget::ClangFormatGlobalConfigWidget(
}; };
Column { Column {
globalSettingsGroupBox globalSettingsGroupBox,
}.attachTo(this, Layouting::WithoutMargins); noMargin
}.attachTo(this);
initCheckBoxes(); initCheckBoxes();
initIndentationOrFormattingCombobox(); initIndentationOrFormattingCombobox();

View File

@@ -84,8 +84,9 @@ ClangToolsProjectSettingsWidget::ClangToolsProjectSettingsWidget(ProjectExplorer
st st
} }
} }
} },
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
setUseGlobalSettings(m_projectSettings->useGlobalSettings()); setUseGlobalSettings(m_projectSettings->useGlobalSettings());
onGlobalCustomChanged(useGlobalSettings()); onGlobalCustomChanged(useGlobalSettings());

View File

@@ -90,13 +90,15 @@ public:
using namespace Layouting; using namespace Layouting;
Column { Column {
checksPrefixesTree checksPrefixesTree,
}.attachTo(checksPage, WithoutMargins); noMargin
}.attachTo(checksPage);
Column { Column {
invalidExecutableLabel, invalidExecutableLabel,
st, st,
}.attachTo(invalidExecutablePage, WithoutMargins); noMargin
}.attachTo(invalidExecutablePage);
Column { Column {
Row { plainTextEditButton, filterLineEdit }, Row { plainTextEditButton, filterLineEdit },
@@ -169,13 +171,15 @@ public:
Column { Column {
label, label,
Row { groupBox, checksGroupBox } Row { groupBox, checksGroupBox },
}.attachTo(checksPage, WithoutMargins); noMargin
}.attachTo(checksPage);
Column { Column {
invalidExecutableLabel, invalidExecutableLabel,
st st,
}.attachTo(invalidExecutablePage, WithoutMargins); noMargin
}.attachTo(invalidExecutablePage);
Column { Column {
enableLowerLevelsCheckBox, enableLowerLevelsCheckBox,

View File

@@ -50,8 +50,9 @@ RunSettingsWidget::RunSettingsWidget(QWidget *parent)
m_analyzeOpenFiles, m_analyzeOpenFiles,
Row { Tr::tr("Parallel jobs:"), m_parallelJobsSpinBox, st }, Row { Tr::tr("Parallel jobs:"), m_parallelJobsSpinBox, st },
} }
} },
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
} }
RunSettingsWidget::~RunSettingsWidget() = default; RunSettingsWidget::~RunSettingsWidget() = default;

View File

@@ -109,8 +109,8 @@ SettingsPageWidget::SettingsPageWidget()
using namespace Layouting; using namespace Layouting;
Form { Form {
Tr::tr("Arg&uments:"), diffArgsEdit Tr::tr("Arg&uments:"), diffArgsEdit, noMargin
}.attachTo(diffWidget, WithoutMargins); }.attachTo(diffWidget);
Column { Column {
Group { Group {

View File

@@ -354,12 +354,14 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
} }
}, },
configureEnvironmentAspectWidget configureEnvironmentAspectWidget
} },
}.attachTo(details, WithoutMargins); noMargin
}.attachTo(details);
Column { Column {
m_configureDetailsWidget, m_configureDetailsWidget,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
updateAdvancedCheckBox(); updateAdvancedCheckBox();
setError(m_buildSystem->error()); setError(m_buildSystem->error());

View File

@@ -577,7 +577,8 @@ QWidget *CMakeBuildStep::createConfigWidget()
if (!isCleanStep() && !m_buildPreset.isEmpty()) if (!isCleanStep() && !m_buildPreset.isEmpty())
createAndAddEnvironmentWidgets(builder); createAndAddEnvironmentWidgets(builder);
auto widget = builder.emerge(Layouting::WithoutMargins); builder.addItem(Layouting::noMargin);
auto widget = builder.emerge();
updateDetails(); updateDetails();

View File

@@ -108,8 +108,9 @@ QWidget *CMakeInstallStep::createConfigWidget()
Layouting::Form builder; Layouting::Form builder;
builder.addRow({m_cmakeArguments}); builder.addRow({m_cmakeArguments});
builder.addItem(Layouting::noMargin);
auto widget = builder.emerge(Layouting::WithoutMargins); auto widget = builder.emerge();
updateDetails(); updateDetails();

View File

@@ -33,7 +33,7 @@ AddToVcsDialog::AddToVcsDialog(QWidget *parent,
filesListWidget->setSelectionMode(QAbstractItemView::NoSelection); filesListWidget->setSelectionMode(QAbstractItemView::NoSelection);
filesListWidget->setSelectionBehavior(QAbstractItemView::SelectRows); filesListWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
QWidget *scrollAreaWidgetContents = Column{filesListWidget}.emerge(WithoutMargins); QWidget *scrollAreaWidgetContents = Column{filesListWidget, noMargin}.emerge();
scrollAreaWidgetContents->setGeometry({0, 0, 341, 300}); scrollAreaWidgetContents->setGeometry({0, 0, 341, 300});
auto scrollArea = new QScrollArea; auto scrollArea = new QScrollArea;

View File

@@ -564,11 +564,11 @@ ExternalToolConfig::ExternalToolConfig()
Tr::tr("Environment:"), m_environmentLabel, environmentButton, br, Tr::tr("Environment:"), m_environmentLabel, environmentButton, br,
empty, m_modifiesDocumentCheckbox, br, empty, m_modifiesDocumentCheckbox, br,
inputLabel, m_inputText inputLabel, m_inputText
}.attachTo(m_infoWidget, WithMargins); }.attachTo(m_infoWidget);
Column { Column {
m_infoWidget m_infoWidget, noMargin
}.attachTo(scrollAreaWidgetContents, WithoutMargins); }.attachTo(scrollAreaWidgetContents);
Row { Row {
Column { Column {

View File

@@ -422,8 +422,12 @@ void ReadOnlyFilesDialogPrivate::initDialog(const FilePaths &filePaths)
using namespace Layouting; using namespace Layouting;
QWidget *setAllWidget = Row{Tr::tr("Select all, if possible: "), m_setAll, st}.emerge( QWidget *setAllWidget = Row {
WithoutMargins); Tr::tr("Select all, if possible: "),
m_setAll,
st,
noMargin
}.emerge();
// clang-format off // clang-format off
Column { Column {

View File

@@ -109,7 +109,8 @@ FindToolWindow::FindToolWindow(QWidget *parent)
m_wholeWords, m_wholeWords,
m_regExp, m_regExp,
st, st,
}.attachTo(m_optionsWidget, WithoutMargins); noMargin
}.attachTo(m_optionsWidget);
Grid { Grid {
label, m_filterList, br, label, m_filterList, br,

View File

@@ -796,8 +796,13 @@ ListModel *SectionedGridView::addSection(const Section &section, const QList<Lis
} }
connect(seeAllLink, &QLabel::linkActivated, this, [this, section] { zoomInSection(section); }); connect(seeAllLink, &QLabel::linkActivated, this, [this, section] { zoomInSection(section); });
using namespace Layouting; using namespace Layouting;
QWidget *sectionLabel = Row{section.name, createSeparator(this), seeAllLink, Space(HSpacing)} QWidget *sectionLabel = Row {
.emerge(Layouting::WithoutMargins); section.name,
createSeparator(this),
seeAllLink,
Space(HSpacing),
noMargin
}.emerge();
m_sectionLabels.append(sectionLabel); m_sectionLabels.append(sectionLabel);
sectionLabel->setContentsMargins(0, ItemGap, 0, 0); sectionLabel->setContentsMargins(0, ItemGap, 0, 0);
sectionLabel->setFont(Core::WelcomePageHelpers::brandFont()); sectionLabel->setFont(Core::WelcomePageHelpers::brandFont());
@@ -849,8 +854,13 @@ void SectionedGridView::zoomInSection(const Section &section)
setCurrentIndex(0); setCurrentIndex(0);
}); });
using namespace Layouting; using namespace Layouting;
QWidget *sectionLabel = Row{section.name, createSeparator(this), backLink, Space(HSpacing)} QWidget *sectionLabel = Row {
.emerge(Layouting::WithoutMargins); section.name,
createSeparator(this),
backLink,
Space(HSpacing),
noMargin
}.emerge();
sectionLabel->setContentsMargins(0, ItemGap, 0, 0); sectionLabel->setContentsMargins(0, ItemGap, 0, 0);
sectionLabel->setFont(Core::WelcomePageHelpers::brandFont()); sectionLabel->setFont(Core::WelcomePageHelpers::brandFont());

View File

@@ -1485,7 +1485,8 @@ CppCodeModelInspectorDialog::CppCodeModelInspectorDialog(QWidget *parent)
Column { Column {
Form { QString("Sn&apshot:"), m_snapshotSelector }, Form { QString("Sn&apshot:"), m_snapshotSelector },
m_snapshotView, m_snapshotView,
}.emerge(Layouting::WithoutMargins), noMargin,
}.emerge(),
docTab, docTab,
}, },
} }

View File

@@ -54,7 +54,7 @@ LineCountSpinBox::LineCountSpinBox(QWidget *parent)
m_unitLabel = new QLabel(Tr::tr("lines")); m_unitLabel = new QLabel(Tr::tr("lines"));
using namespace Layouting; using namespace Layouting;
Row { m_checkBox, m_opLabel, m_spinBox, m_unitLabel, }.attachTo(this, WithoutMargins); Row { m_checkBox, m_opLabel, m_spinBox, m_unitLabel, noMargin }.attachTo(this);
auto handleChange = [this] { auto handleChange = [this] {
updateFields(); updateFields();
@@ -220,7 +220,8 @@ e.g. name = "m_test_foo_":
Tr::tr("Inside class:"), Tr::tr("Default"), Tr::tr("Default"), br, Tr::tr("Inside class:"), Tr::tr("Default"), Tr::tr("Default"), br,
Tr::tr("Outside class:"), m_lines_setterOutsideClass, m_lines_getterOutsideClass, br, Tr::tr("Outside class:"), m_lines_setterOutsideClass, m_lines_getterOutsideClass, br,
Tr::tr("In .cpp file:"), m_lines_setterInCppFile, m_lines_getterInCppFile, br, Tr::tr("In .cpp file:"), m_lines_setterInCppFile, m_lines_getterInCppFile, br,
}.attachTo(functionLocationsGrid, WithoutMargins); noMargin,
}.attachTo(functionLocationsGrid);
if (QGridLayout *gl = qobject_cast<QGridLayout*>(functionLocationsGrid->layout())) if (QGridLayout *gl = qobject_cast<QGridLayout*>(functionLocationsGrid->layout()))
gl->setHorizontalSpacing(48); gl->setHorizontalSpacing(48);

View File

@@ -67,7 +67,8 @@ DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(Target *target)
details->setState(DetailsWidget::Expanded); details->setState(DetailsWidget::Expanded);
auto innerPane = new QWidget; auto innerPane = new QWidget;
details->setWidget(innerPane); details->setWidget(innerPane);
builder.attachTo(innerPane, Layouting::WithoutMargins); builder.addItem(Layouting::noMargin);
builder.attachTo(innerPane);
const auto setSummaryText = [this, details] { const auto setSummaryText = [this, details] {
QStringList items; QStringList items;

View File

@@ -73,7 +73,8 @@ NewClassWidget::NewClassWidget(QWidget *parent) :
Tr::tr("&Source file:"), d->m_sourceFileLineEdit, br, Tr::tr("&Source file:"), d->m_sourceFileLineEdit, br,
Tr::tr("&Form file:"), d->m_formFileLineEdit, br, Tr::tr("&Form file:"), d->m_formFileLineEdit, br,
Tr::tr("&Path:"), d->m_pathChooser, br, Tr::tr("&Path:"), d->m_pathChooser, br,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
connect(d->m_classLineEdit, &ClassNameValidatingLineEdit::updateFileName, connect(d->m_classLineEdit, &ClassNameValidatingLineEdit::updateFileName,
this, &NewClassWidget::slotUpdateFileNames); this, &NewClassWidget::slotUpdateFileNames);

View File

@@ -247,7 +247,8 @@ DockerDeviceWidget::DockerDeviceWidget(const IDevice::Ptr &device)
m_pathsListEdit, m_pathsListEdit,
}, br, }, br,
(dockerDevice->isAutoDetected() ? Column {} : std::move(detectionControls)), (dockerDevice->isAutoDetected() ? Column {} : std::move(detectionControls)),
}.attachTo(this, WithoutMargins); noMargin,
}.attachTo(this);
// clang-format on // clang-format on
searchDirsLineEdit->setVisible(false); searchDirsLineEdit->setVisible(false);

View File

@@ -120,8 +120,9 @@ FossilCommitWidget::FossilCommitWidget() : m_commitPanel(new QWidget)
Tr::tr("Tags:"), m_tagsLineEdit, br, Tr::tr("Tags:"), m_tagsLineEdit, br,
Tr::tr("Author:"), m_authorLineEdit, st, Tr::tr("Author:"), m_authorLineEdit, st,
} }
} },
}.attachTo(m_commitPanel, WithoutMargins); noMargin
}.attachTo(m_commitPanel);
insertTopWidget(m_commitPanel); insertTopWidget(m_commitPanel);
new FossilSubmitHighlighter(descriptionEdit()); new FossilSubmitHighlighter(descriptionEdit());

View File

@@ -81,7 +81,8 @@ public:
} }
}, },
editGroup, editGroup,
}.attachTo(this, WithoutMargins); noMargin,
}.attachTo(this);
} }
QLabel *repositoryLabel; QLabel *repositoryLabel;

View File

@@ -101,9 +101,10 @@ GitLabServerWidget::GitLabServerWidget(Mode m, QWidget *parent)
m_description, m_description,
m_token, m_token,
m_port, m_port,
m_secure m_secure,
m == Edit ? normalMargin : noMargin
}, },
}.attachTo(this, m == Edit ? WithMargins : WithoutMargins); }.attachTo(this);
} }
GitLabServer GitLabServerWidget::gitLabServer() const GitLabServer GitLabServerWidget::gitLabServer() const

View File

@@ -119,8 +119,9 @@ public:
Tr::tr("Email:"), m_emailLineEdit, Tr::tr("Email:"), m_emailLineEdit,
}, },
} }
} },
}.attachTo(this, Layouting::WithoutMargins); noMargin
}.attachTo(this);
} }
QLabel *m_repositoryLabel; QLabel *m_repositoryLabel;

View File

@@ -30,8 +30,8 @@ RevertDialog::RevertDialog(QWidget *parent)
using namespace Layouting; using namespace Layouting;
Form { Form {
Tr::tr("Revision:"), m_revisionLineEdit, Tr::tr("Revision:"), m_revisionLineEdit, normalMargin
}.attachTo(groupBox, WithMargins); }.attachTo(groupBox);
Column { Column {
groupBox, groupBox,

View File

@@ -67,16 +67,18 @@ MesonBuildSettingsWidget::MesonBuildSettingsWidget(MesonBuildConfiguration *buil
buildDirWidget, buildDirWidget,
optionsFilterLineEdit, optionsFilterLineEdit,
optionsTreeView, optionsTreeView,
}.attachTo(details, WithoutMargins); noMargin
}.attachTo(details);
Column { Column {
container, container,
Row { configureButton, wipeButton, } Row { configureButton, wipeButton, noMargin }
}.attachTo(this, WithoutMargins); }.attachTo(this);
Form { Form {
buildCfg->buildDirectoryAspect(), buildCfg->buildDirectoryAspect(),
}.attachTo(buildDirWidget, WithoutMargins); noMargin
}.attachTo(buildDirWidget);
parametersLineEdit->setText(buildCfg->parameters()); parametersLineEdit->setText(buildCfg->parameters());
optionsFilterLineEdit->setFiltering(true); optionsFilterLineEdit->setFiltering(true);

View File

@@ -29,7 +29,8 @@ ToolItemSettings::ToolItemSettings(QWidget *parent)
Form { Form {
Tr::tr("Name:"), m_mesonNameLineEdit, br, Tr::tr("Name:"), m_mesonNameLineEdit, br,
Tr::tr("Path:"), m_mesonPathChooser, br, Tr::tr("Path:"), m_mesonPathChooser, br,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
connect(m_mesonPathChooser, &PathChooser::rawPathChanged, this, &ToolItemSettings::store); connect(m_mesonPathChooser, &PathChooser::rawPathChanged, this, &ToolItemSettings::store);
connect(m_mesonNameLineEdit, &QLineEdit::textChanged, this, &ToolItemSettings::store); connect(m_mesonNameLineEdit, &QLineEdit::textChanged, this, &ToolItemSettings::store);

View File

@@ -88,8 +88,9 @@ QWidget *NimbleTaskStep::createConfigWidget()
using namespace Layouting; using namespace Layouting;
auto widget = Form { auto widget = Form {
m_taskArgs, m_taskArgs,
Tr::tr("Tasks:"), taskList Tr::tr("Tasks:"), taskList,
}.emerge(WithoutMargins); noMargin
}.emerge();
auto buildSystem = dynamic_cast<NimbleBuildSystem *>(this->buildSystem()); auto buildSystem = dynamic_cast<NimbleBuildSystem *>(this->buildSystem());
QTC_ASSERT(buildSystem, return widget); QTC_ASSERT(buildSystem, return widget);

View File

@@ -44,7 +44,8 @@ NimCodeStylePreferencesWidget::NimCodeStylePreferencesWidget(ICodeStylePreferenc
st, st,
}, },
m_previewTextEdit, m_previewTextEdit,
}.attachTo(this, WithoutMargins); noMargin,
}.attachTo(this);
decorateEditor(TextEditorSettings::fontSettings()); decorateEditor(TextEditorSettings::fontSettings());
connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged, connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged,

View File

@@ -327,7 +327,8 @@ NamedWidget *BuildConfiguration::createConfigWidget()
if (aspect->isVisible()) if (aspect->isVisible())
form.addItem(aspect); form.addItem(aspect);
} }
form.attachTo(widget, Layouting::WithoutMargins); form.addItem(Layouting::noMargin);
form.attachTo(widget);
return named; return named;
} }

View File

@@ -165,7 +165,8 @@ QWidget *BuildStep::createConfigWidget()
if (aspect->isVisible()) if (aspect->isVisible())
form.addItem(aspect); form.addItem(aspect);
} }
auto widget = form.emerge(Layouting::WithoutMargins); form.addItem(Layouting::noMargin);
auto widget = form.emerge();
if (m_addMacroExpander) if (m_addMacroExpander)
VariableChooser::addSupportForChildWidgets(widget, macroExpander()); VariableChooser::addSupportForChildWidgets(widget, macroExpander());

View File

@@ -52,8 +52,9 @@ CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project)
Column { Column {
Row { new QLabel(Tr::tr("Language:")), languageComboBox, st }, Row { new QLabel(Tr::tr("Language:")), languageComboBox, st },
stackedWidget stackedWidget,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
} }
} // ProjectExplorer::Internal } // ProjectExplorer::Internal

View File

@@ -63,7 +63,8 @@ EditorSettingsWidget::EditorSettingsWidget(Project *project) : m_project(project
m_displaySettings, m_displaySettings,
m_behaviorSettings, m_behaviorSettings,
st, st,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
const EditorConfiguration *config = m_project->editorConfiguration(); const EditorConfiguration *config = m_project->editorConfiguration();
settingsToUi(config); settingsToUi(config);

View File

@@ -756,7 +756,7 @@ void KitAspectWidget::addToLayoutWithLabel(QWidget *parent)
emit labelLinkActivated(link); emit labelLinkActivated(link);
}); });
Layouting::LayoutExtender builder(parent->layout(), Layouting::WithFormAlignment); Layouting::LayoutExtender builder(parent->layout());
builder.addItems({label, Layouting::br}); builder.addItems({label, Layouting::br});
addToLayout(builder); addToLayout(builder);
} }

View File

@@ -67,9 +67,11 @@ KitManagerConfigWidget::KitManagerConfigWidget(Kit *k, bool &isDefaultKit, bool
using namespace Layouting; using namespace Layouting;
Grid { Grid {
withFormAlignment,
label, m_nameEdit, m_iconButton, br, label, m_nameEdit, m_iconButton, br,
fsLabel, m_fileSystemFriendlyNameLineEdit fsLabel, m_fileSystemFriendlyNameLineEdit,
}.attachTo(this, WithFormAlignment); noMargin
}.attachTo(this);
m_iconButton->setToolTip(Tr::tr("Kit icon.")); m_iconButton->setToolTip(Tr::tr("Kit icon."));
auto setIconAction = new QAction(Tr::tr("Select Icon..."), this); auto setIconAction = new QAction(Tr::tr("Select Icon..."), this);

View File

@@ -324,8 +324,9 @@ QWidget *MakeStep::createConfigWidget()
if (m_disablingForSubDirsSupported) if (m_disablingForSubDirsSupported)
builder.addRow({m_disabledForSubdirsAspect}); builder.addRow({m_disabledForSubdirsAspect});
builder.addRow({m_buildTargetsAspect}); builder.addRow({m_buildTargetsAspect});
builder.addItem(Layouting::noMargin);
auto widget = builder.emerge(Layouting::WithoutMargins); auto widget = builder.emerge();
VariableChooser::addSupportForChildWidgets(widget, macroExpander()); VariableChooser::addSupportForChildWidgets(widget, macroExpander());

View File

@@ -221,8 +221,8 @@ QWidget *RunConfiguration::createConfigurationWidget()
if (aspect->isVisible()) if (aspect->isVisible())
form.addItem(aspect); form.addItem(aspect);
} }
form.addItem(Layouting::noMargin);
auto widget = form.emerge(Layouting::WithoutMargins); auto widget = form.emerge();
VariableChooser::addSupportForChildWidgets(widget, &m_expander); VariableChooser::addSupportForChildWidgets(widget, &m_expander);

View File

@@ -96,8 +96,9 @@ public:
Form { Form {
Tr::tr("Name:"), m_name, br, Tr::tr("Name:"), m_name, br,
Tr::tr("Executable"), m_executable Tr::tr("Executable"), m_executable,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
} }
void updateInterpreter(const Interpreter &interpreter) void updateInterpreter(const Interpreter &interpreter)

View File

@@ -118,8 +118,9 @@ PythonWizardPage::PythonWizardPage(const QList<QPair<QString, QVariant>> &pySide
m_interpreter, br, m_interpreter, br,
m_createVenv, br, m_createVenv, br,
m_venvPath, br, m_venvPath, br,
m_stateLabel, br m_stateLabel, br,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
} }
void PythonWizardPage::initializePage() void PythonWizardPage::initializePage()

View File

@@ -677,7 +677,8 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step)
QbsProjectManager::Tr::tr("Installation directory:"), installDirChooser, br, QbsProjectManager::Tr::tr("Installation directory:"), installDirChooser, br,
m_qbsStep->m_commandLine, br, m_qbsStep->m_commandLine, br,
}.attachTo(this, Layouting::WithoutMargins); noMargin,
}.attachTo(this);
propertyEdit->setToolTip(QbsProjectManager::Tr::tr("Properties to pass to the project.")); propertyEdit->setToolTip(QbsProjectManager::Tr::tr("Properties to pass to the project."));
defaultInstallDirCheckBox->setText(QbsProjectManager::Tr::tr("Use default location")); defaultInstallDirCheckBox->setText(QbsProjectManager::Tr::tr("Use default location"));

View File

@@ -485,7 +485,8 @@ QWidget *QMakeStep::createConfigWidget()
builder.addRow({m_userArgs}); builder.addRow({m_userArgs});
builder.addRow({m_effectiveCall}); builder.addRow({m_effectiveCall});
builder.addRow({abisLabel, abisListWidget}); builder.addRow({abisLabel, abisListWidget});
auto widget = builder.emerge(Layouting::WithoutMargins); builder.addItem(Layouting::noMargin);
auto widget = builder.emerge();
qmakeBuildConfigChanged(); qmakeBuildConfigChanged();

View File

@@ -54,7 +54,8 @@ QmlJSCodeStylePreferencesWidget::QmlJSCodeStylePreferencesWidget(
st, st,
}, },
m_previewTextEdit, m_previewTextEdit,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged, connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged,
this, &QmlJSCodeStylePreferencesWidget::decorateEditor); this, &QmlJSCodeStylePreferencesWidget::decorateEditor);

View File

@@ -26,8 +26,9 @@ QmlJSCodeStyleSettingsWidget::QmlJSCodeStyleSettingsWidget(QWidget *parent)
Form { Form {
Tr::tr("&Line length:"), m_lineLengthSpinBox, br, Tr::tr("&Line length:"), m_lineLengthSpinBox, br,
} }
} },
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
connect(m_lineLengthSpinBox, &QSpinBox::valueChanged, connect(m_lineLengthSpinBox, &QSpinBox::valueChanged,
this, &QmlJSCodeStyleSettingsWidget::slotSettingsChanged); this, &QmlJSCodeStyleSettingsWidget::slotSettingsChanged);

View File

@@ -268,8 +268,9 @@ QtOptionsPageWidget::QtOptionsPageWidget()
Form { Form {
Tr::tr("Name:"), m_nameEdit, br, Tr::tr("Name:"), m_nameEdit, br,
Tr::tr("qmake path:"), Row { m_qmakePath, m_editPathPushButton }, br, Tr::tr("qmake path:"), Row { m_qmakePath, m_editPathPushButton }, br,
Span(2, m_errorLabel) Span(2, m_errorLabel),
}.attachTo(versionInfoWidget, WithoutMargins); noMargin
}.attachTo(versionInfoWidget);
// clang-format on // clang-format on
m_formLayout = qobject_cast<QFormLayout*>(versionInfoWidget->layout()); m_formLayout = qobject_cast<QFormLayout*>(versionInfoWidget->layout());

View File

@@ -35,7 +35,7 @@ ColorPicker::ColorPicker(const QString &key, QWidget *parent)
m_lastUsedColorContainer->setContentsMargins(0, 0, 0, 0); m_lastUsedColorContainer->setContentsMargins(0, 0, 0, 0);
using namespace Layouting; using namespace Layouting;
Grid colorGrid; Grid colorGrid{noMargin};
for (int i = 0; i < colors.count(); ++i) { for (int i = 0; i < colors.count(); ++i) {
QWidget *button = createButton(colors[i]); QWidget *button = createButton(colors[i]);
colorGrid.addItem(button); colorGrid.addItem(button);
@@ -46,7 +46,7 @@ ColorPicker::ColorPicker(const QString &key, QWidget *parent)
QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding,
QSizePolicy::Preferred)); QSizePolicy::Preferred));
} }
colorGrid.attachTo(basicColorContentFrame, WithoutMargins); colorGrid.attachTo(basicColorContentFrame);
Column { Column {
Tr::tr("Basic Colors"), Tr::tr("Basic Colors"),
basicColorContentFrame, basicColorContentFrame,

View File

@@ -44,7 +44,8 @@ ColorSettings::ColorSettings(QWidget *parent)
removeTheme, removeTheme,
}, },
m_colorThemeView, m_colorThemeView,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
connect(m_comboColorThemes, &QComboBox::currentIndexChanged, connect(m_comboColorThemes, &QComboBox::currentIndexChanged,
this, &ColorSettings::selectTheme); this, &ColorSettings::selectTheme);

View File

@@ -36,7 +36,8 @@ NavigatorSlider::NavigatorSlider(QWidget *parent)
m_slider, m_slider,
zoomIn, zoomIn,
Space(20), Space(20),
}.attachTo(this, WithoutMargins); noMargin,
}.attachTo(this);
connect(zoomOut, &QToolButton::clicked, this, &NavigatorSlider::zoomOut); connect(zoomOut, &QToolButton::clicked, this, &NavigatorSlider::zoomOut);
connect(zoomIn, &QToolButton::clicked, this, &NavigatorSlider::zoomIn); connect(zoomIn, &QToolButton::clicked, this, &NavigatorSlider::zoomIn);

View File

@@ -50,7 +50,8 @@ Search::Search(QWidget *parent)
spacing(0), spacing(0),
m_searchEdit, m_searchEdit,
m_searchView, m_searchView,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
connect(m_searchEdit, &Utils::FancyLineEdit::textChanged, this, &Search::setSearchText); connect(m_searchEdit, &Utils::FancyLineEdit::textChanged, this, &Search::setSearchText);
connect(m_searchView, &TableView::pressed, this, &Search::rowActivated); connect(m_searchView, &TableView::pressed, this, &Search::rowActivated);

View File

@@ -33,7 +33,8 @@ ShapesToolbox::ShapesToolbox(QWidget *parent)
Column { Column {
spacing(0), spacing(0),
scrollArea, scrollArea,
}.attachTo(this, WithoutMargins); noMargin,
}.attachTo(this);
} }
void ShapesToolbox::setUIFactory(ScxmlEditor::PluginInterface::ScxmlUiFactory *factory) void ShapesToolbox::setUIFactory(ScxmlEditor::PluginInterface::ScxmlUiFactory *factory)

View File

@@ -35,13 +35,15 @@ StateView::StateView(StateItem *state, QWidget *parent)
Row { Row {
PushButton{ text("Back"), onClicked([this] { closeView(); }, this) }, PushButton{ text("Back"), onClicked([this] { closeView(); }, this) },
stateNameLabel, stateNameLabel,
}.attachTo(titleBar, WithoutMargins); noMargin
}.attachTo(titleBar);
Column { Column {
spacing(0), spacing(0),
titleBar, titleBar,
m_graphicsView m_graphicsView,
}.attachTo(this, WithoutMargins); noMargin,
}.attachTo(this);
initScene(); initScene();
} }

View File

@@ -140,8 +140,9 @@ Statistics::Statistics(QWidget *parent)
Tr::tr("File"), m_fileNameLabel, br, Tr::tr("File"), m_fileNameLabel, br,
Tr::tr("Time"), m_timeLabel, br, Tr::tr("Time"), m_timeLabel, br,
Tr::tr("Max. levels"), m_levels, br, Tr::tr("Max. levels"), m_levels, br,
Span(2, m_statisticsView), br Span(2, m_statisticsView), br,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
} }
void Statistics::setDocument(ScxmlDocument *doc) void Statistics::setDocument(ScxmlDocument *doc)

View File

@@ -207,8 +207,9 @@ BehaviorSettingsWidget::BehaviorSettingsWidget(QWidget *parent)
Row { Row {
Column { d->tabPreferencesWidget, d->groupBoxTyping, st }, Column { d->tabPreferencesWidget, d->groupBoxTyping, st },
Column { d->groupBoxStorageSettings, d->groupBoxEncodings, d->groupBoxMouse, st } Column { d->groupBoxStorageSettings, d->groupBoxEncodings, d->groupBoxMouse, st },
}.attachTo(this, WithoutMargins); noMargin,
}.attachTo(this);
connect(d->cleanWhitespace, &QCheckBox::toggled, connect(d->cleanWhitespace, &QCheckBox::toggled,
d->inEntireDocument, &QCheckBox::setEnabled); d->inEntireDocument, &QCheckBox::setEnabled);

View File

@@ -29,6 +29,7 @@ CodeStyleEditor::CodeStyleEditor(ICodeStylePreferencesFactory *factory,
, m_codeStyle(codeStyle) , m_codeStyle(codeStyle)
{ {
m_layout = new QVBoxLayout(this); m_layout = new QVBoxLayout(this);
m_layout->setContentsMargins(0, 0, 0, 0);
auto selector = new CodeStyleSelectorWidget(factory, project, this); auto selector = new CodeStyleSelectorWidget(factory, project, this);
selector->setCodeStyle(codeStyle); selector->setCodeStyle(codeStyle);
m_additionalGlobalSettingsWidget = factory->createAdditionalGlobalSettings(codeStyle, m_additionalGlobalSettingsWidget = factory->createAdditionalGlobalSettings(codeStyle,

View File

@@ -59,8 +59,8 @@ CodeStyleSelectorWidget::CodeStyleSelectorWidget(ICodeStylePreferencesFactory *f
m_exportButton, m_exportButton,
m_importButton m_importButton
}, },
noMargin,
}.attachTo(this, WithoutMargins); }.attachTo(this);
connect(m_delegateComboBox, &QComboBox::activated, connect(m_delegateComboBox, &QComboBox::activated,
this, &CodeStyleSelectorWidget::slotComboBoxActivated); this, &CodeStyleSelectorWidget::slotComboBoxActivated);

View File

@@ -208,7 +208,8 @@ ColorSchemeEdit::ColorSchemeEdit(QWidget *parent) :
m_itemList, m_itemList,
m_builtinSchemeLabel, m_builtinSchemeLabel,
m_fontProperties, m_fontProperties,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
Grid { Grid {
m_foregroundLabel, m_foregroundToolButton, m_eraseForegroundToolButton, br, m_foregroundLabel, m_foregroundToolButton, m_eraseForegroundToolButton, br,

View File

@@ -208,8 +208,9 @@ SubmitEditorWidget::SubmitEditorWidget() :
using namespace Layouting; using namespace Layouting;
Column { Column {
scrollArea scrollArea,
}.attachTo(this, WithoutMargins); noMargin
}.attachTo(this);
connect(d->description, &QWidget::customContextMenuRequested, connect(d->description, &QWidget::customContextMenuRequested,
this, &SubmitEditorWidget::editorCustomContextMenuRequested); this, &SubmitEditorWidget::editorCustomContextMenuRequested);

View File

@@ -91,8 +91,9 @@ TaskWidget::TaskWidget()
m_infoLabel, m_infoLabel,
m_spinBox, m_spinBox,
m_checkBox, m_checkBox,
st st,
}.attachTo(this, WithoutMargins); noMargin,
}.attachTo(this);
} }
void TaskWidget::setBusyTime(int seconds) void TaskWidget::setBusyTime(int seconds)
@@ -145,9 +146,10 @@ GroupWidget::GroupWidget()
m_executeCombo, m_executeCombo,
new QLabel("Workflow:"), new QLabel("Workflow:"),
m_workflowCombo, m_workflowCombo,
st st,
noMargin
} }
}.attachTo(this, WithoutMargins); }.attachTo(this);
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
} }