LogPanel.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/std/smart_ptr/unique_ptr.h>
  11. #include <AzToolsFramework/UI/Logging/LogPanel_Panel.h>
  12. #include <AzToolsFramework/UI/Logging/LogControl.h>
  13. #include <AzToolsFramework/UI/UICore/TargetSelectorButton.hxx>
  14. #include <AzQtComponents/Components/StyledDockWidget.h>
  15. #include <Debugger/Bus.h>
  16. #include <ScriptCanvas/Core/NodeBus.h>
  17. #include <ScriptCanvas/Bus/GraphBus.h>
  18. #endif
  19. namespace AzQtComponents
  20. {
  21. class TabWidget;
  22. }
  23. namespace Ui
  24. {
  25. class LogPanel;
  26. }
  27. namespace ScriptCanvasEditor
  28. {
  29. namespace Widget
  30. {
  31. class LogPanel
  32. : public AzToolsFramework::LogPanel::BaseLogPanel
  33. , ScriptCanvasEditor::GeneralGraphEventBus::Handler
  34. {
  35. Q_OBJECT
  36. public:
  37. LogPanel(QWidget* parent = nullptr);
  38. ~LogPanel() override;
  39. protected:
  40. void OnBuildGameEntity(const AZStd::string&, const AZ::EntityId& editGraphId, const ScriptCanvas::ScriptCanvasId& scriptCanvasId) override;
  41. QWidget* CreateTab(const AzToolsFramework::LogPanel::TabSettings& settings) override;
  42. ScriptCanvas::ScriptCanvasId m_scriptCanvasId;
  43. AzQtComponents::TabWidget* pTabWidget;
  44. };
  45. class LogPanelWidget
  46. : public AzQtComponents::StyledDockWidget
  47. {
  48. Q_OBJECT
  49. public:
  50. LogPanelWidget(QWidget* parent = nullptr);
  51. AZStd::unique_ptr<Ui::LogPanel> ui;
  52. };
  53. class LogTab
  54. : public AzToolsFramework::LogPanel::BaseLogView
  55. , ScriptCanvas::LogNotificationBus::Handler
  56. {
  57. Q_OBJECT;
  58. public:
  59. AZ_CLASS_ALLOCATOR(LogTab, AZ::SystemAllocator);
  60. LogTab(QWidget* pParent, const ScriptCanvas::ScriptCanvasId& scriptCanvasId, const AzToolsFramework::LogPanel::TabSettings& in_settings);
  61. ~LogTab() override;
  62. void LogMessage(const AZStd::string& message) override;
  63. private:
  64. AZStd::queue<AzToolsFramework::Logging::LogLine> m_bufferedLines;
  65. AZStd::atomic_bool m_alreadyQueuedDrainMessage; // we also only drain the queue at the end so that we do bulk inserts instead of one at a time.
  66. void CommitAddedLines();
  67. private Q_SLOTS:
  68. void DrainMessages();
  69. virtual void Clear();
  70. };
  71. }
  72. }