3
0

LoggingWindow.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #include <QMenu>
  9. #include <QAction>
  10. #include <AzQtComponents/Components/Widgets/SegmentBar.h>
  11. #include <Editor/View/Widgets/LoggingPanel/LoggingWindow.h>
  12. #include <Editor/View/Widgets/LoggingPanel/ui_LoggingWindow.h>
  13. namespace ScriptCanvasEditor
  14. {
  15. //////////////////
  16. // LoggingWindow
  17. //////////////////
  18. LoggingWindow::LoggingWindow(QWidget* parentWidget)
  19. : AzQtComponents::StyledDockWidget(parentWidget)
  20. , m_ui(new Ui::LoggingWindow)
  21. {
  22. m_ui->setupUi(this);
  23. // Hack to hide the close button on the first tab. Since we always want it open.
  24. m_ui->tabWidget->setTabsClosable(true);
  25. m_ui->tabWidget->tabBar()->setTabButton(0, QTabBar::ButtonPosition::RightSide, nullptr);
  26. m_ui->tabWidget->tabBar()->setTabButton(0, QTabBar::ButtonPosition::LeftSide, nullptr);
  27. m_ui->segmentWidget->addTab(new QWidget(m_ui->segmentWidget), QStringLiteral("Entities"));
  28. m_ui->segmentWidget->addTab(new QWidget(m_ui->segmentWidget), QStringLiteral("Graphs"));
  29. connect(m_ui->segmentWidget, &AzQtComponents::SegmentControl::currentChanged, [this](int newIndex) {
  30. m_ui->stackedWidget->setCurrentIndex(newIndex);
  31. });
  32. QObject::connect(m_ui->tabWidget, &QTabWidget::currentChanged, this, &LoggingWindow::OnActiveTabChanged);
  33. AzQtComponents::TabWidget::applySecondaryStyle(m_ui->tabWidget, false);
  34. m_entityPageIndex = m_ui->stackedWidget->indexOf(m_ui->entitiesPage);
  35. m_graphPageIndex = m_ui->stackedWidget->indexOf(m_ui->graphsPage);
  36. OnActiveTabChanged(m_ui->tabWidget->currentIndex());
  37. PivotOnEntities();
  38. }
  39. LoggingWindow::~LoggingWindow()
  40. {
  41. }
  42. void LoggingWindow::OnActiveTabChanged([[maybe_unused]] int index)
  43. {
  44. LoggingWindowSession* windowSession = qobject_cast<LoggingWindowSession*>(m_ui->tabWidget->currentWidget());
  45. if (windowSession)
  46. {
  47. m_activeDataId = windowSession->GetDataId();
  48. }
  49. m_ui->entityPivotWidget->SwitchDataSource(m_activeDataId);
  50. m_ui->graphPivotWidget->SwitchDataSource(m_activeDataId);
  51. }
  52. void LoggingWindow::PivotOnEntities()
  53. {
  54. m_ui->stackedWidget->setCurrentIndex(m_ui->stackedWidget->indexOf(m_ui->entitiesPage));
  55. }
  56. void LoggingWindow::PivotOnGraphs()
  57. {
  58. m_ui->stackedWidget->setCurrentIndex(m_ui->stackedWidget->indexOf(m_ui->graphsPage));
  59. }
  60. PivotTreeWidget* LoggingWindow::GetActivePivotWidget() const
  61. {
  62. if (m_ui->stackedWidget->currentIndex() == m_entityPageIndex)
  63. {
  64. return m_ui->entityPivotWidget;
  65. }
  66. return nullptr;
  67. }
  68. #include <Editor/View/Widgets/LoggingPanel/moc_LoggingWindow.cpp>
  69. }