2
0

StartupLogoDialog.cpp 3.4 KB

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