GemCatalogScreen.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 <ScreenWidget.h>
  11. #include <ScreensCtrl.h>
  12. #include <AzCore/std/smart_ptr/unique_ptr.h>
  13. #include <AzToolsFramework/UI/Notifications/ToastNotificationsView.h>
  14. #include <GemCatalog/GemInfo.h>
  15. #include <QSet>
  16. #include <QString>
  17. #endif
  18. QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
  19. QT_FORWARD_DECLARE_CLASS(QStackedWidget)
  20. namespace O3DE::ProjectManager
  21. {
  22. QT_FORWARD_DECLARE_CLASS(GemCatalogHeaderWidget)
  23. QT_FORWARD_DECLARE_CLASS(GemFilterWidget)
  24. QT_FORWARD_DECLARE_CLASS(GemListView)
  25. QT_FORWARD_DECLARE_CLASS(GemInspector)
  26. QT_FORWARD_DECLARE_CLASS(GemModel)
  27. QT_FORWARD_DECLARE_CLASS(GemSortFilterProxyModel)
  28. QT_FORWARD_DECLARE_CLASS(DownloadController)
  29. class GemCatalogScreen
  30. : public ScreenWidget
  31. {
  32. public:
  33. explicit GemCatalogScreen(DownloadController* downloadController, bool readOnly = false, QWidget* parent = nullptr);
  34. ~GemCatalogScreen() = default;
  35. ProjectManagerScreen GetScreenEnum() override;
  36. void ReinitForProject(const QString& projectPath);
  37. QString GetTabText() override;
  38. bool IsTab() override;
  39. void NotifyCurrentScreen() override;
  40. void AddToGemModel(const GemInfo& gemInfo);
  41. GemModel* GetGemModel() const { return m_gemModel; }
  42. DownloadController* GetDownloadController() const { return m_downloadController; }
  43. public slots:
  44. void ShowStandardToastNotification(const QString& notification);
  45. void OnGemStatusChanged(const QString& gemName, uint32_t numChangedDependencies);
  46. void OnDependencyGemStatusChanged(const QString& gemName);
  47. void OnAddGemClicked();
  48. void SelectGem(const QString& gemName);
  49. void OnGemDownloadResult(const QString& gemName, bool succeeded = true);
  50. void Refresh(bool refreshRemoteRepos = false);
  51. void UpdateGem(const QModelIndex& modelIndex, const QString& version, const QString& path);
  52. void UninstallGem(const QModelIndex& modelIndex, const QString& path);
  53. void DownloadGem(const QModelIndex& modelIndex, const QString& version, const QString& path);
  54. void HandleGemCreated(const GemInfo& gemInfo);
  55. void HandleGemEdited(const GemInfo& newGemInfo);
  56. void NotifyProjectRemoved(const QString& projectPath);
  57. protected:
  58. void hideEvent(QHideEvent* event) override;
  59. void showEvent(QShowEvent* event) override;
  60. void resizeEvent(QResizeEvent* event) override;
  61. void moveEvent(QMoveEvent* event) override;
  62. virtual void SetUpScreensControl(QWidget* parent);
  63. GemModel* m_gemModel = nullptr;
  64. QSet<QString> m_gemsToRegisterWithProject;
  65. ScreensCtrl* m_screensControl = nullptr;
  66. private slots:
  67. void HandleOpenGemRepo();
  68. void HandleCreateGem();
  69. void HandleEditGem(const QModelIndex& currentModelIndex, const QString& path);
  70. void UpdateAndShowGemCart(QWidget* cartWidget);
  71. void ShowInspector();
  72. private:
  73. enum RightPanelWidgetOrder
  74. {
  75. Inspector = 0,
  76. Cart
  77. };
  78. void FillModel(const QString& projectPath);
  79. AZStd::unique_ptr<AzToolsFramework::ToastNotificationsView> m_notificationsView;
  80. GemListView* m_gemListView = nullptr;
  81. QStackedWidget* m_rightPanelStack = nullptr;
  82. GemInspector* m_gemInspector = nullptr;
  83. GemCatalogHeaderWidget* m_headerWidget = nullptr;
  84. GemSortFilterProxyModel* m_proxyModel = nullptr;
  85. QVBoxLayout* m_filterWidgetLayout = nullptr;
  86. GemFilterWidget* m_filterWidget = nullptr;
  87. DownloadController* m_downloadController = nullptr;
  88. bool m_notificationsEnabled = true;
  89. QString m_projectPath;
  90. bool m_readOnly;
  91. bool m_needRefresh = false;
  92. QModelIndex m_curEditedIndex;
  93. };
  94. } // namespace O3DE::ProjectManager