diff options
author | hjk <[email protected]> | 2022-07-22 18:02:04 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2022-07-25 06:18:06 +0000 |
commit | 715e5800a5db78f198dd1a09c55e0fdcdafd4015 (patch) | |
tree | 282f3439c950630fb06358d2a95d6b7aa2acb40b /src/libs/utils/projectintropage.cpp | |
parent | 1548eef10b8987142bf1cafa27278e5b816a11b7 (diff) |
Utils: inline projectintropage.ui
Change-Id: I10f1b76b8bc88c56dfe6d215345d9b92a6832074
Reviewed-by: Alessandro Portale <[email protected]>
Reviewed-by: <[email protected]>
Diffstat (limited to 'src/libs/utils/projectintropage.cpp')
-rw-r--r-- | src/libs/utils/projectintropage.cpp | 151 |
1 files changed, 102 insertions, 49 deletions
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 <QApplication> +#include <QCheckBox> +#include <QComboBox> #include <QDir> +#include <QFormLayout> +#include <QFrame> +#include <QLabel> +#include <QSpacerItem> /*! \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 |