Prechádzať zdrojové kódy

Tidying code, adding DownloadController check

Signed-off-by: AMZN-Phil <[email protected]>
AMZN-Phil 2 rokov pred
rodič
commit
5e6c40b16a

+ 0 - 2
Code/Tools/ProjectManager/Source/AddRemoteTemplateDialog.h

@@ -14,8 +14,6 @@
 #include <QDialog>
 #endif
 
-QT_FORWARD_DECLARE_CLASS(QLabel)
-QT_FORWARD_DECLARE_CLASS(QCheckBox)
 QT_FORWARD_DECLARE_CLASS(QDialogButtonBox)
 QT_FORWARD_DECLARE_CLASS(QPushButton)
 QT_FORWARD_DECLARE_CLASS(QTimer)

+ 0 - 2
Code/Tools/ProjectManager/Source/DownloadRemoteTemplateDialog.cpp

@@ -71,7 +71,6 @@ namespace O3DE::ProjectManager
         extraInfoGridLayout->setHorizontalSpacing(5);
         extraInfoGridLayout->setVerticalSpacing(15);
         extraInfoGridLayout->setAlignment(Qt::AlignLeft);
-        
 
         m_requirementsTitleLabel = new QLabel(tr("Template Requirements"), this);
         m_requirementsTitleLabel->setObjectName("remoteTemplateDialogRequirementsTitleLabel");
@@ -101,7 +100,6 @@ namespace O3DE::ProjectManager
         extraInfoGridLayout->addWidget(m_licensesContentLabel, 1, 1);
 
         vLayout->addLayout(extraInfoGridLayout);
-
         vLayout->addStretch();
 
         m_dialogButtons = new QDialogButtonBox();

+ 0 - 2
Code/Tools/ProjectManager/Source/DownloadRemoteTemplateDialog.h

@@ -15,10 +15,8 @@
 #endif
 
 QT_FORWARD_DECLARE_CLASS(QLabel)
-QT_FORWARD_DECLARE_CLASS(QCheckBox)
 QT_FORWARD_DECLARE_CLASS(QDialogButtonBox)
 QT_FORWARD_DECLARE_CLASS(QPushButton)
-QT_FORWARD_DECLARE_CLASS(QTimer)
 
 namespace O3DE::ProjectManager
 {

+ 3 - 2
Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.cpp

@@ -101,7 +101,7 @@ namespace O3DE::ProjectManager
                             emit OnTemplateSelectionChanged(/*oldIndex=*/oldIndex, /*newIndex=*/m_selectedTemplateIndex);
                         }
                     }
-                    if (button && button->property(k_addRemoteTemplateProperty).isValid())
+                    else if (button && button->property(k_addRemoteTemplateProperty).isValid())
                     {
                         AddRemoteTemplateDialog* addRemoteTemplateDialog = new AddRemoteTemplateDialog(this);
                         addRemoteTemplateDialog->exec();
@@ -343,6 +343,7 @@ namespace O3DE::ProjectManager
 
     void NewProjectSettingsScreen::StartTemplateDownload(const QString& templateName)
     {
+        AZ_Assert(m_downloadController, "DownloadController must exist.");
         m_downloadController->AddObjectDownload(templateName, DownloadController::DownloadObjectType::Template);
         auto foundButton = AZStd::ranges::find_if(
             m_templateButtons,
@@ -364,7 +365,7 @@ namespace O3DE::ProjectManager
         m_templateIncludedGems->Update(templateInfo.m_includedGems);
         m_downloadTemplateButton->setVisible(templateInfo.m_isRemote);
         m_downloadTemplateButton->disconnect();
-        connect(m_downloadTemplateButton, &QPushButton::clicked, this, [=]()
+        connect(m_downloadTemplateButton, &QPushButton::clicked, this, [&, templateInfo]()
                 {
                     DownloadRemoteTemplateDialog* downloadRemoteTemplateDialog = new DownloadRemoteTemplateDialog(templateInfo, this);
                     if (downloadRemoteTemplateDialog->exec() == QDialog::DialogCode::Accepted)

+ 2 - 1
Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.h

@@ -12,6 +12,7 @@
 #include <ProjectTemplateInfo.h>
 #include <DownloadController.h>
 #include <TemplateButtonWidget.h>
+#include <QPointer>
 #include <QVector>
 #endif
 
@@ -70,7 +71,7 @@ namespace O3DE::ProjectManager
         int m_selectedTemplateIndex = -1;
         bool m_userChangedProjectPath = false;
 
-        DownloadController* m_downloadController = nullptr;
+        QPointer<DownloadController> m_downloadController = nullptr;
 
         inline constexpr static int s_spacerSize = 20;
         inline constexpr static int s_templateDetailsContentMargin = 20;