EngineScreenCtrl.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 <EngineScreenCtrl.h>
  9. #include <GemRepo/GemRepoScreen.h>
  10. #include <EngineSettingsScreen.h>
  11. #include <QVBoxLayout>
  12. #include <QHBoxLayout>
  13. #include <QTabWidget>
  14. namespace O3DE::ProjectManager
  15. {
  16. EngineScreenCtrl::EngineScreenCtrl(QWidget* parent)
  17. : ScreenWidget(parent)
  18. {
  19. QVBoxLayout* vLayout = new QVBoxLayout();
  20. vLayout->setContentsMargins(0, 0, 0, 0);
  21. QFrame* topBarFrameWidget = new QFrame(this);
  22. topBarFrameWidget->setObjectName("engineTopFrame");
  23. QHBoxLayout* topBarHLayout = new QHBoxLayout();
  24. topBarHLayout->setContentsMargins(0, 0, 0, 0);
  25. topBarFrameWidget->setLayout(topBarHLayout);
  26. m_tabWidget = new QTabWidget();
  27. m_tabWidget->setObjectName("engineTab");
  28. m_tabWidget->tabBar()->setObjectName("engineTabBar");
  29. m_tabWidget->tabBar()->setFocusPolicy(Qt::TabFocus);
  30. m_engineSettingsScreen = new EngineSettingsScreen();
  31. m_gemRepoScreen = new GemRepoScreen(parent);
  32. m_tabWidget->addTab(m_engineSettingsScreen, tr("General"));
  33. m_tabWidget->addTab(m_gemRepoScreen, tr("Remote Sources"));
  34. // when tab changes, notify the current screen so it can refresh
  35. connect(m_tabWidget, &QTabWidget::currentChanged, this, &EngineScreenCtrl::TabChanged);
  36. topBarHLayout->addWidget(m_tabWidget);
  37. vLayout->addWidget(topBarFrameWidget);
  38. setLayout(vLayout);
  39. }
  40. void EngineScreenCtrl::TabChanged([[maybe_unused]] int index)
  41. {
  42. NotifyCurrentScreen();
  43. }
  44. ProjectManagerScreen EngineScreenCtrl::GetScreenEnum()
  45. {
  46. return ProjectManagerScreen::UpdateProject;
  47. }
  48. QString EngineScreenCtrl::GetTabText()
  49. {
  50. return tr("Engine");
  51. }
  52. bool EngineScreenCtrl::IsTab()
  53. {
  54. return true;
  55. }
  56. bool EngineScreenCtrl::ContainsScreen(ProjectManagerScreen screen)
  57. {
  58. return screen == m_engineSettingsScreen->GetScreenEnum() || screen == m_gemRepoScreen->GetScreenEnum();
  59. }
  60. void EngineScreenCtrl::NotifyCurrentScreen()
  61. {
  62. ScreenWidget* screen = static_cast<ScreenWidget*>(m_tabWidget->currentWidget());
  63. if (screen)
  64. {
  65. screen->NotifyCurrentScreen();
  66. }
  67. }
  68. void EngineScreenCtrl::GoToScreen(ProjectManagerScreen screen)
  69. {
  70. if (screen == m_engineSettingsScreen->GetScreenEnum())
  71. {
  72. m_tabWidget->setCurrentWidget(m_engineSettingsScreen);
  73. m_engineSettingsScreen->NotifyCurrentScreen();
  74. }
  75. else if (screen == m_gemRepoScreen->GetScreenEnum())
  76. {
  77. m_tabWidget->setCurrentWidget(m_gemRepoScreen);
  78. m_gemRepoScreen->NotifyCurrentScreen();
  79. }
  80. }
  81. } // namespace O3DE::ProjectManager