|
@@ -41,7 +41,6 @@
|
|
namespace O3DE::ProjectManager
|
|
namespace O3DE::ProjectManager
|
|
{
|
|
{
|
|
constexpr const char* k_templateIndexProperty = "TemplateIndex";
|
|
constexpr const char* k_templateIndexProperty = "TemplateIndex";
|
|
- constexpr const char* k_addRemoteTemplateProperty = "AddRemoteTemplate";
|
|
|
|
constexpr const char* k_templateNameProperty = "TemplateName";
|
|
constexpr const char* k_templateNameProperty = "TemplateName";
|
|
|
|
|
|
NewProjectSettingsScreen::NewProjectSettingsScreen(DownloadController* downloadController, QWidget* parent)
|
|
NewProjectSettingsScreen::NewProjectSettingsScreen(DownloadController* downloadController, QWidget* parent)
|
|
@@ -101,10 +100,48 @@ namespace O3DE::ProjectManager
|
|
emit OnTemplateSelectionChanged(/*oldIndex=*/oldIndex, /*newIndex=*/m_selectedTemplateIndex);
|
|
emit OnTemplateSelectionChanged(/*oldIndex=*/oldIndex, /*newIndex=*/m_selectedTemplateIndex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if (button && button->property(k_addRemoteTemplateProperty).isValid())
|
|
|
|
|
|
+ else if (button == m_remoteTemplateButton)
|
|
{
|
|
{
|
|
AddRemoteTemplateDialog* addRemoteTemplateDialog = new AddRemoteTemplateDialog(this);
|
|
AddRemoteTemplateDialog* addRemoteTemplateDialog = new AddRemoteTemplateDialog(this);
|
|
- addRemoteTemplateDialog->exec();
|
|
|
|
|
|
+ if (addRemoteTemplateDialog->exec() == QDialog::DialogCode::Accepted)
|
|
|
|
+ {
|
|
|
|
+ auto remoteTemplatesResult =
|
|
|
|
+ PythonBindingsInterface::Get()->GetProjectTemplatesForRepo(addRemoteTemplateDialog->GetRepoPath());
|
|
|
|
+ if (remoteTemplatesResult.IsSuccess() && !remoteTemplatesResult.GetValue().isEmpty())
|
|
|
|
+ {
|
|
|
|
+ // remove remote template button from layout so we can insert the new templates before it
|
|
|
|
+ m_templateFlowLayout->removeWidget(m_remoteTemplateButton);
|
|
|
|
+
|
|
|
|
+ int currentTemplateIndex = m_templates.size();
|
|
|
|
+ const QVector<ProjectTemplateInfo>& remoteTemplates = remoteTemplatesResult.GetValue();
|
|
|
|
+ for (const ProjectTemplateInfo& remoteTemplate : remoteTemplates)
|
|
|
|
+ {
|
|
|
|
+ m_templates.push_back(remoteTemplate);
|
|
|
|
+
|
|
|
|
+ // create template button
|
|
|
|
+ QString projectPreviewPath = QDir(remoteTemplate.m_path).filePath(ProjectPreviewImagePath);
|
|
|
|
+ QFileInfo doesPreviewExist(projectPreviewPath);
|
|
|
|
+ if (!doesPreviewExist.exists() || !doesPreviewExist.isFile())
|
|
|
|
+ {
|
|
|
|
+ projectPreviewPath = ":/DefaultTemplate.png";
|
|
|
|
+ }
|
|
|
|
+ TemplateButton* templateButton =
|
|
|
|
+ new TemplateButton(projectPreviewPath, remoteTemplate.m_displayName, this);
|
|
|
|
+ templateButton->SetIsRemote(remoteTemplate.m_isRemote);
|
|
|
|
+ templateButton->setCheckable(true);
|
|
|
|
+ templateButton->setProperty(k_templateIndexProperty, currentTemplateIndex);
|
|
|
|
+ templateButton->setProperty(k_templateNameProperty, remoteTemplate.m_name);
|
|
|
|
+
|
|
|
|
+ m_projectTemplateButtonGroup->addButton(templateButton);
|
|
|
|
+ m_templateFlowLayout->addWidget(templateButton);
|
|
|
|
+ m_templateButtons.append(templateButton);
|
|
|
|
+ ++currentTemplateIndex;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // add remote template button back to layout
|
|
|
|
+ m_templateFlowLayout->addWidget(m_remoteTemplateButton);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -259,10 +296,9 @@ namespace O3DE::ProjectManager
|
|
}
|
|
}
|
|
|
|
|
|
// Insert the add a remote template button
|
|
// Insert the add a remote template button
|
|
- TemplateButton* remoteTemplateButton = new TemplateButton(":/DefaultTemplate.png", tr("Add remote Template"), this);
|
|
|
|
- remoteTemplateButton->setProperty(k_addRemoteTemplateProperty, true);
|
|
|
|
- m_projectTemplateButtonGroup->addButton(remoteTemplateButton);
|
|
|
|
- m_templateFlowLayout->addWidget(remoteTemplateButton);
|
|
|
|
|
|
+ m_remoteTemplateButton = new TemplateButton(":/DefaultTemplate.png", tr("Add remote Template"), this);
|
|
|
|
+ m_projectTemplateButtonGroup->addButton(m_remoteTemplateButton);
|
|
|
|
+ m_templateFlowLayout->addWidget(m_remoteTemplateButton);
|
|
|
|
|
|
// Select the first project template (default selection).
|
|
// Select the first project template (default selection).
|
|
SelectProjectTemplate(0, /*blockSignals=*/true);
|
|
SelectProjectTemplate(0, /*blockSignals=*/true);
|
|
@@ -397,6 +433,17 @@ namespace O3DE::ProjectManager
|
|
m_projectTemplateButtonGroup->blockSignals(false);
|
|
m_projectTemplateButtonGroup->blockSignals(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ AZ::Outcome<void, QString> NewProjectSettingsScreen::Validate() const
|
|
|
|
+ {
|
|
|
|
+ if (m_selectedTemplateIndex != -1 && m_templates[m_selectedTemplateIndex].m_isRemote)
|
|
|
|
+ {
|
|
|
|
+ return AZ::Failure<QString>(tr("You cannot create a new project with a template that has not been downloaded. Please download it before proceeding."));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ProjectSettingsScreen::Validate();
|
|
|
|
+ }
|
|
|
|
+
|
|
void NewProjectSettingsScreen::OnProjectNameUpdated()
|
|
void NewProjectSettingsScreen::OnProjectNameUpdated()
|
|
{
|
|
{
|
|
if (ValidateProjectName() && !m_userChangedProjectPath)
|
|
if (ValidateProjectName() && !m_userChangedProjectPath)
|