ProjectButtonWidget.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 <EngineInfo.h>
  11. #include <ProjectInfo.h>
  12. #include <AzCore/std/functional.h>
  13. #include <QLabel>
  14. #include <QPushButton>
  15. #include <QSpacerItem>
  16. #include <QLayout>
  17. #endif
  18. QT_FORWARD_DECLARE_CLASS(QPixmap)
  19. QT_FORWARD_DECLARE_CLASS(QAction)
  20. QT_FORWARD_DECLARE_CLASS(QProgressBar)
  21. QT_FORWARD_DECLARE_CLASS(QLayout)
  22. QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
  23. QT_FORWARD_DECLARE_CLASS(QEvent)
  24. QT_FORWARD_DECLARE_CLASS(QMenu)
  25. namespace AzQtComponents
  26. {
  27. QT_FORWARD_DECLARE_CLASS(ElidingLabel)
  28. }
  29. namespace O3DE::ProjectManager
  30. {
  31. class LabelButton
  32. : public QLabel
  33. {
  34. Q_OBJECT
  35. public:
  36. explicit LabelButton(QWidget* parent = nullptr);
  37. ~LabelButton() = default;
  38. QLabel* GetMessageLabel();
  39. QLabel* GetSubMessageLabel();
  40. QLabel* GetWarningIcon();
  41. QLabel* GetCloudIcon();
  42. QSpacerItem* GetWarningSpacer();
  43. QLabel* GetBuildingAnimationLabel();
  44. QPushButton* GetOpenEditorButton();
  45. QPushButton* GetActionButton();
  46. QPushButton* GetActionCancelButton();
  47. QPushButton* GetShowLogsButton();
  48. QLabel* GetDarkenOverlay();
  49. QProgressBar* GetProgressBar();
  50. QLabel* GetProgressPercentage();
  51. QLabel* GetDownloadMessageLabel();
  52. public slots:
  53. void mousePressEvent(QMouseEvent* event) override;
  54. signals:
  55. void triggered(QMouseEvent* event);
  56. private:
  57. QVBoxLayout* m_projectOverlayLayout = nullptr;
  58. QLabel* m_darkenOverlay = nullptr;
  59. QLabel* m_messageLabel = nullptr;
  60. QLabel* m_subMessageLabel = nullptr;
  61. QLabel* m_warningIcon = nullptr;
  62. QSpacerItem* m_warningSpacer = nullptr;
  63. QLabel* m_cloudIcon = nullptr;
  64. QLabel* m_buildingAnimation = nullptr;
  65. QLabel* m_downloadMessageLabel = nullptr;
  66. QProgressBar* m_progessBar = nullptr;
  67. QLabel* m_progressMessageLabel = nullptr;
  68. QPushButton* m_openEditorButton = nullptr;
  69. QPushButton* m_actionButton = nullptr;
  70. QPushButton* m_actionCancelButton = nullptr;
  71. QPushButton* m_showLogsButton = nullptr;
  72. };
  73. enum class ProjectButtonState
  74. {
  75. ReadyToLaunch = 0,
  76. Launching,
  77. NeedsToBuild,
  78. Building,
  79. BuildFailed,
  80. Exporting,
  81. ExportFailed,
  82. NotDownloaded,
  83. Downloading,
  84. DownloadingBuildQueued,
  85. DownloadFailed
  86. };
  87. class ProjectButton
  88. : public QFrame
  89. {
  90. Q_OBJECT
  91. public:
  92. ProjectButton(const ProjectInfo& projectInfo, const EngineInfo& engineInfo, QWidget* parent = nullptr);
  93. ~ProjectButton();
  94. const ProjectInfo& GetProjectInfo() const;
  95. void SetEngine(const EngineInfo& engine);
  96. void SetProject(const ProjectInfo& project);
  97. void SetState(ProjectButtonState state);
  98. const ProjectButtonState GetState() const
  99. {
  100. return m_currentState;
  101. }
  102. void SetProjectButtonAction(const QString& text, AZStd::function<void()> lambda);
  103. void SetBuildLogsLink(const QUrl& logUrl);
  104. void SetProgressBarPercentage(const float percent);
  105. void SetContextualText(const QString& text);
  106. LabelButton* GetLabelButton();
  107. public slots:
  108. void ShowLogs();
  109. signals:
  110. void OpenProject(const QString& projectName);
  111. void EditProject(const QString& projectName);
  112. void EditProjectGems(const QString& projectName);
  113. void ExportProject(const ProjectInfo& projectInfo, const QString& exportScript, bool skipDialogBox = false);
  114. void CopyProject(const ProjectInfo& projectInfo);
  115. void RemoveProject(const QString& projectName);
  116. void DeleteProject(const QString& projectName);
  117. void BuildProject(const ProjectInfo& projectInfo, bool skipDialogBox = false);
  118. void OpenProjectExportSettings(const QString& projectPath);
  119. void OpenCMakeGUI(const ProjectInfo& projectInfo);
  120. void OpenAndroidProjectGenerator(const QString& projectPath);
  121. private:
  122. void enterEvent(QEvent* event) override;
  123. void leaveEvent(QEvent* event) override;
  124. void ShowReadyState();
  125. void ShowLaunchingState();
  126. void ShowBuildRequiredState();
  127. void ShowBuildingState();
  128. void ShowExportingState();
  129. void ShowBuildFailedState();
  130. void ShowExportFailedState();
  131. void ShowNotDownloadedState();
  132. void ShowDownloadingState();
  133. void ResetButtonWidgets();
  134. void ShowMessage(const QString& message = {}, const QString& submessage = {});
  135. void ShowWarning(const QString& warning = {});
  136. void ShowBuildButton();
  137. void SetLaunchingEnabled(bool enabled);
  138. void SetProjectBuilding(bool isBuilding);
  139. void SetProjectExporting(bool isExporting);
  140. void HideContextualLabelButtonWidgets();
  141. QMenu* CreateProjectMenu();
  142. EngineInfo m_engineInfo;
  143. ProjectInfo m_projectInfo;
  144. LabelButton* m_projectImageLabel = nullptr;
  145. QPushButton* m_projectMenuButton = nullptr;
  146. QLayout* m_requiresBuildLayout = nullptr;
  147. AzQtComponents::ElidingLabel* m_projectNameLabel = nullptr;
  148. AzQtComponents::ElidingLabel* m_engineNameLabel = nullptr;
  149. QMetaObject::Connection m_actionButtonConnection;
  150. bool m_isProjectBuilding = false;
  151. bool m_isProjectExporting = false;
  152. bool m_canLaunch = true;
  153. ProjectButtonState m_currentState = ProjectButtonState::ReadyToLaunch;
  154. };
  155. } // namespace O3DE::ProjectManager