From e759ce310fe6f30724f29b809bf0bcab1df88e1d Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 31 May 2023 19:10:05 +0200 Subject: [PATCH] Core: Use LayoutBuilder in PluginDialog Change-Id: I06b07234727fc46a717af89febae43af1cb67b9b Reviewed-by: Eike Ziller Reviewed-by: Reviewed-by: Qt CI Patch Build Bot --- src/plugins/coreplugin/plugindialog.cpp | 58 +++++++++---------- .../coreplugin/plugininstallwizard.cpp | 43 +++++--------- 2 files changed, 43 insertions(+), 58 deletions(-) diff --git a/src/plugins/coreplugin/plugindialog.cpp b/src/plugins/coreplugin/plugindialog.cpp index f6ea25e719c..24d8c8dff12 100644 --- a/src/plugins/coreplugin/plugindialog.cpp +++ b/src/plugins/coreplugin/plugindialog.cpp @@ -17,14 +17,11 @@ #include #include +#include -#include #include #include -#include -#include #include -#include using namespace Utils; @@ -35,30 +32,27 @@ PluginDialog::PluginDialog(QWidget *parent) : QDialog(parent), m_view(new ExtensionSystem::PluginView(this)) { - auto vl = new QVBoxLayout(this); - - auto filterLayout = new QHBoxLayout; - vl->addLayout(filterLayout); auto filterEdit = new Utils::FancyLineEdit(this); filterEdit->setFocus(); filterEdit->setFiltering(true); connect(filterEdit, &Utils::FancyLineEdit::filterChanged, m_view, &ExtensionSystem::PluginView::setFilter); - filterLayout->addWidget(filterEdit); - - vl->addWidget(m_view); - - m_detailsButton = new QPushButton(Tr::tr("Details"), this); - m_errorDetailsButton = new QPushButton(Tr::tr("Error Details"), this); - m_installButton = new QPushButton(Tr::tr("Install Plugin..."), this); - m_detailsButton->setEnabled(false); - m_errorDetailsButton->setEnabled(false); auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - buttonBox->addButton(m_detailsButton, QDialogButtonBox::ActionRole); - buttonBox->addButton(m_errorDetailsButton, QDialogButtonBox::ActionRole); - buttonBox->addButton(m_installButton, QDialogButtonBox::ActionRole); - vl->addWidget(buttonBox); + m_detailsButton = buttonBox->addButton(Tr::tr("Details"), QDialogButtonBox::ActionRole); + m_detailsButton->setEnabled(false); + m_errorDetailsButton = buttonBox->addButton(Tr::tr("Error Details"), + QDialogButtonBox::ActionRole); + m_errorDetailsButton->setEnabled(false); + m_installButton = buttonBox->addButton(Tr::tr("Install Plugin..."), + QDialogButtonBox::ActionRole); + + using namespace Layouting; + Column { + filterEdit, + m_view, + buttonBox, + }.attachTo(this); resize(650, 400); setWindowTitle(Tr::tr("Installed Plugins")); @@ -116,13 +110,16 @@ void PluginDialog::openDetails(ExtensionSystem::PluginSpec *spec) return; QDialog dialog(this); dialog.setWindowTitle(Tr::tr("Plugin Details of %1").arg(spec->name())); - auto layout = new QVBoxLayout; - dialog.setLayout(layout); auto details = new ExtensionSystem::PluginDetailsView(&dialog); - layout->addWidget(details); details->update(spec); QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog); - layout->addWidget(buttons); + + using namespace Layouting; + Column { + details, + buttons, + }.attachTo(&dialog); + connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); dialog.resize(400, 500); @@ -136,13 +133,16 @@ void PluginDialog::openErrorDetails() return; QDialog dialog(this); dialog.setWindowTitle(Tr::tr("Plugin Errors of %1").arg(spec->name())); - auto layout = new QVBoxLayout; - dialog.setLayout(layout); auto errors = new ExtensionSystem::PluginErrorView(&dialog); - layout->addWidget(errors); errors->update(spec); QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog); - layout->addWidget(buttons); + + using namespace Layouting; + Column { + errors, + buttons, + }.attachTo(&dialog); + connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept); connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject); dialog.resize(500, 300); diff --git a/src/plugins/coreplugin/plugininstallwizard.cpp b/src/plugins/coreplugin/plugininstallwizard.cpp index c5694016d49..ac2dfd6c240 100644 --- a/src/plugins/coreplugin/plugininstallwizard.cpp +++ b/src/plugins/coreplugin/plugininstallwizard.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include @@ -80,19 +80,15 @@ public: , m_data(data) { setTitle(Tr::tr("Source")); - auto vlayout = new QVBoxLayout; - setLayout(vlayout); auto label = new QLabel( "

" + Tr::tr("Choose source location. This can be a plugin library file or a zip file.") + "

"); label->setWordWrap(true); - vlayout->addWidget(label); auto chooser = new PathChooser; chooser->setExpectedKind(PathChooser::Any); - vlayout->addWidget(chooser); connect(chooser, &PathChooser::textChanged, this, [this, chooser] { m_data->sourcePath = chooser->filePath(); updateWarnings(); @@ -101,7 +97,8 @@ public: m_info = new InfoLabel; m_info->setType(InfoLabel::Error); m_info->setVisible(false); - vlayout->addWidget(m_info); + + Layouting::Column { label, chooser, m_info }.attachTo(this); } void updateWarnings() @@ -153,8 +150,6 @@ public: , m_data(data) { setTitle(Tr::tr("Check Archive")); - auto vlayout = new QVBoxLayout; - setLayout(vlayout); m_label = new InfoLabel; m_label->setElideMode(Qt::ElideNone); @@ -163,13 +158,11 @@ public: m_output = new QTextEdit; m_output->setReadOnly(true); - auto hlayout = new QHBoxLayout; - hlayout->addWidget(m_label, 1); - hlayout->addStretch(); - hlayout->addWidget(m_cancelButton); - - vlayout->addLayout(hlayout); - vlayout->addWidget(m_output); + using namespace Layouting; + Column { + Row { m_label, st, m_cancelButton }, + m_output, + }.attachTo(this); } void initializePage() final @@ -322,13 +315,9 @@ public: , m_data(data) { setTitle(Tr::tr("Install Location")); - auto vlayout = new QVBoxLayout; - setLayout(vlayout); auto label = new QLabel("

" + Tr::tr("Choose install location.") + "

"); label->setWordWrap(true); - vlayout->addWidget(label); - vlayout->addSpacing(10); auto localInstall = new QRadioButton(Tr::tr("User plugins")); localInstall->setChecked(!m_data->installIntoApplication); @@ -338,10 +327,6 @@ public: localLabel->setWordWrap(true); localLabel->setAttribute(Qt::WA_MacSmallSize, true); - vlayout->addWidget(localInstall); - vlayout->addWidget(localLabel); - vlayout->addSpacing(10); - auto appInstall = new QRadioButton( Tr::tr("%1 installation").arg(Constants::IDE_DISPLAY_NAME)); appInstall->setChecked(m_data->installIntoApplication); @@ -351,8 +336,11 @@ public: .arg(Constants::IDE_DISPLAY_NAME)); appLabel->setWordWrap(true); appLabel->setAttribute(Qt::WA_MacSmallSize, true); - vlayout->addWidget(appInstall); - vlayout->addWidget(appLabel); + + using namespace Layouting; + Column { + label, Space(10), localInstall, localLabel, Space(10), appInstall, appLabel, + }.attachTo(this); auto group = new QButtonGroup(this); group->addButton(localInstall); @@ -375,12 +363,9 @@ public: { setTitle(Tr::tr("Summary")); - auto vlayout = new QVBoxLayout; - setLayout(vlayout); - m_summaryLabel = new QLabel(this); m_summaryLabel->setWordWrap(true); - vlayout->addWidget(m_summaryLabel); + Layouting::Column { m_summaryLabel }.attachTo(this); } void initializePage() final