/dev/Code/Sandbox/Editor/AboutDialog.cpp

https://github.com/aws/lumberyard · C++ · 90 lines · 57 code · 19 blank · 14 comment · 2 complexity · 8783d4a4bcef00333f406283478e2bfd MD5 · raw file

  1. /*
  2. * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
  3. * its licensors.
  4. *
  5. * For complete copyright and license terms please see the LICENSE at the root of this
  6. * distribution (the "License"). All use of this software is governed by the License,
  7. * or, if provided, by the license below or the license accompanying this file. Do not
  8. * remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. *
  11. */
  12. // Original file Copyright Crytek GMBH or its affiliates, used under license.
  13. #include "StdAfx.h"
  14. #include "AboutDialog.h"
  15. #include <ui_AboutDialog.h>
  16. #include <QLabel>
  17. #include <QDesktopServices>
  18. #include <QPainter>
  19. #include <QPixmap>
  20. #include <QMouseEvent>
  21. #include <QDesktopServices>
  22. #include <QFont>
  23. #include <AzCore/Casting/numeric_cast.h>
  24. CAboutDialog::CAboutDialog(QString versionText, QString richTextCopyrightNotice, QWidget* pParent /*=NULL*/)
  25. : QDialog(pParent)
  26. , m_ui(new Ui::CAboutDialog)
  27. {
  28. m_ui->setupUi(this);
  29. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  30. connect(m_ui->m_transparentAgreement, &QLabel::linkActivated, this, &CAboutDialog::OnCustomerAgreement);
  31. connect(m_ui->m_transparentNotice, &QLabel::linkActivated, this, &CAboutDialog::OnPrivacyNotice);
  32. m_ui->m_transparentTrademarks->setText(versionText);
  33. m_ui->m_transparentAllRightReserved->setObjectName("copyrightNotice");
  34. m_ui->m_transparentAllRightReserved->setTextFormat(Qt::RichText);
  35. m_ui->m_transparentAllRightReserved->setText(richTextCopyrightNotice);
  36. m_ui->m_transparentAgreement->setObjectName("link");
  37. m_ui->m_transparentNotice->setObjectName("link");
  38. setStyleSheet( "CAboutDialog > QLabel#copyrightNotice { color: #AAAAAA; font-size: 9px; }\
  39. CAboutDialog > QLabel#link { text-decoration: underline; color: #00A1C9; }");
  40. m_backgroundImage = QPixmap(QStringLiteral(":/StartupLogoDialog/splashscreen_startergame.png"));
  41. // Prevent re-sizing
  42. setFixedSize(m_enforcedWidth, aznumeric_cast<int>(m_enforcedWidth * m_enforcedRatio));
  43. }
  44. CAboutDialog::~CAboutDialog()
  45. {
  46. }
  47. void CAboutDialog::paintEvent(QPaintEvent*)
  48. {
  49. QPainter painter(this);
  50. // Enforce the sizing to avoid stretching the image
  51. QRect drawTarget = rect();
  52. drawTarget.setHeight( aznumeric_cast<int>( drawTarget.width() * m_enforcedRatio ) );
  53. painter.drawPixmap(drawTarget, m_backgroundImage);
  54. }
  55. void CAboutDialog::mouseReleaseEvent(QMouseEvent* event)
  56. {
  57. if (event->button() == Qt::LeftButton)
  58. {
  59. accept();
  60. }
  61. QDialog::mouseReleaseEvent(event);
  62. }
  63. void CAboutDialog::OnCustomerAgreement()
  64. {
  65. QDesktopServices::openUrl(QUrl(QStringLiteral("http://aws.amazon.com/agreement/")));
  66. }
  67. void CAboutDialog::OnPrivacyNotice()
  68. {
  69. QDesktopServices::openUrl(QUrl(QStringLiteral("http://aws.amazon.com/privacy/")));
  70. }
  71. #include <AboutDialog.moc>