From 715e5800a5db78f198dd1a09c55e0fdcdafd4015 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 22 Jul 2022 18:02:04 +0200 Subject: Utils: inline projectintropage.ui Change-Id: I10f1b76b8bc88c56dfe6d215345d9b92a6832074 Reviewed-by: Alessandro Portale Reviewed-by: --- src/libs/utils/CMakeLists.txt | 2 +- src/libs/utils/projectintropage.cpp | 151 ++++++++++++++++++++++++------------ src/libs/utils/projectintropage.h | 7 +- src/libs/utils/projectintropage.ui | 140 --------------------------------- src/libs/utils/utils.qbs | 1 - 5 files changed, 104 insertions(+), 197 deletions(-) delete mode 100644 src/libs/utils/projectintropage.ui (limited to 'src/libs') diff --git a/src/libs/utils/CMakeLists.txt b/src/libs/utils/CMakeLists.txt index d76b5339ed0..4029752e899 100644 --- a/src/libs/utils/CMakeLists.txt +++ b/src/libs/utils/CMakeLists.txt @@ -126,7 +126,7 @@ add_qtc_library(Utils processreaper.cpp processreaper.h processutils.cpp processutils.h progressindicator.cpp progressindicator.h - projectintropage.cpp projectintropage.h projectintropage.ui + projectintropage.cpp projectintropage.h proxyaction.cpp proxyaction.h proxycredentialsdialog.cpp proxycredentialsdialog.h proxycredentialsdialog.ui qrcparser.cpp qrcparser.h diff --git a/src/libs/utils/projectintropage.cpp b/src/libs/utils/projectintropage.cpp index 1b3186be115..c8f99d7bb71 100644 --- a/src/libs/utils/projectintropage.cpp +++ b/src/libs/utils/projectintropage.cpp @@ -24,13 +24,23 @@ ****************************************************************************/ #include "projectintropage.h" -#include "ui_projectintropage.h" +#include "fancylineedit.h" #include "filenamevalidatinglineedit.h" #include "fileutils.h" +#include "infolabel.h" +#include "layoutbuilder.h" +#include "pathchooser.h" #include "wizard.h" +#include +#include +#include #include +#include +#include +#include +#include /*! \class Utils::ProjectIntroPage @@ -59,50 +69,93 @@ namespace Utils { class ProjectIntroPagePrivate { public: - Ui::ProjectIntroPage m_ui; bool m_complete = false; QRegularExpressionValidator m_projectNameValidator; QString m_projectNameValidatorUserMessage; bool m_forceSubProject = false; FilePaths m_projectDirectories; + + QLabel *m_descriptionLabel; + FancyLineEdit *m_nameLineEdit; + PathChooser *m_pathChooser; + QCheckBox *m_projectsDirectoryCheckBox; + QLabel *m_projectLabel; + QComboBox *m_projectComboBox; + InfoLabel *m_stateLabel; }; ProjectIntroPage::ProjectIntroPage(QWidget *parent) : WizardPage(parent), d(new ProjectIntroPagePrivate) { - d->m_ui.setupUi(this); - d->m_ui.stateLabel->setFilled(true); + resize(355, 289); + setTitle(tr("Introduction and Project Location")); + + d->m_descriptionLabel = new QLabel(this); + d->m_descriptionLabel->setWordWrap(true); + + auto frame = new QFrame(this); + frame->setFrameShape(QFrame::StyledPanel); + frame->setFrameShadow(QFrame::Raised); + + d->m_nameLineEdit = new Utils::FancyLineEdit(frame); + + d->m_pathChooser = new Utils::PathChooser(frame); + d->m_pathChooser->setDisabled(d->m_forceSubProject); + + d->m_projectsDirectoryCheckBox = new QCheckBox(tr("Use as default project location")); + d->m_projectsDirectoryCheckBox->setDisabled(d->m_forceSubProject); + + d->m_projectComboBox = new QComboBox; + d->m_projectComboBox->setVisible(d->m_forceSubProject); + + d->m_stateLabel = new Utils::InfoLabel(this); + d->m_stateLabel->setWordWrap(true); + d->m_stateLabel->setFilled(true); hideStatusLabel(); - d->m_ui.nameLineEdit->setPlaceholderText(tr("Enter project name")); - d->m_ui.nameLineEdit->setFocus(); - d->m_ui.nameLineEdit->setValidationFunction([this](FancyLineEdit *edit, QString *errorString) { + + d->m_nameLineEdit->setPlaceholderText(tr("Enter project name")); + d->m_nameLineEdit->setFocus(); + d->m_nameLineEdit->setValidationFunction([this](FancyLineEdit *edit, QString *errorString) { return validateProjectName(edit->text(), errorString); }); - d->m_ui.projectLabel->setVisible(d->m_forceSubProject); - d->m_ui.projectComboBox->setVisible(d->m_forceSubProject); - d->m_ui.pathChooser->setDisabled(d->m_forceSubProject); - d->m_ui.projectsDirectoryCheckBox->setDisabled(d->m_forceSubProject); - connect(d->m_ui.pathChooser, &PathChooser::filePathChanged, this, &ProjectIntroPage::slotChanged); - connect(d->m_ui.nameLineEdit, &QLineEdit::textChanged, + + d->m_projectLabel = new QLabel("Project:"); + d->m_projectLabel->setVisible(d->m_forceSubProject); + + using namespace Layouting; + const Break br; + + Form { + tr("Name:"), d->m_nameLineEdit, br, + d->m_projectLabel, d->m_projectComboBox, br, + Column { Space(12) }, br, + tr("Create in:"), d->m_pathChooser, br, + Span(2, d->m_projectsDirectoryCheckBox) + }.attachTo(frame); + + Column { + d->m_descriptionLabel, + Stretch(), + frame, + d->m_stateLabel + }.attachTo(this); + + connect(d->m_pathChooser, &PathChooser::filePathChanged, this, &ProjectIntroPage::slotChanged); + connect(d->m_nameLineEdit, &QLineEdit::textChanged, this, &ProjectIntroPage::slotChanged); - connect(d->m_ui.pathChooser, &PathChooser::validChanged, + connect(d->m_pathChooser, &PathChooser::validChanged, this, &ProjectIntroPage::slotChanged); - connect(d->m_ui.pathChooser, &PathChooser::returnPressed, + connect(d->m_pathChooser, &PathChooser::returnPressed, this, &ProjectIntroPage::slotActivated); - connect(d->m_ui.nameLineEdit, &FancyLineEdit::validReturnPressed, + connect(d->m_nameLineEdit, &FancyLineEdit::validReturnPressed, this, &ProjectIntroPage::slotActivated); - connect(d->m_ui.projectComboBox, &QComboBox::currentIndexChanged, + connect(d->m_projectComboBox, &QComboBox::currentIndexChanged, this, &ProjectIntroPage::slotChanged); setProperty(SHORT_TITLE_PROPERTY, tr("Location")); - registerFieldWithName(QLatin1String("Path"), d->m_ui.pathChooser, "path", SIGNAL(pathChanged(QString))); - registerFieldWithName(QLatin1String("ProjectName"), d->m_ui.nameLineEdit); -} - -void ProjectIntroPage::insertControl(int row, QWidget *label, QWidget *control) -{ - d->m_ui.formLayout->insertRow(row, label, control); + registerFieldWithName(QLatin1String("Path"), d->m_pathChooser, "path", SIGNAL(pathChanged(QString))); + registerFieldWithName(QLatin1String("ProjectName"), d->m_nameLineEdit); } ProjectIntroPage::~ProjectIntroPage() @@ -112,17 +165,17 @@ ProjectIntroPage::~ProjectIntroPage() QString ProjectIntroPage::projectName() const { - return d->m_ui.nameLineEdit->text(); + return d->m_nameLineEdit->text(); } FilePath ProjectIntroPage::filePath() const { - return d->m_ui.pathChooser->filePath(); + return d->m_pathChooser->filePath(); } void ProjectIntroPage::setFilePath(const FilePath &path) { - d->m_ui.pathChooser->setFilePath(path); + d->m_pathChooser->setFilePath(path); } void ProjectIntroPage::setProjectNameRegularExpression(const QRegularExpression ®Ex, const QString &userErrorMessage) @@ -134,18 +187,18 @@ void ProjectIntroPage::setProjectNameRegularExpression(const QRegularExpression void ProjectIntroPage::setProjectName(const QString &name) { - d->m_ui.nameLineEdit->setText(name); - d->m_ui.nameLineEdit->selectAll(); + d->m_nameLineEdit->setText(name); + d->m_nameLineEdit->selectAll(); } QString ProjectIntroPage::description() const { - return d->m_ui.descriptionLabel->text(); + return d->m_descriptionLabel->text(); } void ProjectIntroPage::setDescription(const QString &description) { - d->m_ui.descriptionLabel->setText(description); + d->m_descriptionLabel->setText(description); } bool ProjectIntroPage::isComplete() const @@ -156,21 +209,21 @@ bool ProjectIntroPage::isComplete() const bool ProjectIntroPage::validate() { if (d->m_forceSubProject) { - int index = d->m_ui.projectComboBox->currentIndex(); + int index = d->m_projectComboBox->currentIndex(); if (index == 0) return false; - d->m_ui.pathChooser->setFilePath(d->m_projectDirectories.at(index)); + d->m_pathChooser->setFilePath(d->m_projectDirectories.at(index)); } // Validate and display status - if (!d->m_ui.pathChooser->isValid()) { - displayStatusMessage(InfoLabel::Error, d->m_ui.pathChooser->errorMessage()); + if (!d->m_pathChooser->isValid()) { + displayStatusMessage(InfoLabel::Error, d->m_pathChooser->errorMessage()); return false; } // Name valid? - switch (d->m_ui.nameLineEdit->state()) { + switch (d->m_nameLineEdit->state()) { case FancyLineEdit::Invalid: - displayStatusMessage(InfoLabel::Error, d->m_ui.nameLineEdit->errorMessage()); + displayStatusMessage(InfoLabel::Error, d->m_nameLineEdit->errorMessage()); return false; case FancyLineEdit::DisplayingPlaceholderText: displayStatusMessage(InfoLabel::Error, tr("Name is empty.")); @@ -181,7 +234,7 @@ bool ProjectIntroPage::validate() // Check existence of the directory const FilePath projectDir = - filePath().pathAppended(QDir::fromNativeSeparators(d->m_ui.nameLineEdit->text())); + filePath().pathAppended(QDir::fromNativeSeparators(d->m_nameLineEdit->text())); if (!projectDir.exists()) { // All happy hideStatusLabel(); @@ -225,16 +278,16 @@ bool ProjectIntroPage::forceSubProject() const void ProjectIntroPage::setForceSubProject(bool force) { d->m_forceSubProject = force; - d->m_ui.projectLabel->setVisible(d->m_forceSubProject); - d->m_ui.projectComboBox->setVisible(d->m_forceSubProject); - d->m_ui.pathChooser->setDisabled(d->m_forceSubProject); - d->m_ui.projectsDirectoryCheckBox->setDisabled(d->m_forceSubProject); + d->m_projectLabel->setVisible(d->m_forceSubProject); + d->m_projectComboBox->setVisible(d->m_forceSubProject); + d->m_pathChooser->setDisabled(d->m_forceSubProject); + d->m_projectsDirectoryCheckBox->setDisabled(d->m_forceSubProject); } void ProjectIntroPage::setProjectList(const QStringList &projectList) { - d->m_ui.projectComboBox->clear(); - d->m_ui.projectComboBox->addItems(projectList); + d->m_projectComboBox->clear(); + d->m_projectComboBox->addItems(projectList); } void ProjectIntroPage::setProjectDirectories(const FilePaths &directoryList) @@ -244,7 +297,7 @@ void ProjectIntroPage::setProjectDirectories(const FilePaths &directoryList) int ProjectIntroPage::projectIndex() const { - return d->m_ui.projectComboBox->currentIndex(); + return d->m_projectComboBox->currentIndex(); } bool ProjectIntroPage::validateProjectName(const QString &name, QString *errorMessage) @@ -293,8 +346,8 @@ bool ProjectIntroPage::validateProjectName(const QString &name, QString *errorMe void ProjectIntroPage::displayStatusMessage(InfoLabel::InfoType t, const QString &s) { - d->m_ui.stateLabel->setType(t); - d->m_ui.stateLabel->setText(s); + d->m_stateLabel->setType(t); + d->m_stateLabel->setText(s); emit statusMessageChanged(t, s); } @@ -306,12 +359,12 @@ void ProjectIntroPage::hideStatusLabel() bool ProjectIntroPage::useAsDefaultPath() const { - return d->m_ui.projectsDirectoryCheckBox->isChecked(); + return d->m_projectsDirectoryCheckBox->isChecked(); } void ProjectIntroPage::setUseAsDefaultPath(bool u) { - d->m_ui.projectsDirectoryCheckBox->setChecked(u); + d->m_projectsDirectoryCheckBox->setChecked(u); } } // namespace Utils diff --git a/src/libs/utils/projectintropage.h b/src/libs/utils/projectintropage.h index 4508039b06c..7fb2fada195 100644 --- a/src/libs/utils/projectintropage.h +++ b/src/libs/utils/projectintropage.h @@ -33,8 +33,6 @@ namespace Utils { -class ProjectIntroPagePrivate; - class QTCREATOR_UTILS_EXPORT ProjectIntroPage : public WizardPage { Q_OBJECT @@ -53,9 +51,6 @@ public: QString description() const; bool useAsDefaultPath() const; - // Insert an additional control into the form layout for the target. - void insertControl(int row, QWidget *label, QWidget *control); - bool isComplete() const override; bool forceSubProject() const; @@ -90,7 +85,7 @@ private: void displayStatusMessage(InfoLabel::InfoType t, const QString &); void hideStatusLabel(); - ProjectIntroPagePrivate *d; + class ProjectIntroPagePrivate *d; }; } // namespace Utils diff --git a/src/libs/utils/projectintropage.ui b/src/libs/utils/projectintropage.ui deleted file mode 100644 index 54624948a6b..00000000000 --- a/src/libs/utils/projectintropage.ui +++ /dev/null @@ -1,140 +0,0 @@ - - - Utils::ProjectIntroPage - - - - 0 - 0 - 355 - 289 - - - - Introduction and Project Location - - - - QLayout::SetMinimumSize - - - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 0 - 0 - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - QFormLayout::ExpandingFieldsGrow - - - - - Name: - - - - - - - - - - Create in: - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 0 - 12 - - - - - - - - Use as default project location - - - - - - - Project: - - - - - - - - - - - - - true - - - - - - - - Utils::FancyLineEdit - QLineEdit -
utils/fancylineedit.h
-
- - Utils::PathChooser - QWidget -
utils/pathchooser.h
- 1 -
- - Utils::InfoLabel - QLabel -
utils/infolabel.h
-
-
- - -
diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 07570df9499..8636eb0bdc1 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -240,7 +240,6 @@ Project { "progressindicator.h", "projectintropage.cpp", "projectintropage.h", - "projectintropage.ui", "proxyaction.cpp", "proxyaction.h", "proxycredentialsdialog.cpp", -- cgit v1.2.3