GemUpdateDialog.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 <GemCatalog/GemUpdateDialog.h>
  9. #include <QDialogButtonBox>
  10. #include <QLabel>
  11. #include <QPushButton>
  12. #include <QVBoxLayout>
  13. #include <QVariant>
  14. namespace O3DE::ProjectManager
  15. {
  16. GemUpdateDialog::GemUpdateDialog(const QString& gemName, bool updateAvaliable, QWidget* parent)
  17. : QDialog(parent)
  18. {
  19. setWindowTitle(tr("Update Remote Gem"));
  20. setObjectName("GemUpdateDialog");
  21. setAttribute(Qt::WA_DeleteOnClose);
  22. setModal(true);
  23. QVBoxLayout* layout = new QVBoxLayout();
  24. layout->setMargin(30);
  25. layout->setAlignment(Qt::AlignTop);
  26. setLayout(layout);
  27. // Body
  28. QLabel* subTitleLabel = new QLabel(tr("%1 to the latest version of %2?").arg(
  29. updateAvaliable ? tr("Update") : tr("Force update"), gemName));
  30. subTitleLabel->setObjectName("dialogSubTitle");
  31. layout->addWidget(subTitleLabel);
  32. layout->addSpacing(10);
  33. QLabel* bodyLabel = new QLabel(tr("%1The latest version of this Gem may not be compatible with your engine. "
  34. "Updating this Gem will remove any local changes made to this Gem, "
  35. "and may remove old features that are in use.").arg(
  36. updateAvaliable ? "" : tr("No update detected for Gem. "
  37. "This will force a re-download of the gem. ")));
  38. bodyLabel->setWordWrap(true);
  39. bodyLabel->setFixedSize(QSize(440, 80));
  40. layout->addWidget(bodyLabel);
  41. layout->addSpacing(40);
  42. // Buttons
  43. QDialogButtonBox* dialogButtons = new QDialogButtonBox();
  44. dialogButtons->setObjectName("footer");
  45. layout->addWidget(dialogButtons);
  46. QPushButton* cancelButton = dialogButtons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole);
  47. cancelButton->setProperty("secondary", true);
  48. QPushButton* updateButton =
  49. dialogButtons->addButton(tr("%1Update Gem").arg(updateAvaliable ? "" : tr("Force ")), QDialogButtonBox::ApplyRole);
  50. updateButton->setProperty("primary", true);
  51. connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
  52. connect(updateButton, &QPushButton::clicked, this, &QDialog::accept);
  53. }
  54. } // namespace O3DE::ProjectManager