ExternalLinkDialog.cpp 3.2 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 <ExternalLinkDialog.h>
  9. #include <LinkWidget.h>
  10. #include <SettingsInterface.h>
  11. #include <QDialogButtonBox>
  12. #include <QLabel>
  13. #include <QPushButton>
  14. #include <QHBoxLayout>
  15. #include <QVBoxLayout>
  16. #include <QVariant>
  17. #include <QIcon>
  18. #include <QCheckBox>
  19. namespace O3DE::ProjectManager
  20. {
  21. ExternalLinkDialog::ExternalLinkDialog(const QUrl& url, QWidget* parent)
  22. : QDialog(parent)
  23. {
  24. setWindowTitle(tr("Leaving O3DE"));
  25. setObjectName("ExternalLinkDialog");
  26. setAttribute(Qt::WA_DeleteOnClose);
  27. setModal(true);
  28. QHBoxLayout* hLayout = new QHBoxLayout();
  29. hLayout->setMargin(30);
  30. hLayout->setAlignment(Qt::AlignTop);
  31. setLayout(hLayout);
  32. QVBoxLayout* warningLayout = new QVBoxLayout();
  33. warningLayout->setMargin(0);
  34. warningLayout->setAlignment(Qt::AlignTop);
  35. hLayout->addLayout(warningLayout);
  36. QLabel* warningIcon = new QLabel(this);
  37. warningIcon->setPixmap(QIcon(":/Warning.svg").pixmap(32, 32));
  38. warningLayout->addWidget(warningIcon);
  39. warningLayout->addStretch();
  40. QVBoxLayout* layout = new QVBoxLayout();
  41. layout->setMargin(0);
  42. layout->setAlignment(Qt::AlignTop);
  43. hLayout->addLayout(layout);
  44. // Body
  45. QLabel* subTitleLabel = new QLabel(tr("You are about to leave O3DE Project Manager to visit an external link."));
  46. subTitleLabel->setObjectName("dialogSubTitle");
  47. layout->addWidget(subTitleLabel);
  48. layout->addSpacing(10);
  49. QLabel* bodyLabel = new QLabel(tr("If you trust this source, you can proceed to this link, or click \"Cancel\" to return."));
  50. layout->addWidget(bodyLabel);
  51. QLabel* linkLabel = new QLabel(url.toString());
  52. linkLabel->setObjectName("externalLink");
  53. linkLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
  54. layout->addWidget(linkLabel);
  55. QCheckBox* skipDialogCheckbox = new QCheckBox(tr("Do not show this again"));
  56. layout->addWidget(skipDialogCheckbox);
  57. connect(skipDialogCheckbox, &QCheckBox::stateChanged, this, &ExternalLinkDialog::SetSkipDialogSetting);
  58. // Buttons
  59. QDialogButtonBox* dialogButtons = new QDialogButtonBox();
  60. dialogButtons->setObjectName("footer");
  61. layout->addWidget(dialogButtons);
  62. QPushButton* cancelButton = dialogButtons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole);
  63. cancelButton->setProperty("secondary", true);
  64. QPushButton* acceptButton = dialogButtons->addButton(tr("Proceed"), QDialogButtonBox::ApplyRole);
  65. acceptButton->setProperty("primary", true);
  66. connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
  67. connect(acceptButton, &QPushButton::clicked, this, &QDialog::accept);
  68. }
  69. void ExternalLinkDialog::SetSkipDialogSetting(bool state)
  70. {
  71. SettingsInterface::Get()->Set(ISettings::ExternalLinkWarningKey, state);
  72. }
  73. } // namespace O3DE::ProjectManager