forked from qt-creator/qt-creator
Make additional changes in the QtCreator side required for QDS new project dialog
* We need to use the CheckBox field to set the checked state of fields (TargetQtVersion, Use as default project location). * When the validation of the Project Name or Project Location fails, we need a way to be notified of what went wrong. We also need a way to force the project intro page to execute the validation of those fields whenever we need (i.e. when the user types into our QML TextField controls) Also, add a warning on loading wizards: whenever a wizard.json file cannot be parsed, we should issue a qWarning(), so that we can more easily notice when something went wrong. Task-number: QDS-4490 Change-Id: I7cfa61b4e43d731db9d0679e093e723d947b60c0 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -195,6 +195,11 @@ bool ProjectIntroPage::validate()
|
||||
return false;
|
||||
}
|
||||
|
||||
void ProjectIntroPage::fieldsUpdated()
|
||||
{
|
||||
slotChanged();
|
||||
}
|
||||
|
||||
void ProjectIntroPage::slotChanged()
|
||||
{
|
||||
const bool newComplete = validate();
|
||||
@@ -286,6 +291,8 @@ void ProjectIntroPage::displayStatusMessage(InfoLabel::InfoType t, const QString
|
||||
{
|
||||
d->m_ui.stateLabel->setType(t);
|
||||
d->m_ui.stateLabel->setText(s);
|
||||
|
||||
emit statusMessageChanged(t, s);
|
||||
}
|
||||
|
||||
void ProjectIntroPage::hideStatusLabel()
|
||||
|
@@ -66,8 +66,14 @@ public:
|
||||
|
||||
bool validateProjectName(const QString &name, QString *errorMessage);
|
||||
|
||||
// Calls slotChanged() - i.e. tell the page that some of its fields have been updated.
|
||||
// This function is useful if you programmatically update the fields of the page (i.e. from
|
||||
// your client code).
|
||||
void fieldsUpdated();
|
||||
|
||||
signals:
|
||||
void activated();
|
||||
void statusMessageChanged(InfoLabel::InfoType type, const QString &message);
|
||||
|
||||
public slots:
|
||||
void setFilePath(const FilePath &path);
|
||||
|
@@ -956,6 +956,15 @@ void CheckBoxField::setup(JsonFieldPage *page, const QString &name)
|
||||
});
|
||||
}
|
||||
|
||||
void CheckBoxField::setChecked(bool value)
|
||||
{
|
||||
auto w = qobject_cast<QCheckBox *>(widget());
|
||||
QTC_ASSERT(w, return);
|
||||
|
||||
w->setChecked(value);
|
||||
w->clicked(value);
|
||||
}
|
||||
|
||||
bool CheckBoxField::validate(MacroExpander *expander, QString *message)
|
||||
{
|
||||
if (!JsonFieldPage::Field::validate(expander, message))
|
||||
|
@@ -230,11 +230,13 @@ private:
|
||||
Utils::PathChooser::Kind m_kind = Utils::PathChooser::ExistingDirectory;
|
||||
};
|
||||
|
||||
class CheckBoxField : public JsonFieldPage::Field
|
||||
class PROJECTEXPLORER_EXPORT CheckBoxField : public JsonFieldPage::Field
|
||||
{
|
||||
public:
|
||||
bool suppressName() const override { return true; }
|
||||
|
||||
void setChecked(bool);
|
||||
|
||||
private:
|
||||
bool parseData(const QVariant &data, QString *errorMessage) override;
|
||||
|
||||
|
@@ -257,12 +257,14 @@ QList<Core::IWizardFactory *> JsonWizardFactory::createWizardFactories()
|
||||
.arg(currentFile.fileName())
|
||||
.arg(line).arg(column)
|
||||
.arg(error.errorString()));
|
||||
qWarning() << "Failed to parse wizard: " << currentFile.fileName();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!json.isObject()) {
|
||||
verboseLog.append(tr("* Did not find a JSON object in \"%1\".\n")
|
||||
.arg(currentFile.fileName()));
|
||||
qWarning() << "Failed to parse wizard: " << currentFile.fileName();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -280,6 +282,7 @@ QList<Core::IWizardFactory *> JsonWizardFactory::createWizardFactories()
|
||||
JsonWizardFactory *factory = createWizardFactory(data, currentDir, &errorMessage);
|
||||
if (!factory) {
|
||||
verboseLog.append(tr("* Failed to create: %1\n").arg(errorMessage));
|
||||
qWarning() << "Failed to create wizard: " << currentFile.fileName();
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user