Merge pull request #1640 from DarkLordZach/game-list-reload

game_list: Only reload game list after relevant settings changed
This commit is contained in:
bunnei 2018-11-18 19:24:53 -08:00 committed by GitHub
commit 3e93c30630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 1 deletions

View File

@ -36,6 +36,16 @@ ConfigureGameList::ConfigureGameList(QWidget* parent)
InitializeRowComboBoxes(); InitializeRowComboBoxes();
this->setConfiguration(); this->setConfiguration();
// Force game list reload if any of the relevant settings are changed.
connect(ui->show_unknown, &QCheckBox::stateChanged, this,
&ConfigureGameList::RequestGameListUpdate);
connect(ui->icon_size_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureGameList::RequestGameListUpdate);
connect(ui->row_1_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureGameList::RequestGameListUpdate);
connect(ui->row_2_text_combobox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
&ConfigureGameList::RequestGameListUpdate);
} }
ConfigureGameList::~ConfigureGameList() = default; ConfigureGameList::~ConfigureGameList() = default;
@ -49,6 +59,10 @@ void ConfigureGameList::applyConfiguration() {
Settings::Apply(); Settings::Apply();
} }
void ConfigureGameList::RequestGameListUpdate() {
UISettings::values.is_game_list_reload_pending.exchange(true);
}
void ConfigureGameList::setConfiguration() { void ConfigureGameList::setConfiguration() {
ui->show_unknown->setChecked(UISettings::values.show_unknown); ui->show_unknown->setChecked(UISettings::values.show_unknown);
ui->show_add_ons->setChecked(UISettings::values.show_add_ons); ui->show_add_ons->setChecked(UISettings::values.show_add_ons);

View File

@ -21,6 +21,8 @@ public:
void applyConfiguration(); void applyConfiguration();
private: private:
void RequestGameListUpdate();
void setConfiguration(); void setConfiguration();
void changeEvent(QEvent*) override; void changeEvent(QEvent*) override;

View File

@ -23,6 +23,9 @@ ConfigureGeneral::ConfigureGeneral(QWidget* parent)
this->setConfiguration(); this->setConfiguration();
connect(ui->toggle_deepscan, &QCheckBox::stateChanged, this,
[] { UISettings::values.is_game_list_reload_pending.exchange(true); });
ui->use_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn()); ui->use_cpu_jit->setEnabled(!Core::System::GetInstance().IsPoweredOn());
} }

View File

@ -1341,7 +1341,13 @@ void GMainWindow::OnConfigure() {
UpdateUITheme(); UpdateUITheme();
if (UISettings::values.enable_discord_presence != old_discord_presence) if (UISettings::values.enable_discord_presence != old_discord_presence)
SetDiscordEnabled(UISettings::values.enable_discord_presence); SetDiscordEnabled(UISettings::values.enable_discord_presence);
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false);
if (reload) {
game_list->PopulateAsync(UISettings::values.gamedir,
UISettings::values.gamedir_deepscan);
}
config->Save(); config->Save();
} }
} }

View File

@ -5,6 +5,7 @@
#pragma once #pragma once
#include <array> #include <array>
#include <atomic>
#include <vector> #include <vector>
#include <QByteArray> #include <QByteArray>
#include <QString> #include <QString>
@ -63,6 +64,7 @@ struct Values {
uint32_t icon_size; uint32_t icon_size;
uint8_t row_1_text_id; uint8_t row_1_text_id;
uint8_t row_2_text_id; uint8_t row_2_text_id;
std::atomic_bool is_game_list_reload_pending{false};
}; };
extern Values values; extern Values values;