Преглед на файлове

refresh gem catalog when repos updated

Signed-off-by: Alex Peterson <[email protected]>
Alex Peterson преди 2 години
родител
ревизия
b831ed6e51

+ 10 - 0
Code/Tools/ProjectManager/Source/CreateProjectCtrl.cpp

@@ -224,6 +224,11 @@ namespace O3DE::ProjectManager
             if(auto outcome = CurrentScreenIsValid(); outcome.IsSuccess())
             if(auto outcome = CurrentScreenIsValid(); outcome.IsSuccess())
             {
             {
                 m_stack->setCurrentIndex(m_stack->currentIndex() + 1);
                 m_stack->setCurrentIndex(m_stack->currentIndex() + 1);
+                ScreenWidget* currentScreen = static_cast<ScreenWidget*>(m_stack->currentWidget());
+                if (currentScreen)
+                {
+                    currentScreen->NotifyCurrentScreen();
+                }
                 Update();
                 Update();
             }
             }
             else if (!outcome.GetError().isEmpty())
             else if (!outcome.GetError().isEmpty())
@@ -243,6 +248,11 @@ namespace O3DE::ProjectManager
         if (m_stack->currentIndex() > 0)
         if (m_stack->currentIndex() > 0)
         {
         {
             m_stack->setCurrentIndex(m_stack->currentIndex() - 1);
             m_stack->setCurrentIndex(m_stack->currentIndex() - 1);
+            ScreenWidget* currentScreen = static_cast<ScreenWidget*>(m_stack->currentWidget());
+            if (currentScreen)
+            {
+                currentScreen->NotifyCurrentScreen();
+            }
             Update();
             Update();
         }
         }
     }
     }

+ 1 - 1
Code/Tools/ProjectManager/Source/EngineScreenCtrl.cpp

@@ -35,7 +35,7 @@ namespace O3DE::ProjectManager
         m_tabWidget->tabBar()->setFocusPolicy(Qt::TabFocus);
         m_tabWidget->tabBar()->setFocusPolicy(Qt::TabFocus);
 
 
         m_engineSettingsScreen = new EngineSettingsScreen();
         m_engineSettingsScreen = new EngineSettingsScreen();
-        m_gemRepoScreen = new GemRepoScreen();
+        m_gemRepoScreen = new GemRepoScreen(parent);
 
 
         m_tabWidget->addTab(m_engineSettingsScreen, tr("General"));
         m_tabWidget->addTab(m_engineSettingsScreen, tr("General"));
         m_tabWidget->addTab(m_gemRepoScreen, tr("Remote Sources"));
         m_tabWidget->addTab(m_gemRepoScreen, tr("Remote Sources"));

+ 1 - 1
Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.cpp

@@ -538,7 +538,7 @@ namespace O3DE::ProjectManager
         hLayout->addSpacing(16);
         hLayout->addSpacing(16);
 
 
         QMenu* gemMenu = new QMenu(this);
         QMenu* gemMenu = new QMenu(this);
-        gemMenu->addAction( tr("Refresh"), [this]() { emit RefreshGems(); });
+        gemMenu->addAction(tr("Refresh"), [this]() { emit RefreshGems(/*refreshRemoteRepos*/true); });
         gemMenu->addAction( tr("Show Gem Repos"), [this]() { emit OpenGemsRepo(); });
         gemMenu->addAction( tr("Show Gem Repos"), [this]() { emit OpenGemsRepo(); });
         gemMenu->addSeparator();
         gemMenu->addSeparator();
         gemMenu->addAction( tr("Add Existing Gem"), [this]() { emit AddGem(); });
         gemMenu->addAction( tr("Add Existing Gem"), [this]() { emit AddGem(); });

+ 1 - 1
Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogHeaderWidget.h

@@ -109,7 +109,7 @@ namespace O3DE::ProjectManager
         void AddGem();
         void AddGem();
         void CreateGem();
         void CreateGem();
         void OpenGemsRepo();
         void OpenGemsRepo();
-        void RefreshGems();
+        void RefreshGems(bool refreshRemoteRepos);
         void UpdateGemCart(QWidget* gemCart);
         void UpdateGemCart(QWidget* gemCart);
 
 
     protected slots:
     protected slots:

+ 18 - 3
Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.cpp

@@ -19,6 +19,7 @@
 #include <GemCatalog/GemUpdateDialog.h>
 #include <GemCatalog/GemUpdateDialog.h>
 #include <GemCatalog/GemUninstallDialog.h>
 #include <GemCatalog/GemUninstallDialog.h>
 #include <GemCatalog/GemItemDelegate.h>
 #include <GemCatalog/GemItemDelegate.h>
+#include <GemRepo/GemRepoScreen.h>
 #include <DownloadController.h>
 #include <DownloadController.h>
 #include <ProjectUtils.h>
 #include <ProjectUtils.h>
 #include <AdjustableHeaderWidget.h>
 #include <AdjustableHeaderWidget.h>
@@ -79,7 +80,11 @@ namespace O3DE::ProjectManager
         connect(m_headerWidget, &GemCatalogHeaderWidget::UpdateGemCart, this, &GemCatalogScreen::UpdateAndShowGemCart);
         connect(m_headerWidget, &GemCatalogHeaderWidget::UpdateGemCart, this, &GemCatalogScreen::UpdateAndShowGemCart);
         connect(m_downloadController, &DownloadController::Done, this, &GemCatalogScreen::OnGemDownloadResult);
         connect(m_downloadController, &DownloadController::Done, this, &GemCatalogScreen::OnGemDownloadResult);
 
 
-        SetUpScreensControl(parent);
+        ScreensCtrl* screensCtrl = GetScreensCtrl(this);
+        if (screensCtrl)
+        {
+            connect(screensCtrl, &ScreensCtrl::NotifyRemoteContentRefreshed, [this]() { m_needRefresh = true; });
+        }
 
 
         QHBoxLayout* hLayout = new QHBoxLayout();
         QHBoxLayout* hLayout = new QHBoxLayout();
         hLayout->setMargin(0);
         hLayout->setMargin(0);
@@ -194,9 +199,14 @@ namespace O3DE::ProjectManager
             // init the read only catalog the first time it is shown
             // init the read only catalog the first time it is shown
             ReinitForProject(m_projectPath);
             ReinitForProject(m_projectPath);
         }
         }
+        else if (m_needRefresh)
+        {
+            // generally we need to refresh because remote repos were updated
+            m_needRefresh = false;
+            Refresh();
+        }
     }
     }
 
 
-
     void GemCatalogScreen::NotifyProjectRemoved(const QString& projectPath)
     void GemCatalogScreen::NotifyProjectRemoved(const QString& projectPath)
     {
     {
         // Use QFileInfo because the project path might be the project folder
         // Use QFileInfo because the project path might be the project folder
@@ -296,7 +306,7 @@ namespace O3DE::ProjectManager
         }
         }
     }
     }
 
 
-    void GemCatalogScreen::Refresh()
+    void GemCatalogScreen::Refresh(bool refreshRemoteRepos)
     {
     {
         QSet<QPersistentModelIndex> validIndexes;
         QSet<QPersistentModelIndex> validIndexes;
 
 
@@ -306,6 +316,11 @@ namespace O3DE::ProjectManager
             validIndexes = QSet(indexes.cbegin(), indexes.cend());
             validIndexes = QSet(indexes.cbegin(), indexes.cend());
         }
         }
 
 
+        if(refreshRemoteRepos)
+        {
+            PythonBindingsInterface::Get()->RefreshAllGemRepos();
+        }
+
         if (const auto& outcome = PythonBindingsInterface::Get()->GetGemInfosForAllRepos(); outcome.IsSuccess())
         if (const auto& outcome = PythonBindingsInterface::Get()->GetGemInfosForAllRepos(); outcome.IsSuccess())
         {
         {
             const auto& indexes = m_gemModel->AddGems(outcome.GetValue(), /*updateExisting=*/true);
             const auto& indexes = m_gemModel->AddGems(outcome.GetValue(), /*updateExisting=*/true);

+ 2 - 1
Code/Tools/ProjectManager/Source/GemCatalog/GemCatalogScreen.h

@@ -57,7 +57,7 @@ namespace O3DE::ProjectManager
         void OnAddGemClicked();
         void OnAddGemClicked();
         void SelectGem(const QString& gemName);
         void SelectGem(const QString& gemName);
         void OnGemDownloadResult(const QString& gemName, bool succeeded = true);
         void OnGemDownloadResult(const QString& gemName, bool succeeded = true);
-        void Refresh();
+        void Refresh(bool refreshRemoteRepos = false);
         void UpdateGem(const QModelIndex& modelIndex, const QString& version, const QString& path);
         void UpdateGem(const QModelIndex& modelIndex, const QString& version, const QString& path);
         void UninstallGem(const QModelIndex& modelIndex, const QString& path);
         void UninstallGem(const QModelIndex& modelIndex, const QString& path);
         void DownloadGem(const QModelIndex& modelIndex, const QString& version, const QString& path);
         void DownloadGem(const QModelIndex& modelIndex, const QString& version, const QString& path);
@@ -104,6 +104,7 @@ namespace O3DE::ProjectManager
         bool m_notificationsEnabled = true;
         bool m_notificationsEnabled = true;
         QString m_projectPath;
         QString m_projectPath;
         bool m_readOnly;
         bool m_readOnly;
+        bool m_needRefresh = false;
 
 
         QModelIndex m_curEditedIndex;
         QModelIndex m_curEditedIndex;
 
 

+ 1 - 1
Code/Tools/ProjectManager/Source/GemCatalog/GemListHeaderWidget.cpp

@@ -63,7 +63,7 @@ namespace O3DE::ProjectManager
 
 
         QPushButton* refreshButton = new QPushButton();
         QPushButton* refreshButton = new QPushButton();
         refreshButton->setObjectName("RefreshButton");
         refreshButton->setObjectName("RefreshButton");
-        connect( refreshButton, &QPushButton::clicked, [this] { emit OnRefresh(); });
+        connect(refreshButton, &QPushButton::clicked, [this] { emit OnRefresh(/*refreshRemoteRepos*/true); });
         topLayout->addWidget(refreshButton);
         topLayout->addWidget(refreshButton);
 
 
         auto refreshGemCountUI = [=]() {
         auto refreshGemCountUI = [=]() {

+ 2 - 1
Code/Tools/ProjectManager/Source/GemCatalog/GemListHeaderWidget.h

@@ -24,7 +24,8 @@ namespace O3DE::ProjectManager
     public:
     public:
         explicit GemListHeaderWidget(GemSortFilterProxyModel* proxyModel, QWidget* parent = nullptr);
         explicit GemListHeaderWidget(GemSortFilterProxyModel* proxyModel, QWidget* parent = nullptr);
         ~GemListHeaderWidget() = default;
         ~GemListHeaderWidget() = default;
+
     signals:
     signals:
-        void OnRefresh();
+        void OnRefresh(bool refreshRemoteRepos);
     };
     };
 } // namespace O3DE::ProjectManager
 } // namespace O3DE::ProjectManager

+ 13 - 4
Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp

@@ -60,6 +60,12 @@ namespace O3DE::ProjectManager
         m_notificationsView->SetOffset(QPoint(10, 10));
         m_notificationsView->SetOffset(QPoint(10, 10));
         m_notificationsView->SetMaxQueuedNotifications(1);
         m_notificationsView->SetMaxQueuedNotifications(1);
         m_notificationsView->SetRejectDuplicates(false); // we want to show notifications if a user repeats actions
         m_notificationsView->SetRejectDuplicates(false); // we want to show notifications if a user repeats actions
+
+        ScreensCtrl* screensCtrl = GetScreensCtrl(this);
+        if (screensCtrl)
+        {
+            connect(this, &GemRepoScreen::NotifyRemoteContentRefreshed, screensCtrl, &ScreensCtrl::NotifyRemoteContentRefreshed);
+        }
     }
     }
 
 
     void GemRepoScreen::NotifyCurrentScreen()
     void GemRepoScreen::NotifyCurrentScreen()
@@ -67,6 +73,9 @@ namespace O3DE::ProjectManager
         constexpr bool downloadMissingOnly = true;
         constexpr bool downloadMissingOnly = true;
         PythonBindingsInterface::Get()->RefreshAllGemRepos(downloadMissingOnly);
         PythonBindingsInterface::Get()->RefreshAllGemRepos(downloadMissingOnly);
         Reinit();
         Reinit();
+
+        // we might have downloading missing data so make sure to update the GemCatalog
+        emit NotifyRemoteContentRefreshed();
     }
     }
 
 
     void GemRepoScreen::Reinit()
     void GemRepoScreen::Reinit()
@@ -132,7 +141,7 @@ namespace O3DE::ProjectManager
                 ShowStandardToastNotification(tr("Repo added successfully!"));
                 ShowStandardToastNotification(tr("Repo added successfully!"));
 
 
                 Reinit();
                 Reinit();
-                emit OnRefresh();
+                emit NotifyRemoteContentRefreshed();
             }
             }
             else
             else
             {
             {
@@ -160,7 +169,7 @@ namespace O3DE::ProjectManager
                 ShowStandardToastNotification(tr("Repo removed"));
                 ShowStandardToastNotification(tr("Repo removed"));
 
 
                 Reinit();
                 Reinit();
-                emit OnRefresh();
+                emit NotifyRemoteContentRefreshed();
             }
             }
             else
             else
             {
             {
@@ -177,7 +186,7 @@ namespace O3DE::ProjectManager
         constexpr bool downloadMissingOnly = false;
         constexpr bool downloadMissingOnly = false;
         bool refreshResult = PythonBindingsInterface::Get()->RefreshAllGemRepos(downloadMissingOnly);
         bool refreshResult = PythonBindingsInterface::Get()->RefreshAllGemRepos(downloadMissingOnly);
         Reinit();
         Reinit();
-        emit OnRefresh();
+        emit NotifyRemoteContentRefreshed();
 
 
         if (refreshResult)
         if (refreshResult)
         {
         {
@@ -201,7 +210,7 @@ namespace O3DE::ProjectManager
         if (refreshResult.IsSuccess())
         if (refreshResult.IsSuccess())
         {
         {
             Reinit();
             Reinit();
-            emit OnRefresh();
+            emit NotifyRemoteContentRefreshed();
 
 
             ShowStandardToastNotification(tr("%1 updated").arg(repoName));
             ShowStandardToastNotification(tr("%1 updated").arg(repoName));
         }
         }

+ 0 - 3
Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.h

@@ -45,9 +45,6 @@ namespace O3DE::ProjectManager
 
 
         void NotifyCurrentScreen() override;
         void NotifyCurrentScreen() override;
 
 
-    signals:
-        void OnRefresh();
-
     public slots:
     public slots:
         void ShowStandardToastNotification(const QString& notification);
         void ShowStandardToastNotification(const QString& notification);
         void HandleAddRepoButton();
         void HandleAddRepoButton();

+ 14 - 2
Code/Tools/ProjectManager/Source/ScreenWidget.h

@@ -29,6 +29,7 @@ namespace O3DE::ProjectManager
             : QFrame(parent)
             : QFrame(parent)
         {
         {
         }
         }
+
         ~ScreenWidget() = default;
         ~ScreenWidget() = default;
 
 
         virtual ProjectManagerScreen GetScreenEnum()
         virtual ProjectManagerScreen GetScreenEnum()
@@ -64,10 +65,21 @@ namespace O3DE::ProjectManager
         {
         {
         }
         }
 
 
+        ScreensCtrl* GetScreensCtrl(QObject* widget)
+        {
+            if (!widget)
+            {
+                return nullptr;
+            }
+
+            ScreensCtrl* screensCtrl = qobject_cast<ScreensCtrl*> (widget);
+            return screensCtrl ? screensCtrl : GetScreensCtrl(widget->parent());
+        }
+
         //! Returns true if this screen is the current screen 
         //! Returns true if this screen is the current screen 
         virtual bool IsCurrentScreen()
         virtual bool IsCurrentScreen()
         {
         {
-            ScreensCtrl* screensCtrl = qobject_cast<ScreensCtrl*>(parent());
+            ScreensCtrl* screensCtrl = GetScreensCtrl(this);
             return screensCtrl ? screensCtrl->GetCurrentScreen() == this : false;
             return screensCtrl ? screensCtrl->GetCurrentScreen() == this : false;
         }
         }
 
 
@@ -83,7 +95,7 @@ namespace O3DE::ProjectManager
         void NotifyCurrentProject(const QString& projectPath);
         void NotifyCurrentProject(const QString& projectPath);
         void NotifyBuildProject(const ProjectInfo& projectInfo);
         void NotifyBuildProject(const ProjectInfo& projectInfo);
         void NotifyProjectRemoved(const QString& projectPath);
         void NotifyProjectRemoved(const QString& projectPath);
-
+        void NotifyRemoteContentRefreshed();
     };
     };
 
 
 } // namespace O3DE::ProjectManager
 } // namespace O3DE::ProjectManager

+ 1 - 0
Code/Tools/ProjectManager/Source/ScreensCtrl.h

@@ -39,6 +39,7 @@ namespace O3DE::ProjectManager
         void NotifyCurrentProject(const QString& projectPath);
         void NotifyCurrentProject(const QString& projectPath);
         void NotifyBuildProject(const ProjectInfo& projectInfo);
         void NotifyBuildProject(const ProjectInfo& projectInfo);
         void NotifyProjectRemoved(const QString& projectPath);
         void NotifyProjectRemoved(const QString& projectPath);
+        void NotifyRemoteContentRefreshed();
 
 
     public slots:
     public slots:
         bool ChangeToScreen(ProjectManagerScreen screen);
         bool ChangeToScreen(ProjectManagerScreen screen);

+ 8 - 2
Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp

@@ -46,7 +46,6 @@ namespace O3DE::ProjectManager
         m_gemRepoScreen = new GemRepoScreen(this);
         m_gemRepoScreen = new GemRepoScreen(this);
 
 
         connect(m_projectGemCatalogScreen, &ScreenWidget::ChangeScreenRequest, this, &UpdateProjectCtrl::OnChangeScreenRequest);
         connect(m_projectGemCatalogScreen, &ScreenWidget::ChangeScreenRequest, this, &UpdateProjectCtrl::OnChangeScreenRequest);
-        connect(m_gemRepoScreen, &GemRepoScreen::OnRefresh, m_projectGemCatalogScreen, &ProjectGemCatalogScreen::Refresh);
         connect(static_cast<ScreensCtrl*>(parent), &ScreensCtrl::NotifyProjectRemoved, m_projectGemCatalogScreen, &GemCatalogScreen::NotifyProjectRemoved);
         connect(static_cast<ScreensCtrl*>(parent), &ScreensCtrl::NotifyProjectRemoved, m_projectGemCatalogScreen, &GemCatalogScreen::NotifyProjectRemoved);
 
 
         m_stack = new QStackedWidget(this);
         m_stack = new QStackedWidget(this);
@@ -123,18 +122,20 @@ namespace O3DE::ProjectManager
         if (screen == ProjectManagerScreen::GemRepos)
         if (screen == ProjectManagerScreen::GemRepos)
         {
         {
             m_stack->setCurrentWidget(m_gemRepoScreen);
             m_stack->setCurrentWidget(m_gemRepoScreen);
-            m_gemRepoScreen->Reinit();
+            m_gemRepoScreen->NotifyCurrentScreen();
             Update();
             Update();
         }
         }
         else if (screen == ProjectManagerScreen::ProjectGemCatalog)
         else if (screen == ProjectManagerScreen::ProjectGemCatalog)
         {
         {
             m_projectGemCatalogScreen->ReinitForProject(m_projectInfo.m_path);
             m_projectGemCatalogScreen->ReinitForProject(m_projectInfo.m_path);
+            m_projectGemCatalogScreen->NotifyCurrentScreen();
             m_stack->setCurrentWidget(m_projectGemCatalogScreen);
             m_stack->setCurrentWidget(m_projectGemCatalogScreen);
             Update();
             Update();
         }
         }
         else if (screen == ProjectManagerScreen::UpdateProjectSettings)
         else if (screen == ProjectManagerScreen::UpdateProjectSettings)
         {
         {
             m_stack->setCurrentWidget(m_updateSettingsScreen);
             m_stack->setCurrentWidget(m_updateSettingsScreen);
+            m_updateSettingsScreen->NotifyCurrentScreen();
             Update();
             Update();
         }
         }
         else
         else
@@ -148,6 +149,7 @@ namespace O3DE::ProjectManager
         if (UpdateProjectSettings(true))
         if (UpdateProjectSettings(true))
         {
         {
             m_projectGemCatalogScreen->ReinitForProject(m_projectInfo.m_path);
             m_projectGemCatalogScreen->ReinitForProject(m_projectInfo.m_path);
+            m_projectGemCatalogScreen->NotifyCurrentScreen();
             m_stack->setCurrentWidget(m_projectGemCatalogScreen);
             m_stack->setCurrentWidget(m_projectGemCatalogScreen);
             Update();
             Update();
         }
         }
@@ -158,6 +160,10 @@ namespace O3DE::ProjectManager
         if (m_stack->currentIndex() > 0)
         if (m_stack->currentIndex() > 0)
         {
         {
             m_stack->setCurrentIndex(m_stack->currentIndex() - 1);
             m_stack->setCurrentIndex(m_stack->currentIndex() - 1);
+            if (ScreenWidget* screenWidget = qobject_cast<ScreenWidget*>(m_stack->currentWidget()); screenWidget)
+            {
+                screenWidget->NotifyCurrentScreen();
+            }
             Update();
             Update();
         }
         }
         else
         else