Remove Project ID field from New Project settings

Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com>
This commit is contained in:
nggieber
2021-12-09 10:25:04 -08:00
parent d7a3d63457
commit c632fadb8f
8 changed files with 83 additions and 61 deletions
@@ -43,11 +43,9 @@ namespace O3DE::ProjectManager
{
const QString defaultName = GetDefaultProjectName();
const QString defaultPath = QDir::toNativeSeparators(GetDefaultProjectPath() + "/" + defaultName);
const QString randomUuid = GenerateNewProjectId();
m_projectName->lineEdit()->setText(defaultName);
m_projectPath->lineEdit()->setText(defaultPath);
m_projectId->lineEdit()->setText(randomUuid);
// if we don't use a QFrame we cannot "contain" the widgets inside and move them around
// as a group
@@ -177,14 +175,6 @@ namespace O3DE::ProjectManager
return QDir::toNativeSeparators(GetDefaultProjectPath() + "/" + projectName);
}
QString NewProjectSettingsScreen::GenerateNewProjectId()
{
AZStd::string uuid;
AZ::Uuid::CreateRandom().ToString(uuid);
return QString(uuid.c_str());
}
ProjectManagerScreen NewProjectSettingsScreen::GetScreenEnum()
{
return ProjectManagerScreen::NewProjectSettings;
@@ -47,7 +47,6 @@ namespace O3DE::ProjectManager
private:
QString GetDefaultProjectName();
QString GetDefaultProjectPath();
QString GenerateNewProjectId();
QString GetProjectAutoPath();
QFrame* CreateTemplateDetails(int margin);
void UpdateTemplateDetails(const ProjectTemplateInfo& templateInfo);
@@ -60,10 +60,6 @@ namespace O3DE::ProjectManager
connect(m_projectPath->lineEdit(), &QLineEdit::textChanged, this, &ProjectSettingsScreen::OnProjectPathUpdated);
m_verticalLayout->addWidget(m_projectPath);
m_projectId = new FormLineEditWidget(tr("Project ID"), "", this);
connect(m_projectId->lineEdit(), &QLineEdit::textChanged, this, &ProjectSettingsScreen::OnProjectIdUpdated);
m_verticalLayout->addWidget(m_projectId);
projectSettingsFrame->setLayout(m_verticalLayout);
m_horizontalLayout->addWidget(projectSettingsFrame);
@@ -98,7 +94,6 @@ namespace O3DE::ProjectManager
// currently we don't have separate fields for changing the project name and display name
projectInfo.m_displayName = projectInfo.m_projectName;
projectInfo.m_path = m_projectPath->lineEdit()->text();
projectInfo.m_id = m_projectId->lineEdit()->text();
return projectInfo;
}
@@ -147,19 +142,6 @@ namespace O3DE::ProjectManager
return projectPathIsValid;
}
bool ProjectSettingsScreen::ValidateProjectId()
{
bool projectIdIsValid = true;
if (m_projectId->lineEdit()->text().isEmpty())
{
projectIdIsValid = false;
m_projectId->setErrorLabelText(tr("Project ID cannot be empty."));
}
m_projectId->setErrorLabelVisible(!projectIdIsValid);
return projectIdIsValid;
}
void ProjectSettingsScreen::OnProjectNameUpdated()
{
ValidateProjectName();
@@ -170,13 +152,8 @@ namespace O3DE::ProjectManager
ValidateProjectName() && ValidateProjectPath();
}
void ProjectSettingsScreen::OnProjectIdUpdated()
{
ValidateProjectId();
}
bool ProjectSettingsScreen::Validate()
{
return ValidateProjectName() && ValidateProjectPath() && ValidateProjectId();
return ValidateProjectName() && ValidateProjectPath();
}
} // namespace O3DE::ProjectManager
@@ -35,12 +35,10 @@ namespace O3DE::ProjectManager
protected slots:
virtual void OnProjectNameUpdated();
virtual void OnProjectPathUpdated();
virtual void OnProjectIdUpdated();
protected:
bool ValidateProjectName();
virtual bool ValidateProjectPath();
bool ValidateProjectId();
QString GetDefaultProjectPath();
@@ -48,7 +46,6 @@ namespace O3DE::ProjectManager
QVBoxLayout* m_verticalLayout;
FormLineEditWidget* m_projectName;
FormBrowseEditWidget* m_projectPath;
FormLineEditWidget* m_projectId;
};
} // namespace O3DE::ProjectManager
@@ -688,24 +688,8 @@ namespace O3DE::ProjectManager
auto createProjectResult = m_engineTemplate.attr("create_project")(
projectPath,
QString_To_Py_String(projectInfo.m_projectName), // project_path
QString_To_Py_Path(projectTemplatePath), // template_path
pybind11::none(), // template_name
pybind11::none(), // project_restricted_path
pybind11::none(), // project_restricted_name
pybind11::none(), // template_restricted_path
pybind11::none(), // template_restricted_name
pybind11::none(), // project_restricted_platform_relative_path
pybind11::none(), // template_restricted_platform_relative_path
pybind11::none(), // keep_restricted_in_project
pybind11::none(), // keep_license_text
pybind11::none(), // replace
pybind11::none(), // force
pybind11::none(), // no_register
pybind11::none(), // system_component_class_id
pybind11::none(), // editor_system_component_class_id
pybind11::none(), // module_id
QString_To_Py_String(projectInfo.m_id) // project_id
);
QString_To_Py_Path(projectTemplatePath) // template_path
);
if (createProjectResult.cast<int>() == 0)
{
createdProjectInfo = ProjectInfoFromPath(projectPath);
@@ -35,21 +35,71 @@ namespace O3DE::ProjectManager
virtual bool IsInitialized() = 0;
/**
* Get info about a Gem.
* @param path The absolute path to the Gem
* @param projectPath (Optional) The absolute path to the Gem project
* @return an outcome with GemInfo on success
* Get the value for a string settings key
* @param result Store string result in this variable
* @param settingsKey The key to get the value in
* @return true if all calls to settings registry were successful
*/
virtual bool Get(QString& result, const QString& settingsKey) = 0;
/**
* Get the value for a bool settings key
* @param result Store bool result in this variable
* @param settingsKey The key to get the value in
* @return true if all calls to settings registry were successful
*/
virtual bool Get(bool& result, const QString& settingsKey) = 0;
/**
* Set the value for a string settings key
* @param settingsKey The key to set the value in
* @param settingsValue String value to set key to
* @return true if all calls to settings registry were successful
*/
virtual bool Set(const QString& settingsKey, const QString& settingsValue) = 0;
/**
* Set the value for a bool settings key
* @param settingsKey The key to set the value in
* @param settingsValue Bool value to set key to
* @return true if all calls to settings registry were successful
*/
virtual bool Set(const QString& settingsKey, bool settingsValue) = 0;
/**
* Remove settings key
* @param settingsKey The key to remove
* @return true if all calls to settings registry were successful
*/
virtual bool Remove(const QString& settingsKey) = 0;
/**
* Copy the string settings value from one key to another
* @param settingsKeyOrig The original key to copy from
* @param settingsKeyDest The destination key to copy to
* @param removeOrig(Optional) Delete the original key if true
* @return true if all calls to settings registry were successful
*/
virtual bool Copy(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig = false) = 0;
/**
* Generate prefix for project settings key
* @param projectInfo Project for settings key
* @return QString Prefix for project specific settings key
*/
virtual QString GetProjectKey(const ProjectInfo& projectInfo) = 0;
/**
* Get the build status for a project
* @param result Store bool build status in this variable
* @param projectInfo Project to check built status for
* @return true if all calls to settings registry were successful
*/
virtual bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo) = 0;
/**
* Set the build status for a project
* @param projectInfo Project to set built status for
* @param successfullyBuilt Bool value to set build status to
* @return true if all calls to settings registry were successful
*/
virtual bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt) = 0;
};
@@ -45,6 +45,10 @@ namespace O3DE::ProjectManager
previewExtrasLayout->addWidget(m_projectPreviewImage);
m_verticalLayout->addLayout(previewExtrasLayout);
m_projectId = new FormLineEditWidget(tr("Project ID"), "", this);
connect(m_projectId->lineEdit(), &QLineEdit::textChanged, this, &UpdateProjectSettingsScreen::OnProjectIdUpdated);
m_verticalLayout->addWidget(m_projectId);
}
ProjectManagerScreen UpdateProjectSettingsScreen::GetScreenEnum()
@@ -90,7 +94,7 @@ namespace O3DE::ProjectManager
bool UpdateProjectSettingsScreen::Validate()
{
return ProjectSettingsScreen::Validate() && ValidateProjectPreview();
return ProjectSettingsScreen::Validate() && ValidateProjectPreview() && ValidateProjectId();
}
void UpdateProjectSettingsScreen::ResetProjectPreviewPath()
@@ -108,6 +112,11 @@ namespace O3DE::ProjectManager
QPixmap(m_projectPreview->lineEdit()->text()).scaled(m_projectPreviewImage->size(), Qt::KeepAspectRatioByExpanding));
}
void UpdateProjectSettingsScreen::OnProjectIdUpdated()
{
ValidateProjectId();
}
bool UpdateProjectSettingsScreen::ValidateProjectPath()
{
bool projectPathIsValid = true;
@@ -157,4 +166,17 @@ namespace O3DE::ProjectManager
return projectPreviewIsValid;
}
bool UpdateProjectSettingsScreen::ValidateProjectId()
{
bool projectIdIsValid = true;
if (m_projectId->lineEdit()->text().isEmpty())
{
projectIdIsValid = false;
m_projectId->setErrorLabelText(tr("Project ID cannot be empty."));
}
m_projectId->setErrorLabelVisible(!projectIdIsValid);
return projectIdIsValid;
}
} // namespace O3DE::ProjectManager
@@ -33,13 +33,16 @@ namespace O3DE::ProjectManager
public slots:
void UpdateProjectPreviewPath();
void PreviewPathChanged();
void OnProjectIdUpdated();
protected:
bool ValidateProjectPath() override;
virtual bool ValidateProjectPreview();
bool ValidateProjectId();
FormBrowseEditWidget* m_projectPreview;
QLabel* m_projectPreviewImage;
FormLineEditWidget* m_projectId;
ProjectInfo m_projectInfo;
bool m_userChangedPreview; //! Did the user change the project preview path