StartupLogoDialog.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 "StartupLogoDialog.h"
  9. #include "EditorDefs.h"
  10. #include <AzQtComponents/Utilities/PixmapScaleUtilities.h>
  11. // Qt
  12. #include <QPainter>
  13. #include <QThread>
  14. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  15. #include <ui_StartupLogoDialog.h>
  16. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  17. CStartupLogoDialog* CStartupLogoDialog::s_pLogoWindow = nullptr;
  18. CStartupLogoDialog::CStartupLogoDialog(
  19. DialogType dialogType, QString versionText, QString richTextCopyrightNotice, QWidget* pParent /*=nullptr*/)
  20. : QDialog(pParent)
  21. , m_ui(new Ui::StartupLogoDialog)
  22. , m_dialogType(dialogType)
  23. {
  24. m_ui->setupUi(this);
  25. s_pLogoWindow = this;
  26. setFixedSize(QSize(EnforcedWidth, EnforcedHeight));
  27. setAttribute(Qt::WA_TranslucentBackground, true);
  28. // Prepare background image
  29. m_backgroundImage = AzQtComponents::ScalePixmapForScreenDpi(
  30. QPixmap(QStringLiteral(":/StartupLogoDialog/splashscreen_background.png")),
  31. screen(),
  32. QSize(EnforcedWidth, EnforcedHeight),
  33. Qt::IgnoreAspectRatio,
  34. Qt::SmoothTransformation);
  35. m_ui->m_transparentAgreement->setObjectName("link");
  36. switch (m_dialogType)
  37. {
  38. case Loading:
  39. setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
  40. m_ui->m_pages->setCurrentIndex(0);
  41. setWindowTitle(tr("Starting Open 3D Engine Editor"));
  42. m_ui->m_TransparentConfidential->setObjectName("copyrightNotice");
  43. m_ui->m_TransparentConfidential->setTextFormat(Qt::RichText);
  44. m_ui->m_TransparentConfidential->setText(richTextCopyrightNotice);
  45. m_ui->m_TransparentVersion->setText(versionText);
  46. setStyleSheet("QLabel { background: transparent; color: 'white' }\
  47. QLabel#copyrightNotice { color: #AAAAAA; font-size: 9px; } ");
  48. break;
  49. case About:
  50. setWindowFlags(Qt::FramelessWindowHint | Qt::Popup | Qt::NoDropShadowWindowHint);
  51. m_ui->m_pages->setCurrentIndex(1);
  52. m_ui->m_transparentAllRightReserved->setObjectName("copyrightNotice");
  53. m_ui->m_transparentAllRightReserved->setTextFormat(Qt::RichText);
  54. m_ui->m_transparentAllRightReserved->setText(richTextCopyrightNotice);
  55. m_ui->m_transparentTrademarks->setText(versionText);
  56. setStyleSheet("QLabel#copyrightNotice { color: #AAAAAA; font-size: 9px; }\
  57. QLabel#link { text-decoration: underline; color: #94D2FF; }");
  58. break;
  59. }
  60. // Draw the Open 3D Engine logo from svg
  61. m_ui->m_logo->load(QStringLiteral(":/StartupLogoDialog/o3de_logo.svg"));
  62. }
  63. CStartupLogoDialog::~CStartupLogoDialog()
  64. {
  65. s_pLogoWindow = nullptr;
  66. }
  67. void CStartupLogoDialog::focusOutEvent([[maybe_unused]] QFocusEvent*)
  68. {
  69. if (m_dialogType == About)
  70. {
  71. accept();
  72. }
  73. }
  74. void CStartupLogoDialog::SetText(const char* text)
  75. {
  76. if (s_pLogoWindow)
  77. {
  78. s_pLogoWindow->SetInfoText(text);
  79. }
  80. }
  81. void CStartupLogoDialog::SetInfoText(const char* text)
  82. {
  83. QMetaObject::invokeMethod(
  84. this,
  85. [this, text = QString(text)]()
  86. {
  87. m_ui->m_TransparentText->setText(text);
  88. });
  89. }
  90. void CStartupLogoDialog::paintEvent(QPaintEvent*)
  91. {
  92. QPainter painter(this);
  93. painter.drawPixmap(rect(), m_backgroundImage);
  94. }
  95. #include <moc_StartupLogoDialog.cpp>