ProjectButtonWidget.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. NotDownloaded,
  81. Downloading,
  82. DownloadingBuildQueued,
  83. DownloadFailed
  84. };
  85. class ProjectButton
  86. : public QFrame
  87. {
  88. Q_OBJECT
  89. public:
  90. ProjectButton(const ProjectInfo& projectInfo, const EngineInfo& engineInfo, QWidget* parent = nullptr);
  91. ~ProjectButton();
  92. const ProjectInfo& GetProjectInfo() const;
  93. void SetEngine(const EngineInfo& engine);
  94. void SetProject(const ProjectInfo& project);
  95. void SetState(ProjectButtonState state);
  96. const ProjectButtonState GetState() const
  97. {
  98. return m_currentState;
  99. }
  100. void SetProjectButtonAction(const QString& text, AZStd::function<void()> lambda);
  101. void SetBuildLogsLink(const QUrl& logUrl);
  102. void SetProgressBarPercentage(const float percent);
  103. void SetContextualText(const QString& text);
  104. LabelButton* GetLabelButton();
  105. public slots:
  106. void ShowLogs();
  107. signals:
  108. void OpenProject(const QString& projectName);
  109. void EditProject(const QString& projectName);
  110. void EditProjectGems(const QString& projectName);
  111. void CopyProject(const ProjectInfo& projectInfo);
  112. void RemoveProject(const QString& projectName);
  113. void DeleteProject(const QString& projectName);
  114. void BuildProject(const ProjectInfo& projectInfo, bool skipDialogBox = false);
  115. void OpenCMakeGUI(const ProjectInfo& projectInfo);
  116. void OpenAndroidProjectGenerator(const QString& projectPath);
  117. private:
  118. void enterEvent(QEvent* event) override;
  119. void leaveEvent(QEvent* event) override;
  120. void ShowReadyState();
  121. void ShowLaunchingState();
  122. void ShowBuildRequiredState();
  123. void ShowBuildingState();
  124. void ShowBuildFailedState();
  125. void ShowNotDownloadedState();
  126. void ShowDownloadingState();
  127. void ResetButtonWidgets();
  128. void ShowMessage(const QString& message = {}, const QString& submessage = {});
  129. void ShowWarning(const QString& warning = {});
  130. void ShowBuildButton();
  131. void SetLaunchingEnabled(bool enabled);
  132. void SetProjectBuilding(bool isBuilding);
  133. void HideContextualLabelButtonWidgets();
  134. QMenu* CreateProjectMenu();
  135. EngineInfo m_engineInfo;
  136. ProjectInfo m_projectInfo;
  137. LabelButton* m_projectImageLabel = nullptr;
  138. QPushButton* m_projectMenuButton = nullptr;
  139. QLayout* m_requiresBuildLayout = nullptr;
  140. AzQtComponents::ElidingLabel* m_projectNameLabel = nullptr;
  141. AzQtComponents::ElidingLabel* m_engineNameLabel = nullptr;
  142. QMetaObject::Connection m_actionButtonConnection;
  143. bool m_isProjectBuilding = false;
  144. bool m_canLaunch = true;
  145. ProjectButtonState m_currentState = ProjectButtonState::ReadyToLaunch;
  146. };
  147. } // namespace O3DE::ProjectManager