DownloadRemoteTemplateDialog.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 <DownloadRemoteTemplateDialog.h>
  9. #include <FormFolderBrowseEditWidget.h>
  10. #include <TextOverflowWidget.h>
  11. #include <AzQtComponents/Components/Widgets/CheckBox.h>
  12. #include <ProjectUtils.h>
  13. #include <PythonBindingsInterface.h>
  14. #include <QVBoxLayout>
  15. #include <QGridLayout>
  16. #include <QLabel>
  17. #include <QLineEdit>
  18. #include <QCheckBox>
  19. #include <QDialogButtonBox>
  20. #include <QPushButton>
  21. #include <QDir>
  22. #include <QTimer>
  23. namespace O3DE::ProjectManager
  24. {
  25. DownloadRemoteTemplateDialog::DownloadRemoteTemplateDialog(const ProjectTemplateInfo& projectTemplate, QWidget* parent)
  26. : QDialog(parent)
  27. {
  28. setWindowTitle(tr("Download a remote template"));
  29. setModal(true);
  30. setObjectName("downloadRemoteTempalteDialog");
  31. setFixedSize(QSize(760, 390));
  32. QVBoxLayout* vLayout = new QVBoxLayout();
  33. vLayout->setContentsMargins(30, 30, 25, 10);
  34. vLayout->setSpacing(0);
  35. vLayout->setAlignment(Qt::AlignTop);
  36. setLayout(vLayout);
  37. QLabel* warningLabel = new QLabel(tr("\"%1\" needs to be downloaded from the repository first, before using it as your template.").arg(projectTemplate.m_displayName), this);
  38. warningLabel->setObjectName("remoteTemplateDialogDownloadTemplateLabel");
  39. warningLabel->setAlignment(Qt::AlignLeft);
  40. vLayout->addWidget(warningLabel);
  41. vLayout->addSpacing(20);
  42. QFrame* hLine = new QFrame();
  43. hLine->setFrameShape(QFrame::HLine);
  44. hLine->setObjectName("horizontalSeparatingLine");
  45. vLayout->addWidget(hLine);
  46. vLayout->addSpacing(20);
  47. m_downloadTemplateLabel = new QLabel(tr("Choose the location for the template"), this);
  48. m_downloadTemplateLabel->setObjectName("remoteTemplateDialogDownloadTemplateLabel");
  49. m_downloadTemplateLabel->setAlignment(Qt::AlignLeft);
  50. vLayout->addWidget(m_downloadTemplateLabel);
  51. m_installPath = new FormFolderBrowseEditWidget(tr("Local template directory"));
  52. m_installPath->setMinimumSize(QSize(600, 0));
  53. m_installPath->lineEdit()->setText(
  54. QDir::toNativeSeparators(ProjectUtils::GetDefaultTemplatePath() + "/" + projectTemplate.m_name));
  55. vLayout->addWidget(m_installPath);
  56. vLayout->addSpacing(20);
  57. QGridLayout* extraInfoGridLayout = new QGridLayout(this);
  58. extraInfoGridLayout->setContentsMargins(0, 0, 0, 0);
  59. extraInfoGridLayout->setHorizontalSpacing(5);
  60. extraInfoGridLayout->setVerticalSpacing(15);
  61. extraInfoGridLayout->setAlignment(Qt::AlignLeft);
  62. m_requirementsTitleLabel = new QLabel(tr("Template Requirements"), this);
  63. m_requirementsTitleLabel->setObjectName("remoteTemplateDialogRequirementsTitleLabel");
  64. m_requirementsTitleLabel->setAlignment(Qt::AlignLeft);
  65. extraInfoGridLayout->addWidget(m_requirementsTitleLabel, 0, 0);
  66. m_licensesTitleLabel = new QLabel(tr("Licenses"), this);
  67. m_licensesTitleLabel->setObjectName("remoteTemplateDialogLicensesTitleLabel");
  68. m_licensesTitleLabel->setAlignment(Qt::AlignLeft);
  69. extraInfoGridLayout->addWidget(m_licensesTitleLabel, 0, 1);
  70. extraInfoGridLayout->setVerticalSpacing(15);
  71. m_requirementsContentLabel = new TextOverflowLabel(tr("Requirements"), projectTemplate.m_requirements);
  72. m_requirementsContentLabel->setObjectName("remoteTemplateDialogRequirementsContentLabel");
  73. m_requirementsContentLabel->setWordWrap(true);
  74. m_requirementsContentLabel->setAlignment(Qt::AlignLeft);
  75. m_requirementsContentLabel->setFixedWidth(350);
  76. extraInfoGridLayout->addWidget(m_requirementsContentLabel, 1, 0);
  77. m_licensesContentLabel = new TextOverflowLabel(tr("Licenses"), projectTemplate.m_license);
  78. m_licensesContentLabel->setObjectName("remoteTemplateDialogLicensesContentLabel");
  79. m_licensesContentLabel->setWordWrap(true);
  80. m_licensesContentLabel->setAlignment(Qt::AlignLeft);
  81. m_licensesContentLabel->setFixedWidth(350);
  82. extraInfoGridLayout->addWidget(m_licensesContentLabel, 1, 1);
  83. vLayout->addLayout(extraInfoGridLayout);
  84. vLayout->addStretch();
  85. m_dialogButtons = new QDialogButtonBox();
  86. m_dialogButtons->setObjectName("footer");
  87. vLayout->addWidget(m_dialogButtons);
  88. QPushButton* cancelButton = m_dialogButtons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole);
  89. cancelButton->setProperty("secondary", true);
  90. m_applyButton = m_dialogButtons->addButton(tr("Download"), QDialogButtonBox::ApplyRole);
  91. m_applyButton->setProperty("primary", true);
  92. connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
  93. connect(m_applyButton, &QPushButton::clicked, this, &QDialog::accept);
  94. }
  95. QString DownloadRemoteTemplateDialog::GetInstallPath()
  96. {
  97. return m_installPath->lineEdit()->text();
  98. }
  99. } // namespace O3DE::ProjectManager