NewProjectSettingsScreen.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <ProjectSettingsScreen.h>
  11. #include <ProjectTemplateInfo.h>
  12. #include <DownloadController.h>
  13. #include <TemplateButtonWidget.h>
  14. #include <QPointer>
  15. #include <QVector>
  16. #endif
  17. QT_FORWARD_DECLARE_CLASS(QButtonGroup)
  18. QT_FORWARD_DECLARE_CLASS(QLabel)
  19. QT_FORWARD_DECLARE_CLASS(QFrame)
  20. QT_FORWARD_DECLARE_CLASS(FlowLayout)
  21. namespace O3DE::ProjectManager
  22. {
  23. QT_FORWARD_DECLARE_CLASS(TagContainerWidget)
  24. class NewProjectSettingsScreen
  25. : public ProjectSettingsScreen
  26. {
  27. Q_OBJECT
  28. public:
  29. explicit NewProjectSettingsScreen(DownloadController* downloadController, QWidget* parent = nullptr);
  30. ~NewProjectSettingsScreen() = default;
  31. ProjectManagerScreen GetScreenEnum() override;
  32. //! returns the project template path or "" if the template is remote and has not been downloaded
  33. QString GetProjectTemplatePath();
  34. bool IsDownloadingTemplate() const;
  35. void NotifyCurrentScreen() override;
  36. void SelectProjectTemplate(int index, bool blockSignals = false);
  37. AZ::Outcome<void, QString> Validate() const override;
  38. void ShowDownloadTemplateDialog(const ProjectTemplateInfo& templateInfo = {});
  39. const ProjectTemplateInfo GetSelectedProjectTemplateInfo() const;
  40. signals:
  41. void OnTemplateSelectionChanged(int oldIndex, int newIndex);
  42. public slots:
  43. void StartTemplateDownload(const QString& templateName, const QString& destinationPath);
  44. void HandleDownloadResult(const QString& projectName, bool succeeded);
  45. void HandleDownloadProgress(const QString& projectName, DownloadController::DownloadObjectType objectType, int bytesDownloaded, int totalBytes);
  46. protected:
  47. void OnProjectNameUpdated() override;
  48. void OnProjectPathUpdated() override;
  49. private:
  50. QString GetDefaultProjectName();
  51. QString GetProjectAutoPath();
  52. QFrame* CreateTemplateDetails(int margin);
  53. void AddTemplateButtons();
  54. void UpdateTemplateDetails(const ProjectTemplateInfo& templateInfo);
  55. QButtonGroup* m_projectTemplateButtonGroup;
  56. QLabel* m_templateDisplayName;
  57. QLabel* m_templateSummary;
  58. QPushButton* m_downloadTemplateButton;
  59. TemplateButton* m_remoteTemplateButton = nullptr;
  60. TagContainerWidget* m_templateIncludedGems;
  61. QVector<ProjectTemplateInfo> m_templates;
  62. QVector<TemplateButton*> m_templateButtons;
  63. FlowLayout* m_templateFlowLayout = nullptr;
  64. int m_selectedTemplateIndex = -1;
  65. bool m_userChangedProjectPath = false;
  66. QPointer<DownloadController> m_downloadController = nullptr;
  67. inline constexpr static int s_spacerSize = 20;
  68. inline constexpr static int s_templateDetailsContentMargin = 20;
  69. };
  70. } // namespace O3DE::ProjectManager