forked from qt-creator/qt-creator
Core: Use LayoutBuilder in PluginDialog
Change-Id: I06b07234727fc46a717af89febae43af1cb67b9b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
@@ -17,14 +17,11 @@
|
||||
#include <extensionsystem/pluginview.h>
|
||||
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
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);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/infolabel.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/process.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -33,7 +34,6 @@
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -80,19 +80,15 @@ public:
|
||||
, m_data(data)
|
||||
{
|
||||
setTitle(Tr::tr("Source"));
|
||||
auto vlayout = new QVBoxLayout;
|
||||
setLayout(vlayout);
|
||||
|
||||
auto label = new QLabel(
|
||||
"<p>"
|
||||
+ Tr::tr("Choose source location. This can be a plugin library file or a zip file.")
|
||||
+ "</p>");
|
||||
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("<p>" + Tr::tr("Choose install location.") + "</p>");
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user