|
|
|
@ -16,11 +16,13 @@ |
|
|
|
#include <QToolButton>
|
|
|
|
#include <QVariantAnimation>
|
|
|
|
#include <fmt/ranges.h>
|
|
|
|
#include <qfilesystemwatcher.h>
|
|
|
|
#include <qnamespace.h>
|
|
|
|
#include <qscroller.h>
|
|
|
|
#include <qscrollerproperties.h>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "common/settings.h"
|
|
|
|
#include "core/core.h"
|
|
|
|
#include "core/file_sys/patch_manager.h"
|
|
|
|
#include "core/file_sys/registered_cache.h"
|
|
|
|
@ -326,6 +328,10 @@ GameList::GameList(FileSys::VirtualFilesystem vfs_, FileSys::ManualContentProvid |
|
|
|
watcher = new QFileSystemWatcher(this); |
|
|
|
connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory); |
|
|
|
|
|
|
|
external_watcher = new QFileSystemWatcher(this); |
|
|
|
ResetExternalWatcher(); |
|
|
|
connect(external_watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshExternalContent); |
|
|
|
|
|
|
|
this->main_window = parent; |
|
|
|
layout = new QVBoxLayout; |
|
|
|
tree_view = new QTreeView; |
|
|
|
@ -920,18 +926,38 @@ const QStringList GameList::supported_file_extensions = { |
|
|
|
|
|
|
|
void GameList::RefreshGameDirectory() |
|
|
|
{ |
|
|
|
// Reset the externals watcher whenever the game list is reloaded,
|
|
|
|
// primarily ensures that new titles and external dirs are caught.
|
|
|
|
ResetExternalWatcher(); |
|
|
|
|
|
|
|
if (!UISettings::values.game_dirs.empty() && current_worker != nullptr) { |
|
|
|
LOG_INFO(Frontend, "Change detected in the games directory. Reloading game list."); |
|
|
|
QtCommon::system->GetFileSystemController().CreateFactories(*QtCommon::vfs); |
|
|
|
// TODO: If you force reset metadata here, live updates to the external directories DO get tracked.
|
|
|
|
// This is not correct however. Game list metadata in general is kind of a mess, but ideally this isn't the
|
|
|
|
// behavior as-is
|
|
|
|
PopulateAsync(UISettings::values.game_dirs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// QtCommon::Game::ResetMetadata(false);
|
|
|
|
void GameList::RefreshExternalContent() { |
|
|
|
// TODO: Explore the possibility of only resetting the metadata cache for that specific game.
|
|
|
|
if (!UISettings::values.game_dirs.empty() && current_worker != nullptr) { |
|
|
|
LOG_INFO(Frontend, "External content directory changed. Clearing metadata cache."); |
|
|
|
QtCommon::Game::ResetMetadata(false); |
|
|
|
QtCommon::system->GetFileSystemController().CreateFactories(*QtCommon::vfs); |
|
|
|
PopulateAsync(UISettings::values.game_dirs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void GameList::ResetExternalWatcher() { |
|
|
|
auto watch_dirs = external_watcher->directories(); |
|
|
|
if (!watch_dirs.isEmpty()) { |
|
|
|
external_watcher->removePaths(watch_dirs); |
|
|
|
} |
|
|
|
|
|
|
|
for (const std::string &dir : Settings::values.external_content_dirs) { |
|
|
|
external_watcher->addPath(QString::fromStdString(dir)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void GameList::ToggleFavorite(u64 program_id) { |
|
|
|
if (!UISettings::values.favorited_ids.contains(program_id)) { |
|
|
|
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), |
|
|
|
|