Allow project path changing and auto-completion (#3057)

* Allow project path changing and auto-complete

Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com>

* Improved error message regarding the absolute path requirement

Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com>
This commit is contained in:
Alex Peterson
2021-08-12 09:32:23 -07:00
committed by GitHub
parent 117bd0e680
commit 538276c993
5 changed files with 64 additions and 17 deletions
@@ -39,7 +39,7 @@ namespace O3DE::ProjectManager
NewProjectSettingsScreen::NewProjectSettingsScreen(QWidget* parent)
: ProjectSettingsScreen(parent)
{
const QString defaultName{ "NewProject" };
const QString defaultName = GetDefaultProjectName();
const QString defaultPath = QDir::toNativeSeparators(GetDefaultProjectPath() + "/" + defaultName);
m_projectName->lineEdit()->setText(defaultName);
@@ -162,6 +162,17 @@ namespace O3DE::ProjectManager
return defaultPath;
}
QString NewProjectSettingsScreen::GetDefaultProjectName()
{
return "NewProject";
}
QString NewProjectSettingsScreen::GetProjectAutoPath()
{
const QString projectName = m_projectName->lineEdit()->text();
return QDir::toNativeSeparators(GetDefaultProjectPath() + "/" + projectName);
}
ProjectManagerScreen NewProjectSettingsScreen::GetScreenEnum()
{
return ProjectManagerScreen::NewProjectSettings;
@@ -260,4 +271,22 @@ namespace O3DE::ProjectManager
m_projectTemplateButtonGroup->blockSignals(false);
}
}
void NewProjectSettingsScreen::OnProjectNameUpdated()
{
if (ValidateProjectName() && !m_userChangedProjectPath)
{
m_projectPath->setText(GetProjectAutoPath());
}
}
void NewProjectSettingsScreen::OnProjectPathUpdated()
{
const QString defaultPath = QDir::toNativeSeparators(GetDefaultProjectPath() + "/" + GetDefaultProjectName());
const QString autoPath = GetProjectAutoPath();
const QString path = m_projectPath->lineEdit()->text();
m_userChangedProjectPath = path != defaultPath && path != autoPath;
ValidateProjectPath();
}
} // namespace O3DE::ProjectManager