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 <extensionsystem/pluginview.h>
|
||||||
|
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -35,30 +32,27 @@ PluginDialog::PluginDialog(QWidget *parent)
|
|||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
m_view(new ExtensionSystem::PluginView(this))
|
m_view(new ExtensionSystem::PluginView(this))
|
||||||
{
|
{
|
||||||
auto vl = new QVBoxLayout(this);
|
|
||||||
|
|
||||||
auto filterLayout = new QHBoxLayout;
|
|
||||||
vl->addLayout(filterLayout);
|
|
||||||
auto filterEdit = new Utils::FancyLineEdit(this);
|
auto filterEdit = new Utils::FancyLineEdit(this);
|
||||||
filterEdit->setFocus();
|
filterEdit->setFocus();
|
||||||
filterEdit->setFiltering(true);
|
filterEdit->setFiltering(true);
|
||||||
connect(filterEdit, &Utils::FancyLineEdit::filterChanged,
|
connect(filterEdit, &Utils::FancyLineEdit::filterChanged,
|
||||||
m_view, &ExtensionSystem::PluginView::setFilter);
|
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);
|
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
buttonBox->addButton(m_detailsButton, QDialogButtonBox::ActionRole);
|
m_detailsButton = buttonBox->addButton(Tr::tr("Details"), QDialogButtonBox::ActionRole);
|
||||||
buttonBox->addButton(m_errorDetailsButton, QDialogButtonBox::ActionRole);
|
m_detailsButton->setEnabled(false);
|
||||||
buttonBox->addButton(m_installButton, QDialogButtonBox::ActionRole);
|
m_errorDetailsButton = buttonBox->addButton(Tr::tr("Error Details"),
|
||||||
vl->addWidget(buttonBox);
|
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);
|
resize(650, 400);
|
||||||
setWindowTitle(Tr::tr("Installed Plugins"));
|
setWindowTitle(Tr::tr("Installed Plugins"));
|
||||||
@@ -116,13 +110,16 @@ void PluginDialog::openDetails(ExtensionSystem::PluginSpec *spec)
|
|||||||
return;
|
return;
|
||||||
QDialog dialog(this);
|
QDialog dialog(this);
|
||||||
dialog.setWindowTitle(Tr::tr("Plugin Details of %1").arg(spec->name()));
|
dialog.setWindowTitle(Tr::tr("Plugin Details of %1").arg(spec->name()));
|
||||||
auto layout = new QVBoxLayout;
|
|
||||||
dialog.setLayout(layout);
|
|
||||||
auto details = new ExtensionSystem::PluginDetailsView(&dialog);
|
auto details = new ExtensionSystem::PluginDetailsView(&dialog);
|
||||||
layout->addWidget(details);
|
|
||||||
details->update(spec);
|
details->update(spec);
|
||||||
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
|
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::accepted, &dialog, &QDialog::accept);
|
||||||
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
||||||
dialog.resize(400, 500);
|
dialog.resize(400, 500);
|
||||||
@@ -136,13 +133,16 @@ void PluginDialog::openErrorDetails()
|
|||||||
return;
|
return;
|
||||||
QDialog dialog(this);
|
QDialog dialog(this);
|
||||||
dialog.setWindowTitle(Tr::tr("Plugin Errors of %1").arg(spec->name()));
|
dialog.setWindowTitle(Tr::tr("Plugin Errors of %1").arg(spec->name()));
|
||||||
auto layout = new QVBoxLayout;
|
|
||||||
dialog.setLayout(layout);
|
|
||||||
auto errors = new ExtensionSystem::PluginErrorView(&dialog);
|
auto errors = new ExtensionSystem::PluginErrorView(&dialog);
|
||||||
layout->addWidget(errors);
|
|
||||||
errors->update(spec);
|
errors->update(spec);
|
||||||
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, &dialog);
|
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::accepted, &dialog, &QDialog::accept);
|
||||||
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
||||||
dialog.resize(500, 300);
|
dialog.resize(500, 300);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/infolabel.h>
|
#include <utils/infolabel.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/pathchooser.h>
|
#include <utils/pathchooser.h>
|
||||||
#include <utils/process.h>
|
#include <utils/process.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -33,7 +34,6 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -80,19 +80,15 @@ public:
|
|||||||
, m_data(data)
|
, m_data(data)
|
||||||
{
|
{
|
||||||
setTitle(Tr::tr("Source"));
|
setTitle(Tr::tr("Source"));
|
||||||
auto vlayout = new QVBoxLayout;
|
|
||||||
setLayout(vlayout);
|
|
||||||
|
|
||||||
auto label = new QLabel(
|
auto label = new QLabel(
|
||||||
"<p>"
|
"<p>"
|
||||||
+ Tr::tr("Choose source location. This can be a plugin library file or a zip file.")
|
+ Tr::tr("Choose source location. This can be a plugin library file or a zip file.")
|
||||||
+ "</p>");
|
+ "</p>");
|
||||||
label->setWordWrap(true);
|
label->setWordWrap(true);
|
||||||
vlayout->addWidget(label);
|
|
||||||
|
|
||||||
auto chooser = new PathChooser;
|
auto chooser = new PathChooser;
|
||||||
chooser->setExpectedKind(PathChooser::Any);
|
chooser->setExpectedKind(PathChooser::Any);
|
||||||
vlayout->addWidget(chooser);
|
|
||||||
connect(chooser, &PathChooser::textChanged, this, [this, chooser] {
|
connect(chooser, &PathChooser::textChanged, this, [this, chooser] {
|
||||||
m_data->sourcePath = chooser->filePath();
|
m_data->sourcePath = chooser->filePath();
|
||||||
updateWarnings();
|
updateWarnings();
|
||||||
@@ -101,7 +97,8 @@ public:
|
|||||||
m_info = new InfoLabel;
|
m_info = new InfoLabel;
|
||||||
m_info->setType(InfoLabel::Error);
|
m_info->setType(InfoLabel::Error);
|
||||||
m_info->setVisible(false);
|
m_info->setVisible(false);
|
||||||
vlayout->addWidget(m_info);
|
|
||||||
|
Layouting::Column { label, chooser, m_info }.attachTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateWarnings()
|
void updateWarnings()
|
||||||
@@ -153,8 +150,6 @@ public:
|
|||||||
, m_data(data)
|
, m_data(data)
|
||||||
{
|
{
|
||||||
setTitle(Tr::tr("Check Archive"));
|
setTitle(Tr::tr("Check Archive"));
|
||||||
auto vlayout = new QVBoxLayout;
|
|
||||||
setLayout(vlayout);
|
|
||||||
|
|
||||||
m_label = new InfoLabel;
|
m_label = new InfoLabel;
|
||||||
m_label->setElideMode(Qt::ElideNone);
|
m_label->setElideMode(Qt::ElideNone);
|
||||||
@@ -163,13 +158,11 @@ public:
|
|||||||
m_output = new QTextEdit;
|
m_output = new QTextEdit;
|
||||||
m_output->setReadOnly(true);
|
m_output->setReadOnly(true);
|
||||||
|
|
||||||
auto hlayout = new QHBoxLayout;
|
using namespace Layouting;
|
||||||
hlayout->addWidget(m_label, 1);
|
Column {
|
||||||
hlayout->addStretch();
|
Row { m_label, st, m_cancelButton },
|
||||||
hlayout->addWidget(m_cancelButton);
|
m_output,
|
||||||
|
}.attachTo(this);
|
||||||
vlayout->addLayout(hlayout);
|
|
||||||
vlayout->addWidget(m_output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializePage() final
|
void initializePage() final
|
||||||
@@ -322,13 +315,9 @@ public:
|
|||||||
, m_data(data)
|
, m_data(data)
|
||||||
{
|
{
|
||||||
setTitle(Tr::tr("Install Location"));
|
setTitle(Tr::tr("Install Location"));
|
||||||
auto vlayout = new QVBoxLayout;
|
|
||||||
setLayout(vlayout);
|
|
||||||
|
|
||||||
auto label = new QLabel("<p>" + Tr::tr("Choose install location.") + "</p>");
|
auto label = new QLabel("<p>" + Tr::tr("Choose install location.") + "</p>");
|
||||||
label->setWordWrap(true);
|
label->setWordWrap(true);
|
||||||
vlayout->addWidget(label);
|
|
||||||
vlayout->addSpacing(10);
|
|
||||||
|
|
||||||
auto localInstall = new QRadioButton(Tr::tr("User plugins"));
|
auto localInstall = new QRadioButton(Tr::tr("User plugins"));
|
||||||
localInstall->setChecked(!m_data->installIntoApplication);
|
localInstall->setChecked(!m_data->installIntoApplication);
|
||||||
@@ -338,10 +327,6 @@ public:
|
|||||||
localLabel->setWordWrap(true);
|
localLabel->setWordWrap(true);
|
||||||
localLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
localLabel->setAttribute(Qt::WA_MacSmallSize, true);
|
||||||
|
|
||||||
vlayout->addWidget(localInstall);
|
|
||||||
vlayout->addWidget(localLabel);
|
|
||||||
vlayout->addSpacing(10);
|
|
||||||
|
|
||||||
auto appInstall = new QRadioButton(
|
auto appInstall = new QRadioButton(
|
||||||
Tr::tr("%1 installation").arg(Constants::IDE_DISPLAY_NAME));
|
Tr::tr("%1 installation").arg(Constants::IDE_DISPLAY_NAME));
|
||||||
appInstall->setChecked(m_data->installIntoApplication);
|
appInstall->setChecked(m_data->installIntoApplication);
|
||||||
@@ -351,8 +336,11 @@ public:
|
|||||||
.arg(Constants::IDE_DISPLAY_NAME));
|
.arg(Constants::IDE_DISPLAY_NAME));
|
||||||
appLabel->setWordWrap(true);
|
appLabel->setWordWrap(true);
|
||||||
appLabel->setAttribute(Qt::WA_MacSmallSize, 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);
|
auto group = new QButtonGroup(this);
|
||||||
group->addButton(localInstall);
|
group->addButton(localInstall);
|
||||||
@@ -375,12 +363,9 @@ public:
|
|||||||
{
|
{
|
||||||
setTitle(Tr::tr("Summary"));
|
setTitle(Tr::tr("Summary"));
|
||||||
|
|
||||||
auto vlayout = new QVBoxLayout;
|
|
||||||
setLayout(vlayout);
|
|
||||||
|
|
||||||
m_summaryLabel = new QLabel(this);
|
m_summaryLabel = new QLabel(this);
|
||||||
m_summaryLabel->setWordWrap(true);
|
m_summaryLabel->setWordWrap(true);
|
||||||
vlayout->addWidget(m_summaryLabel);
|
Layouting::Column { m_summaryLabel }.attachTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializePage() final
|
void initializePage() final
|
||||||
|
|||||||
Reference in New Issue
Block a user