3
0

ProjectsScreen.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #include <AzCore/IO/Path/Path.h>
  10. #if !defined(Q_MOC_RUN)
  11. #include <ScreenWidget.h>
  12. #include <EngineInfo.h>
  13. #include <ProjectInfo.h>
  14. #include <DownloadController.h>
  15. #include <QQueue>
  16. #include <QVector>
  17. #endif
  18. QT_FORWARD_DECLARE_CLASS(QPaintEvent)
  19. QT_FORWARD_DECLARE_CLASS(QFrame)
  20. QT_FORWARD_DECLARE_CLASS(QStackedWidget)
  21. QT_FORWARD_DECLARE_CLASS(QLayout)
  22. QT_FORWARD_DECLARE_CLASS(FlowLayout)
  23. QT_FORWARD_DECLARE_CLASS(QFileSystemWatcher)
  24. namespace O3DE::ProjectManager
  25. {
  26. QT_FORWARD_DECLARE_CLASS(ProjectBuilderController);
  27. QT_FORWARD_DECLARE_CLASS(ProjectButton);
  28. QT_FORWARD_DECLARE_CLASS(DownloadController);
  29. class ProjectsScreen
  30. : public ScreenWidget
  31. {
  32. public:
  33. explicit ProjectsScreen(DownloadController* downloadController, QWidget* parent = nullptr);
  34. ~ProjectsScreen();
  35. ProjectManagerScreen GetScreenEnum() override;
  36. QString GetTabText() override;
  37. bool IsTab() override;
  38. protected:
  39. void NotifyCurrentScreen() override;
  40. void SuggestBuildProjectMsg(const ProjectInfo& projectInfo, bool showMessage);
  41. protected slots:
  42. void HandleNewProjectButton();
  43. void HandleAddProjectButton();
  44. void HandleAddRemoteProjectButton();
  45. void HandleOpenProject(const QString& projectPath);
  46. void HandleEditProject(const QString& projectPath);
  47. void HandleEditProjectGems(const QString& projectPath);
  48. void HandleCopyProject(const ProjectInfo& projectInfo);
  49. void HandleRemoveProject(const QString& projectPath);
  50. void HandleDeleteProject(const QString& projectPath);
  51. void SuggestBuildProject(const ProjectInfo& projectInfo);
  52. void QueueBuildProject(const ProjectInfo& projectInfo, bool skipDialogBox = false);
  53. void UnqueueBuildProject(const ProjectInfo& projectInfo);
  54. void StartProjectDownload(const QString& projectName, const QString& destinationPath, bool queueBuild);
  55. void HandleDownloadProgress(const QString& projectName, DownloadController::DownloadObjectType objectType, int bytesDownloaded, int totalBytes);
  56. void HandleDownloadResult(const QString& projectName, bool succeeded);
  57. void ProjectBuildDone(bool success = true);
  58. void paintEvent(QPaintEvent* event) override;
  59. void HandleProjectFilePathChanged(const QString& path);
  60. private:
  61. QFrame* CreateFirstTimeContent();
  62. QFrame* CreateProjectsContent();
  63. ProjectButton* CreateProjectButton(const ProjectInfo& project, const EngineInfo& engine);
  64. QVector<ProjectInfo> GetAllProjects();
  65. void UpdateWithProjects(const QVector<ProjectInfo>& projects);
  66. void UpdateIfCurrentScreen();
  67. bool ShouldDisplayFirstTimeContent(bool projectsFound);
  68. void RemoveProjectButtonsFromFlowLayout(const QVector<ProjectInfo>& projectsToKeep);
  69. bool StartProjectBuild(const ProjectInfo& projectInfo, bool skipDialogBox = false);
  70. QList<ProjectInfo>::iterator RequiresBuildProjectIterator(const QString& projectPath);
  71. bool BuildQueueContainsProject(const QString& projectPath);
  72. bool WarnIfInBuildQueue(const QString& projectPath);
  73. QAction* m_createNewProjectAction = nullptr;
  74. QAction* m_addExistingProjectAction = nullptr;
  75. QAction* m_addRemoteProjectAction = nullptr;
  76. QPixmap m_background;
  77. QFrame* m_firstTimeContent = nullptr;
  78. QFrame* m_projectsContent = nullptr;
  79. FlowLayout* m_projectsFlowLayout = nullptr;
  80. QFileSystemWatcher* m_fileSystemWatcher = nullptr;
  81. QStackedWidget* m_stack = nullptr;
  82. AZStd::unordered_map<AZ::IO::Path, ProjectButton*> m_projectButtons;
  83. QList<ProjectInfo> m_requiresBuild;
  84. QQueue<ProjectInfo> m_buildQueue;
  85. ProjectBuilderController* m_currentBuilder = nullptr;
  86. DownloadController* m_downloadController = nullptr;
  87. inline constexpr static int s_contentMargins = 80;
  88. inline constexpr static int s_spacerSize = 20;
  89. };
  90. } // namespace O3DE::ProjectManager