Project Template details and preview changes
This commit is contained in:
@@ -14,8 +14,12 @@
|
||||
#include <PythonBindingsInterface.h>
|
||||
#include <FormLineEditWidget.h>
|
||||
#include <FormBrowseEditWidget.h>
|
||||
#include <TemplateButtonWidget.h>
|
||||
#include <PathValidator.h>
|
||||
#include <EngineInfo.h>
|
||||
#include <CreateProjectCtrl.h>
|
||||
#include <TagWidget.h>
|
||||
#include <AzQtComponents/Components/FlowLayout.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
@@ -28,10 +32,12 @@
|
||||
#include <QSpacerItem>
|
||||
#include <QStandardPaths>
|
||||
#include <QFrame>
|
||||
#include <QScrollArea>
|
||||
#include <QAbstractButton>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
constexpr const char* k_pathProperty = "Path";
|
||||
constexpr const char* k_templateIndexProperty = "TemplateIndex";
|
||||
|
||||
NewProjectSettingsScreen::NewProjectSettingsScreen(QWidget* parent)
|
||||
: ProjectSettingsScreen(parent)
|
||||
@@ -59,30 +65,69 @@ namespace O3DE::ProjectManager
|
||||
projectTemplateDetailsLabel->setObjectName("projectTemplateDetailsLabel");
|
||||
containerLayout->addWidget(projectTemplateDetailsLabel);
|
||||
|
||||
QHBoxLayout* templateLayout = new QHBoxLayout(this);
|
||||
containerLayout->addItem(templateLayout);
|
||||
|
||||
// we might have enough templates that we need to scroll
|
||||
QScrollArea* templatesScrollArea = new QScrollArea(this);
|
||||
QWidget* scrollWidget = new QWidget();
|
||||
|
||||
FlowLayout* flowLayout = new FlowLayout(0, s_spacerSize, s_spacerSize);
|
||||
scrollWidget->setLayout(flowLayout);
|
||||
|
||||
templatesScrollArea->setWidget(scrollWidget);
|
||||
templatesScrollArea->setWidgetResizable(true);
|
||||
|
||||
m_projectTemplateButtonGroup = new QButtonGroup(this);
|
||||
m_projectTemplateButtonGroup->setObjectName("templateButtonGroup");
|
||||
|
||||
// QButtonGroup has overloaded buttonClicked methods so we need the QOverload
|
||||
connect(
|
||||
m_projectTemplateButtonGroup, QOverload<QAbstractButton*>::of(&QButtonGroup::buttonClicked), this,
|
||||
[=](QAbstractButton* button)
|
||||
{
|
||||
if (button && button->property(k_templateIndexProperty).isValid())
|
||||
{
|
||||
int projectIndex = button->property(k_templateIndexProperty).toInt();
|
||||
UpdateTemplateDetails(m_templates.at(projectIndex));
|
||||
}
|
||||
});
|
||||
|
||||
auto templatesResult = PythonBindingsInterface::Get()->GetProjectTemplates();
|
||||
if (templatesResult.IsSuccess() && !templatesResult.GetValue().isEmpty())
|
||||
{
|
||||
for (const ProjectTemplateInfo& projectTemplate : templatesResult.GetValue())
|
||||
{
|
||||
QRadioButton* radioButton = new QRadioButton(projectTemplate.m_name, this);
|
||||
radioButton->setProperty(k_pathProperty, projectTemplate.m_path);
|
||||
m_projectTemplateButtonGroup->addButton(radioButton);
|
||||
m_templates = templatesResult.GetValue();
|
||||
|
||||
containerLayout->addWidget(radioButton);
|
||||
// sort alphabetically by display name because they could be in any order
|
||||
std::sort(m_templates.begin(), m_templates.end(), [](const ProjectTemplateInfo& arg1, const ProjectTemplateInfo& arg2)
|
||||
{
|
||||
return arg1.m_displayName.toLower() < arg2.m_displayName.toLower();
|
||||
});
|
||||
|
||||
for (int index = 0; index < m_templates.size(); ++index)
|
||||
{
|
||||
ProjectTemplateInfo projectTemplate = m_templates.at(index);
|
||||
QString projectPreviewPath = projectTemplate.m_path + "/Template/preview.png";
|
||||
QFileInfo doesPreviewExist(projectPreviewPath);
|
||||
if (!doesPreviewExist.exists() || !doesPreviewExist.isFile())
|
||||
{
|
||||
projectPreviewPath = ":/DefaultTemplate.png";
|
||||
}
|
||||
TemplateButton* templateButton = new TemplateButton(projectPreviewPath, projectTemplate.m_displayName, this);
|
||||
templateButton->setCheckable(true);
|
||||
templateButton->setProperty(k_templateIndexProperty, index);
|
||||
|
||||
m_projectTemplateButtonGroup->addButton(templateButton);
|
||||
|
||||
flowLayout->addWidget(templateButton);
|
||||
}
|
||||
|
||||
m_projectTemplateButtonGroup->buttons().first()->setChecked(true);
|
||||
}
|
||||
containerLayout->addWidget(templatesScrollArea);
|
||||
}
|
||||
projectTemplateWidget->setLayout(containerLayout);
|
||||
m_verticalLayout->addWidget(projectTemplateWidget);
|
||||
|
||||
QWidget* projectTemplateDetails = new QWidget(this);
|
||||
QFrame* projectTemplateDetails = CreateTemplateDetails(s_templateDetailsContentMargin);
|
||||
projectTemplateDetails->setObjectName("projectTemplateDetails");
|
||||
m_horizontalLayout->addWidget(projectTemplateDetails);
|
||||
}
|
||||
@@ -109,11 +154,71 @@ namespace O3DE::ProjectManager
|
||||
|
||||
void NewProjectSettingsScreen::NotifyCurrentScreen()
|
||||
{
|
||||
if (!m_templates.isEmpty())
|
||||
{
|
||||
UpdateTemplateDetails(m_templates.first());
|
||||
}
|
||||
|
||||
Validate();
|
||||
}
|
||||
|
||||
QString NewProjectSettingsScreen::GetProjectTemplatePath()
|
||||
{
|
||||
return m_projectTemplateButtonGroup->checkedButton()->property(k_pathProperty).toString();
|
||||
const int templateIndex = m_projectTemplateButtonGroup->checkedButton()->property(k_templateIndexProperty).toInt();
|
||||
return m_templates.at(templateIndex).m_path;
|
||||
}
|
||||
|
||||
QFrame* NewProjectSettingsScreen::CreateTemplateDetails(int margin)
|
||||
{
|
||||
QFrame* projectTemplateDetails = new QFrame(this);
|
||||
projectTemplateDetails->setObjectName("projectTemplateDetails");
|
||||
QVBoxLayout* templateDetailsLayout = new QVBoxLayout();
|
||||
templateDetailsLayout->setContentsMargins(margin, margin, margin, margin);
|
||||
templateDetailsLayout->setAlignment(Qt::AlignTop);
|
||||
{
|
||||
m_templateDisplayName = new QLabel(this);
|
||||
m_templateDisplayName->setObjectName("displayName");
|
||||
templateDetailsLayout->addWidget(m_templateDisplayName);
|
||||
|
||||
m_templateSummary = new QLabel(this);
|
||||
m_templateSummary->setObjectName("summary");
|
||||
m_templateSummary->setWordWrap(true);
|
||||
templateDetailsLayout->addWidget(m_templateSummary);
|
||||
|
||||
QLabel* includedGemsTitle = new QLabel(tr("Included Gems"), this);
|
||||
includedGemsTitle->setObjectName("includedGemsTitle");
|
||||
templateDetailsLayout->addWidget(includedGemsTitle);
|
||||
|
||||
m_templateIncludedGems = new TagContainerWidget(this);
|
||||
m_templateIncludedGems->setObjectName("includedGems");
|
||||
templateDetailsLayout->addWidget(m_templateIncludedGems);
|
||||
|
||||
#ifdef TEMPLATE_GEM_CONFIGURATION_ENABLED
|
||||
QLabel* moreGemsLabel = new QLabel(tr("Looking for more Gems?"), this);
|
||||
moreGemsLabel->setObjectName("moreGems");
|
||||
templateDetailsLayout->addWidget(moreGemsLabel);
|
||||
|
||||
QLabel* browseCatalogLabel = new QLabel(tr("Browse the Gems Catalog to further customize your project."), this);
|
||||
browseCatalogLabel->setObjectName("browseCatalog");
|
||||
browseCatalogLabel->setWordWrap(true);
|
||||
templateDetailsLayout->addWidget(browseCatalogLabel);
|
||||
|
||||
QPushButton* configureGemsButton = new QPushButton(tr("Configure with more Gems"), this);
|
||||
connect(configureGemsButton, &QPushButton::clicked, this, [=]()
|
||||
{
|
||||
emit ChangeScreenRequest(ProjectManagerScreen::GemCatalog);
|
||||
});
|
||||
templateDetailsLayout->addWidget(configureGemsButton);
|
||||
#endif // TEMPLATE_GEM_CONFIGURATION_ENABLED
|
||||
}
|
||||
projectTemplateDetails->setLayout(templateDetailsLayout);
|
||||
return projectTemplateDetails;
|
||||
}
|
||||
|
||||
void NewProjectSettingsScreen::UpdateTemplateDetails(const ProjectTemplateInfo& templateInfo)
|
||||
{
|
||||
m_templateDisplayName->setText(templateInfo.m_displayName);
|
||||
m_templateSummary->setText(templateInfo.m_summary);
|
||||
m_templateIncludedGems->Update(templateInfo.m_includedGems);
|
||||
}
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
Reference in New Issue
Block a user