game_list: Remove global instances of Core::System
This commit is contained in:
parent
493905665c
commit
4ce53ffe6a
|
@ -305,8 +305,8 @@ void GameList::OnFilterCloseClicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvider* provider,
|
GameList::GameList(FileSys::VirtualFilesystem vfs, FileSys::ManualContentProvider* provider,
|
||||||
GMainWindow* parent)
|
Core::System& system_, GMainWindow* parent)
|
||||||
: QWidget{parent}, vfs(std::move(vfs)), provider(provider) {
|
: QWidget{parent}, vfs(std::move(vfs)), provider(provider), system{system_} {
|
||||||
watcher = new QFileSystemWatcher(this);
|
watcher = new QFileSystemWatcher(this);
|
||||||
connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory);
|
connect(watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory);
|
||||||
|
|
||||||
|
@ -738,7 +738,8 @@ void GameList::PopulateAsync(QVector<UISettings::GameDir>& game_dirs) {
|
||||||
|
|
||||||
emit ShouldCancelWorker();
|
emit ShouldCancelWorker();
|
||||||
|
|
||||||
GameListWorker* worker = new GameListWorker(vfs, provider, game_dirs, compatibility_list);
|
GameListWorker* worker =
|
||||||
|
new GameListWorker(vfs, provider, game_dirs, compatibility_list, system);
|
||||||
|
|
||||||
connect(worker, &GameListWorker::EntryReady, this, &GameList::AddEntry, Qt::QueuedConnection);
|
connect(worker, &GameListWorker::EntryReady, this, &GameList::AddEntry, Qt::QueuedConnection);
|
||||||
connect(worker, &GameListWorker::DirEntryReady, this, &GameList::AddDirEntry,
|
connect(worker, &GameListWorker::DirEntryReady, this, &GameList::AddDirEntry,
|
||||||
|
|
|
@ -72,7 +72,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs,
|
explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs,
|
||||||
FileSys::ManualContentProvider* provider, GMainWindow* parent = nullptr);
|
FileSys::ManualContentProvider* provider, Core::System& system_,
|
||||||
|
GMainWindow* parent = nullptr);
|
||||||
~GameList() override;
|
~GameList() override;
|
||||||
|
|
||||||
QString GetLastFilterResultItem() const;
|
QString GetLastFilterResultItem() const;
|
||||||
|
@ -145,6 +146,8 @@ private:
|
||||||
CompatibilityList compatibility_list;
|
CompatibilityList compatibility_list;
|
||||||
|
|
||||||
friend class GameListSearchField;
|
friend class GameListSearchField;
|
||||||
|
|
||||||
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameListPlaceholder : public QWidget {
|
class GameListPlaceholder : public QWidget {
|
||||||
|
|
|
@ -228,16 +228,15 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
|
||||||
GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs,
|
GameListWorker::GameListWorker(FileSys::VirtualFilesystem vfs,
|
||||||
FileSys::ManualContentProvider* provider,
|
FileSys::ManualContentProvider* provider,
|
||||||
QVector<UISettings::GameDir>& game_dirs,
|
QVector<UISettings::GameDir>& game_dirs,
|
||||||
const CompatibilityList& compatibility_list)
|
const CompatibilityList& compatibility_list, Core::System& system_)
|
||||||
: vfs(std::move(vfs)), provider(provider), game_dirs(game_dirs),
|
: vfs(std::move(vfs)), provider(provider), game_dirs(game_dirs),
|
||||||
compatibility_list(compatibility_list) {}
|
compatibility_list(compatibility_list), system{system_} {}
|
||||||
|
|
||||||
GameListWorker::~GameListWorker() = default;
|
GameListWorker::~GameListWorker() = default;
|
||||||
|
|
||||||
void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {
|
void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {
|
||||||
using namespace FileSys;
|
using namespace FileSys;
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
|
||||||
const auto& cache = dynamic_cast<ContentProviderUnion&>(system.GetContentProvider());
|
const auto& cache = dynamic_cast<ContentProviderUnion&>(system.GetContentProvider());
|
||||||
|
|
||||||
auto installed_games = cache.ListEntriesFilterOrigin(std::nullopt, TitleType::Application,
|
auto installed_games = cache.ListEntriesFilterOrigin(std::nullopt, TitleType::Application,
|
||||||
|
@ -285,10 +284,7 @@ void GameListWorker::AddTitlesToGameList(GameListDir* parent_dir) {
|
||||||
|
|
||||||
void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
|
void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_path, bool deep_scan,
|
||||||
GameListDir* parent_dir) {
|
GameListDir* parent_dir) {
|
||||||
auto& system = Core::System::GetInstance();
|
const auto callback = [this, target, parent_dir](const std::filesystem::path& path) -> bool {
|
||||||
|
|
||||||
const auto callback = [this, target, parent_dir,
|
|
||||||
&system](const std::filesystem::path& path) -> bool {
|
|
||||||
if (stop_processing) {
|
if (stop_processing) {
|
||||||
// Breaks the callback loop.
|
// Breaks the callback loop.
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "yuzu/compatibility_list.h"
|
#include "yuzu/compatibility_list.h"
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
class QStandardItem;
|
class QStandardItem;
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
@ -37,7 +41,7 @@ public:
|
||||||
explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs,
|
explicit GameListWorker(std::shared_ptr<FileSys::VfsFilesystem> vfs,
|
||||||
FileSys::ManualContentProvider* provider,
|
FileSys::ManualContentProvider* provider,
|
||||||
QVector<UISettings::GameDir>& game_dirs,
|
QVector<UISettings::GameDir>& game_dirs,
|
||||||
const CompatibilityList& compatibility_list);
|
const CompatibilityList& compatibility_list, Core::System& system_);
|
||||||
~GameListWorker() override;
|
~GameListWorker() override;
|
||||||
|
|
||||||
/// Starts the processing of directory tree information.
|
/// Starts the processing of directory tree information.
|
||||||
|
@ -80,4 +84,6 @@ private:
|
||||||
|
|
||||||
QStringList watch_list;
|
QStringList watch_list;
|
||||||
std::atomic_bool stop_processing;
|
std::atomic_bool stop_processing;
|
||||||
|
|
||||||
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
|
@ -701,7 +701,7 @@ void GMainWindow::InitializeWidgets() {
|
||||||
render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, system);
|
render_window = new GRenderWindow(this, emu_thread.get(), input_subsystem, system);
|
||||||
render_window->hide();
|
render_window->hide();
|
||||||
|
|
||||||
game_list = new GameList(vfs, provider.get(), this);
|
game_list = new GameList(vfs, provider.get(), system, this);
|
||||||
ui.horizontalLayout->addWidget(game_list);
|
ui.horizontalLayout->addWidget(game_list);
|
||||||
|
|
||||||
game_list_placeholder = new GameListPlaceholder(this);
|
game_list_placeholder = new GameListPlaceholder(this);
|
||||||
|
|
Loading…
Reference in New Issue