From d5ae98496ca8abc139c7cf30ccac04dc8cae45ae Mon Sep 17 00:00:00 2001 From: nggieber Date: Tue, 9 Nov 2021 10:26:37 -0800 Subject: [PATCH] Full UI Built for Updating and Uninstalling Gems Signed-off-by: nggieber --- .../Resources/ProjectManager.qss | 46 ++++++++++++++ .../Source/GemCatalog/GemCatalogScreen.cpp | 42 ++++++++++--- .../Source/GemCatalog/GemCatalogScreen.h | 3 + .../Source/GemCatalog/GemInfo.h | 2 +- .../Source/GemCatalog/GemInspector.cpp | 32 +++++++++- .../Source/GemCatalog/GemInspector.h | 9 ++- .../Source/GemCatalog/GemUninstallDialog.cpp | 60 +++++++++++++++++++ .../Source/GemCatalog/GemUninstallDialog.h | 25 ++++++++ .../Source/GemCatalog/GemUpdateDialog.cpp | 60 +++++++++++++++++++ .../Source/GemCatalog/GemUpdateDialog.h | 25 ++++++++ .../project_manager_files.cmake | 4 ++ 11 files changed, 297 insertions(+), 11 deletions(-) create mode 100644 Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.cpp create mode 100644 Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.h create mode 100644 Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp create mode 100644 Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.h diff --git a/Code/Tools/ProjectManager/Resources/ProjectManager.qss b/Code/Tools/ProjectManager/Resources/ProjectManager.qss index d3ec066be7..426f409581 100644 --- a/Code/Tools/ProjectManager/Resources/ProjectManager.qss +++ b/Code/Tools/ProjectManager/Resources/ProjectManager.qss @@ -563,6 +563,52 @@ QProgressBar::chunk { margin-top:5px; } +#gemCatalogUpdateGemButton, +#gemCatalogUninstallGemButton +{ + qproperty-flat: true; + min-height:24px; + max-height:24px; + border-radius: 3px; + text-align:center; + font-size:12px; + font-weight:600; +} + +#gemCatalogUpdateGemButton { + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #888888, stop: 1.0 #555555); +} +#gemCatalogUpdateGemButton:hover { + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #999999, stop: 1.0 #666666); +} +#gemCatalogUpdateGemButton:pressed { + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #555555, stop: 1.0 #777777); +} + +#footer > #gemCatalogUninstallGemButton, +#gemCatalogUninstallGemButton { + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #E32C27, stop: 1.0 #951D21); +} +#footer > #gemCatalogUninstallGemButton:hover, +#gemCatalogUninstallGemButton:hover { + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #FD3129, stop: 1.0 #AF2221); +} +#footer > #gemCatalogUninstallGemButton:pressed, +#gemCatalogUninstallGemButton:pressed { + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + 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/GemCatalog/GemCatalogScreen.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp index 1a3dc03230..1395dce764 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp @@ -12,7 +12,10 @@ #include #include #include +#include +#include #include + #include #include #include @@ -55,6 +58,8 @@ namespace O3DE::ProjectManager m_gemInspector->setFixedWidth(240); connect(m_gemInspector, &GemInspector::TagClicked, this, &GemCatalogScreen::SelectGem); + connect(m_gemInspector, &GemInspector::UpdateGem, this, &GemCatalogScreen::UpdateGem); + connect(m_gemInspector, &GemInspector::UninstallGem, this, &GemCatalogScreen::UninstallGem); QWidget* filterWidget = new QWidget(this); filterWidget->setFixedWidth(240); @@ -104,9 +109,10 @@ namespace O3DE::ProjectManager // Select the first entry after everything got correctly sized QTimer::singleShot(200, [=]{ - QModelIndex firstModelIndex = m_gemListView->model()->index(0,0); - m_gemListView->selectionModel()->select(firstModelIndex, QItemSelectionModel::ClearAndSelect); - }); + QModelIndex firstModelIndex = m_gemModel->index(0, 0); // m_gemListView->model()->index(0,0); + //m_gemListView->selectionModel()->select(firstModelIndex, QItemSelectionModel::ClearAndSelect); + m_gemModel->GetSelectionModel()->select(firstModelIndex, QItemSelectionModel::ClearAndSelect); + }); } void GemCatalogScreen::OnAddGemClicked() @@ -170,7 +176,7 @@ namespace O3DE::ProjectManager notification = GemModel::GetDisplayName(modelIndex); if (numChangedDependencies > 0) { - notification += " " + tr("and") + " "; + notification += tr(" and "); } if (added && GemModel::GetDownloadStatus(modelIndex) == GemInfo::DownloadStatus::NotDownloaded) { @@ -178,15 +184,15 @@ namespace O3DE::ProjectManager } } - if (numChangedDependencies == 1 ) + if (numChangedDependencies == 1) { - notification += "1 Gem " + tr("dependency"); + notification += tr("1 Gem dependency"); } else if (numChangedDependencies > 1) { - notification += QString("%1 Gem ").arg(numChangedDependencies) + tr("dependencies"); + notification += tr("%1 Gem %2").arg(QString(numChangedDependencies), tr("dependencies")); } - notification += " " + (added ? tr("activated") : tr("deactivated")); + notification += (added ? tr(" activated") : tr(" deactivated")); AzQtComponents::ToastConfiguration toastConfiguration(AzQtComponents::ToastType::Custom, notification, ""); toastConfiguration.m_customIconImage = ":/gem.svg"; @@ -210,6 +216,26 @@ namespace O3DE::ProjectManager m_gemListView->scrollTo(proxyIndex); } + void GemCatalogScreen::UpdateGem(const QModelIndex& modelIndex) + { + const QString selectedGemName = m_gemModel->GetDisplayName(modelIndex); + GemUpdateDialog* confirmUpdateDialog = new GemUpdateDialog(selectedGemName, this); + if (confirmUpdateDialog->exec() == QDialog::Accepted) + { + // Update Gem + } + } + + void GemCatalogScreen::UninstallGem(const QModelIndex& modelIndex) + { + const QString selectedGemName = m_gemModel->GetDisplayName(modelIndex); + GemUninstallDialog* confirmUninstallDialog = new GemUninstallDialog(selectedGemName, this); + if (confirmUninstallDialog->exec() == QDialog::Accepted) + { + // Uninstall Gem + } + } + void GemCatalogScreen::hideEvent(QHideEvent* event) { ScreenWidget::hideEvent(event); diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.h b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.h index 55fbb1befc..5a5a782254 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.h +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.h @@ -49,6 +49,8 @@ namespace O3DE::ProjectManager void OnGemStatusChanged(const QString& gemName, uint32_t numChangedDependencies); void OnAddGemClicked(); void SelectGem(const QString& gemName); + void UpdateGem(const QModelIndex& modelIndex); + void UninstallGem(const QModelIndex& modelIndex); protected: void hideEvent(QHideEvent* event) override; @@ -62,6 +64,7 @@ namespace O3DE::ProjectManager private: void FillModel(const QString& projectPath); + QModelIndex GetCurrentlySelectedGem(); AZStd::unique_ptr m_notificationsView; diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h b/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h index 12cce5a4ea..bef9f6cd99 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h @@ -57,7 +57,7 @@ namespace O3DE::ProjectManager UnknownDownloadStatus = -1, NotDownloaded, Downloading, - Downloaded, + Downloaded }; static QString GetDownloadStatusString(DownloadStatus status); diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.cpp index b0b8cca29a..7b6947c040 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace O3DE::ProjectManager { @@ -70,6 +71,8 @@ namespace O3DE::ProjectManager void GemInspector::Update(const QModelIndex& modelIndex) { + m_curModelIndex = modelIndex; + if (!modelIndex.isValid()) { m_mainWidget->hide(); @@ -122,6 +125,18 @@ namespace O3DE::ProjectManager m_lastUpdatedLabel->setText(tr("Last Updated: %1").arg(m_model->GetLastUpdated(modelIndex))); m_binarySizeLabel->setText(tr("Binary Size: %1 KB").arg(m_model->GetBinarySizeInKB(modelIndex))); + // Update and Uninstall buttons + if (m_model->GetGemOrigin(modelIndex) == GemInfo::Remote && m_model->GetDownloadStatus(modelIndex) == GemInfo::Downloaded) + { + m_updateGemButton->show(); + m_uninstallGemButton->show(); + } + else + { + m_updateGemButton->hide(); + m_uninstallGemButton->hide(); + } + m_mainWidget->adjustSize(); m_mainWidget->show(); } @@ -222,7 +237,7 @@ namespace O3DE::ProjectManager // Depending gems m_dependingGems = new GemsSubWidget(); - connect(m_dependingGems, &GemsSubWidget::TagClicked, this, [=](const QString& tag){ emit TagClicked(tag); }); + connect(m_dependingGems, &GemsSubWidget::TagClicked, this, [this](const QString& tag){ emit TagClicked(tag); }); m_mainLayout->addWidget(m_dependingGems); m_mainLayout->addSpacing(20); @@ -233,5 +248,20 @@ namespace O3DE::ProjectManager m_versionLabel = CreateStyledLabel(m_mainLayout, s_baseFontSize, s_textColor); m_lastUpdatedLabel = CreateStyledLabel(m_mainLayout, s_baseFontSize, s_textColor); m_binarySizeLabel = CreateStyledLabel(m_mainLayout, s_baseFontSize, s_textColor); + + m_mainLayout->addSpacing(20); + + // Update and Uninstall buttons + m_updateGemButton = new QPushButton(tr("Update Gem")); + m_updateGemButton->setObjectName("gemCatalogUpdateGemButton"); + m_mainLayout->addWidget(m_updateGemButton); + connect(m_updateGemButton, &QPushButton::clicked, this , [this]{ emit UpdateGem(m_curModelIndex); }); + + m_mainLayout->addSpacing(10); + + m_uninstallGemButton = new QPushButton(tr("Uninstall Gem")); + m_uninstallGemButton->setObjectName("gemCatalogUninstallGemButton"); + m_mainLayout->addWidget(m_uninstallGemButton); + connect(m_uninstallGemButton, &QPushButton::clicked, this , [this]{ emit UninstallGem(m_curModelIndex); }); } } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.h b/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.h index c6548527ab..4fb2375d6b 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.h +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemInspector.h @@ -16,11 +16,12 @@ #include #include -#include #endif QT_FORWARD_DECLARE_CLASS(QVBoxLayout) QT_FORWARD_DECLARE_CLASS(QLabel) +QT_FORWARD_DECLARE_CLASS(QSpacerItem) +QT_FORWARD_DECLARE_CLASS(QPushButton) namespace O3DE::ProjectManager { @@ -45,6 +46,8 @@ namespace O3DE::ProjectManager signals: void TagClicked(const QString& tag); + void UpdateGem(const QModelIndex& modelIndex); + void UninstallGem(const QModelIndex& modelIndex); private slots: void OnSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); @@ -55,6 +58,7 @@ namespace O3DE::ProjectManager GemModel* m_model = nullptr; QWidget* m_mainWidget = nullptr; QVBoxLayout* m_mainLayout = nullptr; + QModelIndex m_curModelIndex; // General info (top) section QLabel* m_nameLabel = nullptr; @@ -77,5 +81,8 @@ namespace O3DE::ProjectManager QLabel* m_versionLabel = nullptr; QLabel* m_lastUpdatedLabel = nullptr; QLabel* m_binarySizeLabel = nullptr; + + QPushButton* m_updateGemButton = nullptr; + QPushButton* m_uninstallGemButton = nullptr; }; } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.cpp new file mode 100644 index 0000000000..6838741417 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.cpp @@ -0,0 +1,60 @@ +/* + * 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 + +namespace O3DE::ProjectManager +{ + GemUninstallDialog::GemUninstallDialog(const QString& gemName, QWidget* parent) + : QDialog(parent) + { + setWindowTitle(tr("Uninstall Remote Gem")); + setObjectName("GemUninstallDialog"); + setAttribute(Qt::WA_DeleteOnClose); + setModal(true); + + QVBoxLayout* layout = new QVBoxLayout(); + layout->setMargin(30); + layout->setAlignment(Qt::AlignTop); + setLayout(layout); + + // Body + QLabel* subTitleLabel = new QLabel(tr("Are you sure you want to uninstall %1?").arg(gemName)); + subTitleLabel->setObjectName("gemCatalogDialogSubTitle"); + layout->addWidget(subTitleLabel); + + layout->addSpacing(10); + + QLabel* bodyLabel = new QLabel(tr("The Gem and its related files will be uninstalled. This does not affect the Gem’s repository. " + "You can reinstall this Gem from the Catalog, but its contents may be subject to change.")); + bodyLabel->setWordWrap(true); + bodyLabel->setFixedWidth(440); + layout->addWidget(bodyLabel); + + layout->addSpacing(60); + + // Buttons + QDialogButtonBox* dialogButtons = new QDialogButtonBox(); + dialogButtons->setObjectName("footer"); + layout->addWidget(dialogButtons); + + QPushButton* cancelButton = dialogButtons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole); + cancelButton->setProperty("secondary", true); + QPushButton* uninstallButton = dialogButtons->addButton(tr("Uninstall Gem"), QDialogButtonBox::ApplyRole); + uninstallButton->setObjectName("gemCatalogUninstallGemButton"); + + connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject); + connect(uninstallButton, &QPushButton::clicked, this, &QDialog::accept); + } +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.h b/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.h new file mode 100644 index 0000000000..9e3f4c3f3b --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemUninstallDialog.h @@ -0,0 +1,25 @@ +/* + * 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 GemUninstallDialog + : public QDialog + { + Q_OBJECT // AUTOMOC + public: + explicit GemUninstallDialog(const QString& gemName, QWidget *parent = nullptr); + ~GemUninstallDialog() = default; + }; +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp new file mode 100644 index 0000000000..8d8490ab40 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.cpp @@ -0,0 +1,60 @@ +/* + * 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 + +namespace O3DE::ProjectManager +{ + GemUpdateDialog::GemUpdateDialog(const QString& gemName, QWidget* parent) + : QDialog(parent) + { + setWindowTitle(tr("Update Remote Gem")); + setObjectName("GemUpdateDialog"); + setAttribute(Qt::WA_DeleteOnClose); + setModal(true); + + QVBoxLayout* layout = new QVBoxLayout(); + layout->setMargin(30); + layout->setAlignment(Qt::AlignTop); + setLayout(layout); + + // Body + QLabel* subTitleLabel = new QLabel(tr("Update to the latest version of %1?").arg(gemName)); + subTitleLabel->setObjectName("gemCatalogDialogSubTitle"); + layout->addWidget(subTitleLabel); + + layout->addSpacing(10); + + QLabel* bodyLabel = new QLabel(tr("The latest version of this Gem may not be compatible with your engine. " + "Updating this Gem will remove any local changes made to this Gem, " + "and may remove old features that are in use.")); + bodyLabel->setWordWrap(true); + bodyLabel->setFixedWidth(440); + layout->addWidget(bodyLabel); + + layout->addSpacing(60); + + // Buttons + QDialogButtonBox* dialogButtons = new QDialogButtonBox(); + dialogButtons->setObjectName("footer"); + layout->addWidget(dialogButtons); + + QPushButton* cancelButton = dialogButtons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole); + cancelButton->setProperty("secondary", true); + QPushButton* updateButton = dialogButtons->addButton(tr("Update Gem"), QDialogButtonBox::ApplyRole); + + connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject); + connect(updateButton, &QPushButton::clicked, this, &QDialog::accept); + } +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.h b/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.h new file mode 100644 index 0000000000..1a2813d1a2 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemUpdateDialog.h @@ -0,0 +1,25 @@ +/* + * 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 GemUpdateDialog + : public QDialog + { + Q_OBJECT // AUTOMOC + public : + explicit GemUpdateDialog(const QString& gemName, QWidget* parent = nullptr); + ~GemUpdateDialog() = default; + }; +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/project_manager_files.cmake b/Code/Tools/ProjectManager/project_manager_files.cmake index e2e35717f6..fcfae2f336 100644 --- a/Code/Tools/ProjectManager/project_manager_files.cmake +++ b/Code/Tools/ProjectManager/project_manager_files.cmake @@ -96,6 +96,10 @@ set(FILES Source/GemCatalog/GemListHeaderWidget.cpp Source/GemCatalog/GemModel.h Source/GemCatalog/GemModel.cpp + Source/GemCatalog/GemUninstallDialog.h + Source/GemCatalog/GemUninstallDialog.cpp + Source/GemCatalog/GemUpdateDialog.h + Source/GemCatalog/GemUpdateDialog.cpp Source/GemCatalog/GemDependenciesDialog.h Source/GemCatalog/GemDependenciesDialog.cpp Source/GemCatalog/GemRequirementDialog.h