diff --git a/Code/Tools/ProjectManager/Resources/ProjectManager.qss b/Code/Tools/ProjectManager/Resources/ProjectManager.qss index 426f409581..1fc808b72c 100644 --- a/Code/Tools/ProjectManager/Resources/ProjectManager.qss +++ b/Code/Tools/ProjectManager/Resources/ProjectManager.qss @@ -232,6 +232,11 @@ QTabBar::tab:focus { stop: 0 #555555, stop: 1.0 #777777); } +#dialogSubTitle { + font-size:14px; + font-weight:600; +} + #horizontalSeparatingLine { color: #666666; } @@ -604,11 +609,6 @@ QProgressBar::chunk { stop: 0 #951D1F, stop: 1.0 #C92724); } -#gemCatalogDialogSubTitle { - font-size:14px; - font-weight:600; -} - /************** Filter Tag widget **************/ #FilterTagWidgetTextLabel { diff --git a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp new file mode 100644 index 0000000000..122a5cbf5a --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace O3DE::ProjectManager +{ + ExternalLinkDialog::ExternalLinkDialog(const QUrl& url, QWidget* parent) + : QDialog(parent) + { + setWindowTitle(tr("Leaving O3DE")); + setObjectName("ExternalLinkDialog"); + setAttribute(Qt::WA_DeleteOnClose); + setModal(true); + + QHBoxLayout* hLayout = new QHBoxLayout(); + hLayout->setMargin(30); + hLayout->setAlignment(Qt::AlignTop); + setLayout(hLayout); + + QVBoxLayout* warningLayout = new QVBoxLayout(); + warningLayout->setMargin(0); + warningLayout->setAlignment(Qt::AlignTop); + hLayout->addLayout(warningLayout); + + QLabel* warningIcon = new QLabel(this); + warningIcon->setPixmap(QIcon(":/Warning.svg").pixmap(32, 32)); + warningLayout->addWidget(warningIcon); + + warningLayout->addStretch(); + + QVBoxLayout* layout = new QVBoxLayout(); + layout->setMargin(0); + layout->setAlignment(Qt::AlignTop); + hLayout->addLayout(layout); + + // Body + QLabel* subTitleLabel = new QLabel(tr("You are about to leave O3DE Project Manager to visit an external link.")); + subTitleLabel->setObjectName("dialogSubTitle"); + layout->addWidget(subTitleLabel); + + layout->addSpacing(10); + + QLabel* bodyLabel = new QLabel(tr("If you trust this source, you can proceed to this link, or click \"Cancel\" to return.")); + layout->addWidget(bodyLabel); + + // Don't actually set linkUrl we are just using LinkLabel superficially here + LinkLabel* linkLabel = new LinkLabel(url.toString(), {}, 12); + layout->addWidget(linkLabel); + + layout->addSpacing(40); + + QCheckBox* skipDialogCheckbox = new QCheckBox(tr("Do not show this again")); + layout->addWidget(skipDialogCheckbox); + connect(skipDialogCheckbox, &QCheckBox::stateChanged, this, &ExternalLinkDialog::SetSkipDialogSetting); + + // Buttons + QDialogButtonBox* dialogButtons = new QDialogButtonBox(); + dialogButtons->setObjectName("footer"); + layout->addWidget(dialogButtons); + + QPushButton* cancelButton = dialogButtons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole); + cancelButton->setProperty("secondary", true); + QPushButton* acceptButton = dialogButtons->addButton(tr("Proceed"), QDialogButtonBox::ApplyRole); + + connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject); + connect(acceptButton, &QPushButton::clicked, this, &QDialog::accept); + } + + void ExternalLinkDialog::SetSkipDialogSetting(bool state) + { + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if (settingsRegistry) + { + QString settingsKey = GetExternalLinkWarningKey(); + settingsRegistry->Set(settingsKey.toStdString().c_str(), state); + SaveProjectManagerSettings(); + } + } +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.h b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.h new file mode 100644 index 0000000000..45d391e64e --- /dev/null +++ b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#if !defined(Q_MOC_RUN) +#include +#endif + +namespace O3DE::ProjectManager +{ + class ExternalLinkDialog + : public QDialog + { + Q_OBJECT // AUTOMOC + public: + explicit ExternalLinkDialog(const QUrl& url, QWidget* parent = nullptr); + ~ExternalLinkDialog() = default; + + private slots: + void SetSkipDialogSetting(bool state); + }; +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.cpp index 1408e29b6d..679d9c576f 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.cpp @@ -31,7 +31,7 @@ namespace O3DE::ProjectManager // Body QLabel* subTitleLabel = new QLabel(tr("Are you sure you want to uninstall %1?").arg(gemName)); - subTitleLabel->setObjectName("gemCatalogDialogSubTitle"); + subTitleLabel->setObjectName("dialogSubTitle"); layout->addWidget(subTitleLabel); layout->addSpacing(10); diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp index 82d205aab5..d973dd3749 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp @@ -32,7 +32,7 @@ namespace O3DE::ProjectManager // Body QLabel* subTitleLabel = new QLabel(tr("%1 to the latest version of %2?").arg( updateAvaliable ? tr("Update") : tr("Force update"), gemName)); - subTitleLabel->setObjectName("gemCatalogDialogSubTitle"); + subTitleLabel->setObjectName("dialogSubTitle"); layout->addWidget(subTitleLabel); layout->addSpacing(10); diff --git a/Code/Tools/ProjectManager/Source/LinkWidget.cpp b/Code/Tools/ProjectManager/Source/LinkWidget.cpp index 9c8c78ed37..f25e38db67 100644 --- a/Code/Tools/ProjectManager/Source/LinkWidget.cpp +++ b/Code/Tools/ProjectManager/Source/LinkWidget.cpp @@ -7,6 +7,11 @@ */ #include +#include +#include + +#include + #include #include #include @@ -26,7 +31,29 @@ namespace O3DE::ProjectManager { if (m_url.isValid()) { - QDesktopServices::openUrl(m_url); + // Check if user request not to be shown external link warning dialog + bool skipDialog = false; + auto settingsRegistry = AZ::SettingsRegistry::Get(); + + if (settingsRegistry) + { + QString settingsKey = GetExternalLinkWarningKey(); + settingsRegistry->Get(skipDialog, settingsKey.toStdString().c_str()); + } + + if (!skipDialog) + { + // Style does not apply if LinkLabel is parent so use parentWidget as parent instead + ExternalLinkDialog* linkDialog = new ExternalLinkDialog(m_url.toString(), parentWidget()); + if (linkDialog->exec() == QDialog::Accepted) + { + QDesktopServices::openUrl(m_url); + } + } + else + { + QDesktopServices::openUrl(m_url); + } } emit clicked(); diff --git a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp index 3049a6d70c..66480aab3e 100644 --- a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp @@ -6,7 +6,7 @@ * */ -#include "ProjectManagerSettings.h" +#include #include #include @@ -51,4 +51,9 @@ namespace O3DE::ProjectManager { return QString("%1/Projects/%2/BuiltSuccessfully").arg(ProjectManagerKeyPrefix).arg(projectName); } + + QString GetExternalLinkWarningKey() + { + return QString("%1/SkipExternalLinkWarning").arg(ProjectManagerKeyPrefix); + } } diff --git a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h index 3454909062..93cfbc5ceb 100644 --- a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h +++ b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h @@ -18,4 +18,5 @@ namespace O3DE::ProjectManager void SaveProjectManagerSettings(); QString GetProjectBuiltSuccessfullyKey(const QString& projectName); + QString GetExternalLinkWarningKey(); } diff --git a/Code/Tools/ProjectManager/project_manager_files.cmake b/Code/Tools/ProjectManager/project_manager_files.cmake index 43c11edacc..468e8dcbc5 100644 --- a/Code/Tools/ProjectManager/project_manager_files.cmake +++ b/Code/Tools/ProjectManager/project_manager_files.cmake @@ -78,6 +78,8 @@ set(FILES Source/TagWidget.cpp Source/TemplateButtonWidget.h Source/TemplateButtonWidget.cpp + Source/ExternalLinkDialog.h + Source/ExternalLinkDialog.cpp Source/GemCatalog/GemCatalogHeaderWidget.h Source/GemCatalog/GemCatalogHeaderWidget.cpp Source/GemCatalog/GemCatalogScreen.h