SceneSettingsCard.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 <AzCore/Debug/TraceMessageBus.h>
  11. #include <AzCore/std/smart_ptr/shared_ptr.h>
  12. #include <AzCore/std/string/string.h>
  13. #include <AzToolsFramework/Debug/TraceContextMultiStackHandler.h>
  14. #include <AzQtComponents/Components/StyledDetailsTableModel.h>
  15. #include <AzQtComponents/Components/Widgets/Card.h>
  16. #include <AzQtComponents/Components/Widgets/CardHeader.h>
  17. #include <SceneAPI/SceneUI/SceneUIConfiguration.h>
  18. #include <QMap>
  19. #include <QPair>
  20. #include <QString>
  21. #include <QVector>
  22. #endif
  23. class QSvgWidget;
  24. namespace AzQtComponents
  25. {
  26. class StyledDetailsTableView;
  27. class TableView;
  28. }
  29. namespace AZ
  30. {
  31. namespace SceneAPI
  32. {
  33. namespace SceneUI
  34. {
  35. class ProcessingHandler;
  36. }
  37. }
  38. }
  39. namespace AzToolsFramework
  40. {
  41. namespace Logging
  42. {
  43. class LogEntry;
  44. }
  45. }
  46. class QPushButton;
  47. class SceneSettingsCardHeader : public AzQtComponents::CardHeader
  48. {
  49. Q_OBJECT
  50. public:
  51. SceneSettingsCardHeader(QWidget* parent = nullptr);
  52. void SetCanClose(bool canClose);
  53. private:
  54. void triggerCloseButton();
  55. QPushButton* m_closeButton = nullptr;
  56. QSvgWidget* m_busySpinner = nullptr;
  57. friend class SceneSettingsCard;
  58. };
  59. class SCENE_UI_API SceneSettingsCard : public AzQtComponents::Card, public AZ::Debug::TraceMessageBus::Handler
  60. {
  61. Q_OBJECT
  62. public:
  63. enum class Layout
  64. {
  65. Loading,
  66. Resetting,
  67. Exporting
  68. };
  69. SceneSettingsCard(AZ::Uuid traceTag, QString fileTracked, Layout layout, QWidget* parent = nullptr);
  70. ~SceneSettingsCard();
  71. void SetAndStartProcessingHandler(const AZStd::shared_ptr<AZ::SceneAPI::SceneUI::ProcessingHandler>& handler);
  72. bool OnPrintf(const char* window, const char* message) override;
  73. bool OnError(const char* window, const char* message) override;
  74. bool OnWarning(const char* window, const char* message) override;
  75. bool OnAssert(const char* message) override;
  76. enum class State
  77. {
  78. Loading,
  79. Processing,
  80. Done,
  81. };
  82. void SetState(State newState);
  83. public Q_SLOTS:
  84. void AddLogEntry(const AzToolsFramework::Logging::LogEntry& logEntry);
  85. void OnSetStatusMessage(const AZStd::string& message);
  86. void OnProcessingComplete();
  87. signals:
  88. void ProcessingCompleted();
  89. private:
  90. enum class CompletionState
  91. {
  92. Success,
  93. Warning,
  94. Error,
  95. Failure
  96. };
  97. bool ShouldProcessMessage();
  98. void UpdateCompletionState(CompletionState newState);
  99. void CopyTraceContext(AzQtComponents::StyledDetailsTableModel::TableEntry& entry) const;
  100. QString GetTimeNowAsString();
  101. void ShowLogContextMenu(const QPoint& pos);
  102. void AddLogTableEntry(AzQtComponents::StyledDetailsTableModel::TableEntry& entry);
  103. QMap<int, QVector<QPair<QString, QString>>> m_additionalLogDetails;
  104. AzToolsFramework::Debug::TraceContextMultiStackHandler m_traceStackHandler;
  105. AZ::Uuid m_traceTag;
  106. AzQtComponents::StyledDetailsTableModel* m_reportModel = nullptr;
  107. AzQtComponents::TableView* m_reportView = nullptr;
  108. AZStd::shared_ptr<AZ::SceneAPI::SceneUI::ProcessingHandler> m_targetHandler;
  109. SceneSettingsCardHeader* m_settingsHeader = nullptr;
  110. CompletionState m_completionState = CompletionState::Success;
  111. State m_sceneCardState = State::Loading;
  112. QString m_fileTracked;
  113. int m_warningCount = 0;
  114. int m_errorCount = 0;
  115. };