diff --git a/Source/Core/DolphinQt2/GameList/GameListModel.cpp b/Source/Core/DolphinQt2/GameList/GameListModel.cpp index c1e6ce1af1..f332947b28 100644 --- a/Source/Core/DolphinQt2/GameList/GameListModel.cpp +++ b/Source/Core/DolphinQt2/GameList/GameListModel.cpp @@ -22,6 +22,8 @@ GameListModel::GameListModel(QObject* parent) : QAbstractTableModel(parent) [this](const QString& path) { RemoveGame(path.toStdString()); }); connect(&Settings::Instance(), &Settings::PathAdded, &m_tracker, &GameTracker::AddDirectory); connect(&Settings::Instance(), &Settings::PathRemoved, &m_tracker, &GameTracker::RemoveDirectory); + connect(&Settings::Instance(), &Settings::PathReloadRequested, &m_tracker, + &GameTracker::ReloadDirectory); for (const QString& dir : Settings::Instance().GetPaths()) m_tracker.AddDirectory(dir); diff --git a/Source/Core/DolphinQt2/GameList/GameTracker.cpp b/Source/Core/DolphinQt2/GameList/GameTracker.cpp index 4e4dfcb57b..d37869ee12 100644 --- a/Source/Core/DolphinQt2/GameList/GameTracker.cpp +++ b/Source/Core/DolphinQt2/GameList/GameTracker.cpp @@ -6,6 +6,7 @@ #include #include +#include "Core/ConfigManager.h" #include "DiscIO/DirectoryBlob.h" #include "DolphinQt2/GameList/GameTracker.h" #include "DolphinQt2/QtUtils/QueueOnObject.h" @@ -58,6 +59,12 @@ void GameTracker::RemoveDirectory(const QString& dir) m_load_thread.EmplaceItem(Command{CommandType::RemoveDirectory, dir}); } +void GameTracker::ReloadDirectory(const QString& dir) +{ + m_load_thread.EmplaceItem(Command{CommandType::RemoveDirectory, dir}); + m_load_thread.EmplaceItem(Command{CommandType::AddDirectory, dir}); +} + void GameTracker::UpdateDirectory(const QString& dir) { m_load_thread.EmplaceItem(Command{CommandType::UpdateDirectory, dir}); @@ -76,13 +83,21 @@ void GameTracker::AddDirectoryInternal(const QString& dir) UpdateDirectoryInternal(dir); } +static std::unique_ptr GetIterator(const QString& dir) +{ + return std::make_unique(dir, game_filters, QDir::NoFilter, + SConfig::GetInstance().m_RecursiveISOFolder ? + QDirIterator::Subdirectories : + QDirIterator::NoIteratorFlags); +} + void GameTracker::RemoveDirectoryInternal(const QString& dir) { removePath(dir); - QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories); - while (it.hasNext()) + auto it = GetIterator(dir); + while (it->hasNext()) { - QString path = QFileInfo(it.next()).canonicalFilePath(); + QString path = QFileInfo(it->next()).canonicalFilePath(); if (m_tracked_files.contains(path)) { m_tracked_files[path].remove(dir); @@ -98,10 +113,10 @@ void GameTracker::RemoveDirectoryInternal(const QString& dir) void GameTracker::UpdateDirectoryInternal(const QString& dir) { - QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories); - while (it.hasNext()) + auto it = GetIterator(dir); + while (it->hasNext()) { - QString path = QFileInfo(it.next()).canonicalFilePath(); + QString path = QFileInfo(it->next()).canonicalFilePath(); if (m_tracked_files.contains(path)) { @@ -147,7 +162,7 @@ void GameTracker::UpdateFileInternal(const QString& file) QSet GameTracker::FindMissingFiles(const QString& dir) { - QDirIterator it(dir, game_filters, QDir::NoFilter, QDirIterator::Subdirectories); + auto it = GetIterator(dir); QSet missing_files; @@ -157,9 +172,9 @@ QSet GameTracker::FindMissingFiles(const QString& dir) missing_files.insert(key); } - while (it.hasNext()) + while (it->hasNext()) { - QString path = QFileInfo(it.next()).canonicalFilePath(); + QString path = QFileInfo(it->next()).canonicalFilePath(); if (m_tracked_files.contains(path)) missing_files.remove(path); } diff --git a/Source/Core/DolphinQt2/GameList/GameTracker.h b/Source/Core/DolphinQt2/GameList/GameTracker.h index 73d1e097c4..b6bc8835a1 100644 --- a/Source/Core/DolphinQt2/GameList/GameTracker.h +++ b/Source/Core/DolphinQt2/GameList/GameTracker.h @@ -28,6 +28,7 @@ public: void AddDirectory(const QString& dir); void RemoveDirectory(const QString& dir); + void ReloadDirectory(const QString& dir); signals: void GameLoaded(std::shared_ptr game); diff --git a/Source/Core/DolphinQt2/Settings.cpp b/Source/Core/DolphinQt2/Settings.cpp index 8a523605de..b697b8c431 100644 --- a/Source/Core/DolphinQt2/Settings.cpp +++ b/Source/Core/DolphinQt2/Settings.cpp @@ -80,6 +80,11 @@ void Settings::RemovePath(const QString& qpath) emit PathRemoved(qpath); } +void Settings::ReloadPath(const QString& qpath) +{ + emit PathReloadRequested(qpath); +} + QString Settings::GetDefaultGame() const { return QString::fromStdString(SConfig::GetInstance().m_strDefaultISO); diff --git a/Source/Core/DolphinQt2/Settings.h b/Source/Core/DolphinQt2/Settings.h index dcde3434d6..7e40803e17 100644 --- a/Source/Core/DolphinQt2/Settings.h +++ b/Source/Core/DolphinQt2/Settings.h @@ -65,6 +65,7 @@ public: void SetPreferredView(bool list); QString GetDefaultGame() const; void SetDefaultGame(QString path); + void ReloadPath(const QString& qpath); // Emulation int GetStateSlot() const; @@ -123,6 +124,7 @@ signals: void PathAdded(const QString&); void PathRemoved(const QString&); void DefaultGameChanged(const QString&); + void PathReloadRequested(const QString&); void HideCursorChanged(); void VolumeChanged(int volume); void NANDRefresh(); diff --git a/Source/Core/DolphinQt2/Settings/PathPane.cpp b/Source/Core/DolphinQt2/Settings/PathPane.cpp index 76ca08edfa..3554876708 100644 --- a/Source/Core/DolphinQt2/Settings/PathPane.cpp +++ b/Source/Core/DolphinQt2/Settings/PathPane.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include #include #include @@ -81,9 +82,20 @@ QGroupBox* PathPane::MakeGameFolderBox() hlayout->addStretch(); QPushButton* add = new QPushButton(tr("Add")); QPushButton* remove = new QPushButton(tr("Remove")); + + auto* checkbox = new QCheckBox(tr("Search Subfolders")); + checkbox->setChecked(SConfig::GetInstance().m_RecursiveISOFolder); + hlayout->addWidget(add); hlayout->addWidget(remove); vlayout->addLayout(hlayout); + vlayout->addWidget(checkbox); + + connect(checkbox, &QCheckBox::toggled, this, [this](bool checked) { + SConfig::GetInstance().m_RecursiveISOFolder = checked; + for (const auto& path : Settings::Instance().GetPaths()) + Settings::Instance().ReloadPath(path); + }); connect(add, &QPushButton::clicked, this, &PathPane::Browse); connect(remove, &QPushButton::clicked, this, &PathPane::RemovePath);