GemInspector.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 <GemCatalog/GemInfo.h>
  11. #include <GemCatalog/GemModel.h>
  12. #include <GemsSubWidget.h>
  13. #include <LinkWidget.h>
  14. #include <QItemSelection>
  15. #include <QScrollArea>
  16. #include <QThread>
  17. #include <QDir>
  18. #endif
  19. QT_FORWARD_DECLARE_CLASS(QVBoxLayout)
  20. QT_FORWARD_DECLARE_CLASS(QLabel)
  21. QT_FORWARD_DECLARE_CLASS(QSpacerItem)
  22. QT_FORWARD_DECLARE_CLASS(QPushButton)
  23. QT_FORWARD_DECLARE_CLASS(QComboBox)
  24. QT_FORWARD_DECLARE_CLASS(QThread)
  25. QT_FORWARD_DECLARE_CLASS(QDir)
  26. namespace O3DE::ProjectManager
  27. {
  28. class GemInspectorWorker : public QObject
  29. {
  30. Q_OBJECT
  31. public:
  32. explicit GemInspectorWorker();
  33. ~GemInspectorWorker() = default;
  34. signals:
  35. void Done(QString size);
  36. public slots:
  37. void SetDir(QString dir);
  38. private:
  39. void GetDirSize(QDir dir, quint64& sizeTotal);
  40. };
  41. class GemInspector
  42. : public QScrollArea
  43. {
  44. Q_OBJECT
  45. public:
  46. explicit GemInspector(GemModel* model, QWidget* parent, bool readOnly = false);
  47. ~GemInspector();
  48. void Update(const QPersistentModelIndex& modelIndex, const QString& version = "", const QString& path = "");
  49. static QLabel* CreateStyledLabel(QLayout* layout, int fontSize, const QString& colorCodeString);
  50. // Fonts
  51. inline constexpr static int s_baseFontSize = 12;
  52. // Colors
  53. inline constexpr static const char* s_headerColor = "#FFFFFF";
  54. inline constexpr static const char* s_textColor = "#DDDDDD";
  55. signals:
  56. void TagClicked(const Tag& tag);
  57. void UpdateGem(const QModelIndex& modelIndex, const QString& version = "", const QString& path = "");
  58. void UninstallGem(const QModelIndex& modelIndex, const QString& path = "");
  59. void EditGem(const QModelIndex& modelIndex, const QString& path = "");
  60. void DownloadGem(const QModelIndex& modelIndex, const QString& version = "", const QString& path = "");
  61. void ShowToastNotification(const QString& notification);
  62. private slots:
  63. void OnSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
  64. void OnVersionChanged(int index);
  65. void OnDirSizeSet(QString size);
  66. void OnCopyDownloadLinkClicked();
  67. private:
  68. void InitMainWidget();
  69. QString GetVersion() const;
  70. QString GetVersionPath() const;
  71. bool m_readOnly = false;
  72. GemModel* m_model = nullptr;
  73. QWidget* m_mainWidget = nullptr;
  74. QVBoxLayout* m_mainLayout = nullptr;
  75. QPersistentModelIndex m_curModelIndex;
  76. QThread m_workerThread;
  77. GemInspectorWorker m_worker;
  78. // General info (top) section
  79. QLabel* m_nameLabel = nullptr;
  80. QLabel* m_creatorLabel = nullptr;
  81. QLabel* m_summaryLabel = nullptr;
  82. QLabel* m_licenseLabel = nullptr;
  83. LinkLabel* m_licenseLinkLabel = nullptr;
  84. LinkLabel* m_directoryLinkLabel = nullptr;
  85. LinkLabel* m_documentationLinkLabel = nullptr;
  86. // Requirements
  87. QLabel* m_requirementsTextLabel = nullptr;
  88. // Compatibility
  89. QLabel* m_compatibilityTextLabel = nullptr;
  90. // Depending gems
  91. GemsSubWidget* m_dependingGems = nullptr;
  92. QSpacerItem* m_dependingGemsSpacer = nullptr;
  93. // Additional information
  94. QComboBox* m_versionComboBox = nullptr;
  95. QWidget* m_versionWidget = nullptr;
  96. QLabel* m_versionLabel = nullptr;
  97. QLabel* m_enginesTitleLabel = nullptr;
  98. QLabel* m_enginesLabel = nullptr;
  99. QLabel* m_lastUpdatedLabel = nullptr;
  100. QLabel* m_binarySizeLabel = nullptr;
  101. LinkLabel* m_copyDownloadLinkLabel = nullptr;
  102. QPushButton* m_updateVersionButton = nullptr;
  103. QPushButton* m_updateGemButton = nullptr;
  104. QPushButton* m_editGemButton = nullptr;
  105. QPushButton* m_uninstallGemButton = nullptr;
  106. QPushButton* m_downloadGemButton = nullptr;
  107. };
  108. } // namespace O3DE::ProjectManager