mirror of
https://github.com/citra-emu/citra.git
synced 2024-11-25 22:20:14 +00:00
Refresh game list if recursion setting changed
This version cleans out all the signals/slots boilerplate, and only actually refreshes the list if that checkbox is modified. It also makes it so that changing to the same directory is a nop.
This commit is contained in:
parent
36aaaafc26
commit
abf54effe0
@ -37,6 +37,10 @@ GameList::GameList(QWidget* parent) : QWidget{parent} {
|
||||
item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, "File type");
|
||||
item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, "Size");
|
||||
|
||||
recursive = UISettings::values.gamedir_deepscan;
|
||||
game_directory = UISettings::values.gamedir;
|
||||
PopulateAsync(game_directory, recursive);
|
||||
|
||||
connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry);
|
||||
connect(tree_view, &QTreeView::customContextMenuRequested, this, &GameList::PopupContextMenu);
|
||||
connect(&watcher, &QFileSystemWatcher::directoryChanged, this, &GameList::RefreshGameDirectory);
|
||||
@ -151,9 +155,18 @@ static bool HasSupportedFileExtension(const std::string& file_name) {
|
||||
}
|
||||
|
||||
void GameList::RefreshGameDirectory() {
|
||||
if (!UISettings::values.gamedir.isEmpty() && current_worker != nullptr) {
|
||||
if (!game_directory.isEmpty() && current_worker != nullptr) {
|
||||
LOG_INFO(Frontend, "Change detected in the games directory. Reloading game list.");
|
||||
PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
||||
PopulateAsync(game_directory, recursive);
|
||||
}
|
||||
}
|
||||
|
||||
void GameList::OnSettingsUpdated() {
|
||||
if (UISettings::values.gamedir_deepscan != recursive ||
|
||||
UISettings::values.gamedir != game_directory) {
|
||||
game_directory = UISettings::values.gamedir;
|
||||
recursive = UISettings::values.gamedir_deepscan;
|
||||
RefreshGameDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
|
||||
void SaveInterfaceLayout();
|
||||
void LoadInterfaceLayout();
|
||||
void OnSettingsUpdated();
|
||||
|
||||
static const QStringList supported_file_extensions;
|
||||
|
||||
@ -54,4 +55,6 @@ private:
|
||||
QStandardItemModel* item_model = nullptr;
|
||||
GameListWorker* current_worker = nullptr;
|
||||
QFileSystemWatcher watcher;
|
||||
QString game_directory;
|
||||
bool recursive;
|
||||
};
|
||||
|
@ -73,8 +73,6 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
|
||||
.arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc));
|
||||
show();
|
||||
|
||||
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
||||
|
||||
QStringList args = QApplication::arguments();
|
||||
if (args.length() >= 2) {
|
||||
BootGame(args[1]);
|
||||
@ -538,7 +536,7 @@ void GMainWindow::OnMenuSelectGameListRoot() {
|
||||
QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
|
||||
if (!dir_path.isEmpty()) {
|
||||
UISettings::values.gamedir = dir_path;
|
||||
game_list->PopulateAsync(dir_path, UISettings::values.gamedir_deepscan);
|
||||
game_list->OnSettingsUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
@ -612,6 +610,7 @@ void GMainWindow::OnConfigure() {
|
||||
auto result = configureDialog.exec();
|
||||
if (result == QDialog::Accepted) {
|
||||
configureDialog.applyConfiguration();
|
||||
game_list->OnSettingsUpdated();
|
||||
config->Save();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user