diff --git a/Source/Core/DolphinQt2/Config/ControllersWindow.cpp b/Source/Core/DolphinQt2/Config/ControllersWindow.cpp index 84490433f5..f7fb269129 100644 --- a/Source/Core/DolphinQt2/Config/ControllersWindow.cpp +++ b/Source/Core/DolphinQt2/Config/ControllersWindow.cpp @@ -371,7 +371,7 @@ void ControllersWindow::OnWiimoteRefreshPressed() void ControllersWindow::OnEmulationStateChanged(bool running) { - if (!Settings().IsWiiGameRunning() || NetPlay::IsNetPlayRunning()) + if (!Settings::Instance().IsWiiGameRunning() || NetPlay::IsNetPlayRunning()) { m_wiimote_sync->setEnabled(!running); m_wiimote_reset->setEnabled(!running); @@ -383,7 +383,7 @@ void ControllersWindow::OnEmulationStateChanged(bool running) m_wiimote_emu->setEnabled(!running); m_wiimote_passthrough->setEnabled(!running); - if (!Settings().IsWiiGameRunning()) + if (!Settings::Instance().IsWiiGameRunning()) { m_wiimote_real_balance_board->setEnabled(!running); m_wiimote_continuous_scanning->setEnabled(!running); @@ -471,33 +471,35 @@ void ControllersWindow::UnimplementedButton() void ControllersWindow::LoadSettings() { + auto& settings = Settings::Instance(); for (size_t i = 0; i < m_wiimote_groups.size(); i++) { - m_gc_controller_boxes[i]->setCurrentIndex(ToGCMenuIndex(Settings().GetSIDevice(i))); + m_gc_controller_boxes[i]->setCurrentIndex(ToGCMenuIndex(settings.GetSIDevice(i))); m_wiimote_boxes[i]->setCurrentIndex(ToWiimoteMenuIndex(g_wiimote_sources[i])); } m_wiimote_real_balance_board->setChecked(g_wiimote_sources[WIIMOTE_BALANCE_BOARD] == WIIMOTE_SRC_REAL); - m_wiimote_speaker_data->setChecked(Settings().IsWiimoteSpeakerEnabled()); - m_wiimote_continuous_scanning->setChecked(Settings().IsContinuousScanningEnabled()); + m_wiimote_speaker_data->setChecked(settings.IsWiimoteSpeakerEnabled()); + m_wiimote_continuous_scanning->setChecked(settings.IsContinuousScanningEnabled()); - m_advanced_bg_input->setChecked(Settings().IsBackgroundInputEnabled()); + m_advanced_bg_input->setChecked(settings.IsBackgroundInputEnabled()); - if (Settings().IsBluetoothPassthroughEnabled()) + if (settings.IsBluetoothPassthroughEnabled()) m_wiimote_passthrough->setChecked(true); else m_wiimote_emu->setChecked(true); - OnWiimoteModeChanged(Settings().IsBluetoothPassthroughEnabled()); + OnWiimoteModeChanged(settings.IsBluetoothPassthroughEnabled()); } void ControllersWindow::SaveSettings() { - Settings().SetWiimoteSpeakerEnabled(m_wiimote_speaker_data->isChecked()); - Settings().SetContinuousScanningEnabled(m_wiimote_continuous_scanning->isChecked()); + auto& settings = Settings::Instance(); + settings.SetWiimoteSpeakerEnabled(m_wiimote_speaker_data->isChecked()); + settings.SetContinuousScanningEnabled(m_wiimote_continuous_scanning->isChecked()); - Settings().SetBluetoothPassthroughEnabled(m_wiimote_passthrough->isChecked()); - Settings().SetBackgroundInputEnabled(m_advanced_bg_input->isChecked()); + settings.SetBluetoothPassthroughEnabled(m_wiimote_passthrough->isChecked()); + settings.SetBackgroundInputEnabled(m_advanced_bg_input->isChecked()); WiimoteReal::ChangeWiimoteSource(WIIMOTE_BALANCE_BOARD, m_wiimote_real_balance_board->isChecked() ? WIIMOTE_SRC_REAL : @@ -515,8 +517,8 @@ void ControllersWindow::SaveSettings() for (size_t i = 0; i < m_gc_groups.size(); i++) { const int index = m_gc_controller_boxes[i]->currentIndex(); - Settings().SetSIDevice(i, FromGCMenuIndex(index)); + settings.SetSIDevice(i, FromGCMenuIndex(index)); m_gc_buttons[i]->setEnabled(index != 0 && index != 6); } - Settings().Save(); + settings.Save(); } diff --git a/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.cpp b/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.cpp index 7a2610bffd..e5a2a3ce4c 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/GCPadWiiU.cpp @@ -48,14 +48,14 @@ void GCPadWiiU::ConnectWidgets() void GCPadWiiU::LoadSettings() { - m_rumble->setChecked(Settings().IsGCAdapterRumbleEnabled(GetPort())); - m_simulate_bongos->setChecked(Settings().IsGCAdapterSimulatingDKBongos(GetPort())); + m_rumble->setChecked(Settings::Instance().IsGCAdapterRumbleEnabled(GetPort())); + m_simulate_bongos->setChecked(Settings::Instance().IsGCAdapterSimulatingDKBongos(GetPort())); } void GCPadWiiU::SaveSettings() { - Settings().SetGCAdapterRumbleEnabled(GetPort(), m_rumble->isChecked()); - Settings().SetGCAdapterSimulatingDKBongos(GetPort(), m_simulate_bongos->isChecked()); + Settings::Instance().SetGCAdapterRumbleEnabled(GetPort(), m_rumble->isChecked()); + Settings::Instance().SetGCAdapterSimulatingDKBongos(GetPort(), m_simulate_bongos->isChecked()); } InputConfig* GCPadWiiU::GetConfig() diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp index 7b24f1c678..04e20485b2 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWindow.cpp @@ -126,8 +126,9 @@ void MappingWindow::ConnectWidgets() void MappingWindow::OnDeleteProfilePressed() { + auto& settings = Settings::Instance(); const QString profile_name = m_profiles_combo->currentText(); - if (!Settings().GetProfiles(m_config).contains(profile_name)) + if (!settings.GetProfiles(m_config).contains(profile_name)) { QMessageBox error; error.setIcon(QMessageBox::Critical); @@ -153,7 +154,7 @@ void MappingWindow::OnDeleteProfilePressed() QMessageBox result(this); - std::string profile_path = Settings().GetProfileINIPath(m_config, profile_name).toStdString(); + std::string profile_path = settings.GetProfileINIPath(m_config, profile_name).toStdString(); File::CreateFullPath(profile_path); @@ -170,7 +171,8 @@ void MappingWindow::OnLoadProfilePressed() if (profile_name.isEmpty()) return; - std::string profile_path = Settings().GetProfileINIPath(m_config, profile_name).toStdString(); + std::string profile_path = + Settings::Instance().GetProfileINIPath(m_config, profile_name).toStdString(); File::CreateFullPath(profile_path); @@ -192,7 +194,8 @@ void MappingWindow::OnSaveProfilePressed() if (profile_name.isEmpty()) return; - std::string profile_path = Settings().GetProfileINIPath(m_config, profile_name).toStdString(); + std::string profile_path = + Settings::Instance().GetProfileINIPath(m_config, profile_name).toStdString(); File::CreateFullPath(profile_path); @@ -297,7 +300,7 @@ void MappingWindow::ChangeMappingType(MappingWindow::Type type) m_controller = m_config->GetController(GetPort()); m_profiles_combo->addItem(QStringLiteral("")); - for (const auto& item : Settings().GetProfiles(m_config)) + for (const auto& item : Settings::Instance().GetProfiles(m_config)) m_profiles_combo->addItem(item); } diff --git a/Source/Core/DolphinQt2/Config/PathDialog.cpp b/Source/Core/DolphinQt2/Config/PathDialog.cpp index c99b82acac..62f1b25a2d 100644 --- a/Source/Core/DolphinQt2/Config/PathDialog.cpp +++ b/Source/Core/DolphinQt2/Config/PathDialog.cpp @@ -38,12 +38,11 @@ void PathDialog::Browse() QFileDialog::getExistingDirectory(this, tr("Select a Directory"), QDir::currentPath()); if (!dir.isEmpty()) { - Settings settings; - QStringList game_folders = settings.GetPaths(); + QStringList game_folders = Settings::Instance().GetPaths(); if (!game_folders.contains(dir)) { game_folders << dir; - settings.SetPaths(game_folders); + Settings::Instance().SetPaths(game_folders); m_path_list->addItem(dir); emit PathAdded(dir); } @@ -59,7 +58,7 @@ void PathDialog::BrowseDefaultGame() if (!file.isEmpty()) { m_game_edit->setText(file); - Settings().SetDefaultGame(file); + Settings::Instance().SetDefaultGame(file); } } @@ -69,7 +68,7 @@ void PathDialog::BrowseDVDRoot() if (!dir.isEmpty()) { m_dvd_edit->setText(dir); - Settings().SetDVDRoot(dir); + Settings::Instance().SetDVDRoot(dir); } } @@ -80,7 +79,7 @@ void PathDialog::BrowseApploader() if (!file.isEmpty()) { m_app_edit->setText(file); - Settings().SetApploader(file); + Settings::Instance().SetApploader(file); } } @@ -91,7 +90,7 @@ void PathDialog::BrowseWiiNAND() if (!dir.isEmpty()) { m_nand_edit->setText(dir); - Settings().SetWiiNAND(dir); + Settings::Instance().SetWiiNAND(dir); } } @@ -102,7 +101,7 @@ QGroupBox* PathDialog::MakeGameFolderBox() QVBoxLayout* vlayout = new QVBoxLayout; m_path_list = new QListWidget; - m_path_list->insertItems(0, Settings().GetPaths()); + m_path_list->insertItems(0, Settings::Instance().GetPaths()); m_path_list->setSpacing(1); vlayout->addWidget(m_path_list); @@ -124,39 +123,40 @@ QGroupBox* PathDialog::MakeGameFolderBox() QGridLayout* PathDialog::MakePathsLayout() { + auto& settings = Settings::Instance(); QGridLayout* layout = new QGridLayout; layout->setColumnStretch(1, 1); - m_game_edit = new QLineEdit(Settings().GetDefaultGame()); + m_game_edit = new QLineEdit(settings.GetDefaultGame()); connect(m_game_edit, &QLineEdit::editingFinished, - [=] { Settings().SetDefaultGame(m_game_edit->text()); }); + [=, &settings] { settings.SetDefaultGame(m_game_edit->text()); }); QPushButton* game_open = new QPushButton; connect(game_open, &QPushButton::clicked, this, &PathDialog::BrowseDefaultGame); layout->addWidget(new QLabel(tr("Default Game")), 0, 0); layout->addWidget(m_game_edit, 0, 1); layout->addWidget(game_open, 0, 2); - m_dvd_edit = new QLineEdit(Settings().GetDVDRoot()); + m_dvd_edit = new QLineEdit(settings.GetDVDRoot()); connect(m_dvd_edit, &QLineEdit::editingFinished, - [=] { Settings().SetDVDRoot(m_dvd_edit->text()); }); + [=, &settings] { settings.SetDVDRoot(m_dvd_edit->text()); }); QPushButton* dvd_open = new QPushButton; connect(dvd_open, &QPushButton::clicked, this, &PathDialog::BrowseDVDRoot); layout->addWidget(new QLabel(tr("DVD Root")), 1, 0); layout->addWidget(m_dvd_edit, 1, 1); layout->addWidget(dvd_open, 1, 2); - m_app_edit = new QLineEdit(Settings().GetApploader()); + m_app_edit = new QLineEdit(settings.GetApploader()); connect(m_app_edit, &QLineEdit::editingFinished, - [=] { Settings().SetApploader(m_app_edit->text()); }); + [=, &settings] { settings.SetApploader(m_app_edit->text()); }); QPushButton* app_open = new QPushButton; connect(app_open, &QPushButton::clicked, this, &PathDialog::BrowseApploader); layout->addWidget(new QLabel(tr("Apploader")), 2, 0); layout->addWidget(m_app_edit, 2, 1); layout->addWidget(app_open, 2, 2); - m_nand_edit = new QLineEdit(Settings().GetWiiNAND()); + m_nand_edit = new QLineEdit(settings.GetWiiNAND()); connect(m_nand_edit, &QLineEdit::editingFinished, - [=] { Settings().SetWiiNAND(m_nand_edit->text()); }); + [=, &settings] { settings.SetWiiNAND(m_nand_edit->text()); }); QPushButton* nand_open = new QPushButton; connect(nand_open, &QPushButton::clicked, this, &PathDialog::BrowseWiiNAND); layout->addWidget(new QLabel(tr("Wii NAND Root")), 3, 0); @@ -172,5 +172,5 @@ void PathDialog::RemovePath() if (row < 0) return; emit PathRemoved(m_path_list->takeItem(row)->text()); - Settings().RemovePath(row); + Settings::Instance().RemovePath(row); } diff --git a/Source/Core/DolphinQt2/Config/SettingsWindow.cpp b/Source/Core/DolphinQt2/Config/SettingsWindow.cpp index fb1a8190fe..0e765b4a3a 100644 --- a/Source/Core/DolphinQt2/Config/SettingsWindow.cpp +++ b/Source/Core/DolphinQt2/Config/SettingsWindow.cpp @@ -67,7 +67,7 @@ void SettingsWindow::MakeUnfinishedWarning() void SettingsWindow::AddCategoryToList(const QString& title, const QString& icon) { - QString dir = Settings().GetThemeDir(); + QString dir = Settings::Instance().GetThemeDir(); QListWidgetItem* button = new QListWidgetItem(); button->setIcon(QIcon(dir.append(icon))); button->setText(title); diff --git a/Source/Core/DolphinQt2/GameList/GameFile.cpp b/Source/Core/DolphinQt2/GameList/GameFile.cpp index 94ed8e6e47..5b921e78f2 100644 --- a/Source/Core/DolphinQt2/GameList/GameFile.cpp +++ b/Source/Core/DolphinQt2/GameList/GameFile.cpp @@ -217,9 +217,9 @@ QString GameFile::GetBannerString(const QMap& m) cons bool wii = m_platform != DiscIO::Platform::GAMECUBE_DISC; DiscIO::Language current_lang; if (wii) - current_lang = Settings().GetWiiSystemLanguage(); + current_lang = Settings::Instance().GetWiiSystemLanguage(); else - current_lang = Settings().GetGCSystemLanguage(); + current_lang = Settings::Instance().GetGCSystemLanguage(); if (m.contains(current_lang)) return m[current_lang]; diff --git a/Source/Core/DolphinQt2/GameList/GameList.cpp b/Source/Core/DolphinQt2/GameList/GameList.cpp index 41a063322d..54ab89cb95 100644 --- a/Source/Core/DolphinQt2/GameList/GameList.cpp +++ b/Source/Core/DolphinQt2/GameList/GameList.cpp @@ -50,7 +50,7 @@ GameList::GameList(QWidget* parent) : QStackedWidget(parent) addWidget(m_table); addWidget(m_list); addWidget(m_empty); - m_prefer_table = Settings().GetPreferredView(); + m_prefer_table = Settings::Instance().GetPreferredView(); ConsiderViewChange(); } @@ -70,15 +70,16 @@ void GameList::MakeTableView() connect(m_table, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu); - m_table->setColumnHidden(GameListModel::COL_PLATFORM, !Settings().PlatformVisible()); - m_table->setColumnHidden(GameListModel::COL_ID, !Settings().IDVisible()); - m_table->setColumnHidden(GameListModel::COL_BANNER, !Settings().BannerVisible()); - m_table->setColumnHidden(GameListModel::COL_TITLE, !Settings().TitleVisible()); - m_table->setColumnHidden(GameListModel::COL_DESCRIPTION, !Settings().DescriptionVisible()); - m_table->setColumnHidden(GameListModel::COL_MAKER, !Settings().MakerVisible()); - m_table->setColumnHidden(GameListModel::COL_SIZE, !Settings().SizeVisible()); - m_table->setColumnHidden(GameListModel::COL_COUNTRY, !Settings().CountryVisible()); - m_table->setColumnHidden(GameListModel::COL_RATING, !Settings().StateVisible()); + auto& settings = Settings::Instance(); + m_table->setColumnHidden(GameListModel::COL_PLATFORM, !settings.PlatformVisible()); + m_table->setColumnHidden(GameListModel::COL_ID, !settings.IDVisible()); + m_table->setColumnHidden(GameListModel::COL_BANNER, !settings.BannerVisible()); + m_table->setColumnHidden(GameListModel::COL_TITLE, !settings.TitleVisible()); + m_table->setColumnHidden(GameListModel::COL_DESCRIPTION, !settings.DescriptionVisible()); + m_table->setColumnHidden(GameListModel::COL_MAKER, !settings.MakerVisible()); + m_table->setColumnHidden(GameListModel::COL_SIZE, !settings.SizeVisible()); + m_table->setColumnHidden(GameListModel::COL_COUNTRY, !settings.CountryVisible()); + m_table->setColumnHidden(GameListModel::COL_RATING, !settings.StateVisible()); QHeaderView* hor_header = m_table->horizontalHeader(); hor_header->setSectionResizeMode(GameListModel::COL_PLATFORM, QHeaderView::ResizeToContents); @@ -284,7 +285,7 @@ void GameList::UninstallWAD() void GameList::SetDefaultISO() { - Settings().SetDefaultGame(GetSelectedGame()); + Settings::Instance().SetDefaultGame(GetSelectedGame()); } void GameList::OpenContainingFolder() @@ -364,7 +365,7 @@ QString GameList::GetSelectedGame() const void GameList::SetPreferredView(bool table) { m_prefer_table = table; - Settings().SetPreferredView(table); + Settings::Instance().SetPreferredView(table); ConsiderViewChange(); } diff --git a/Source/Core/DolphinQt2/GameList/GameTracker.cpp b/Source/Core/DolphinQt2/GameList/GameTracker.cpp index 1097504ff8..be66ab406e 100644 --- a/Source/Core/DolphinQt2/GameList/GameTracker.cpp +++ b/Source/Core/DolphinQt2/GameList/GameTracker.cpp @@ -28,7 +28,7 @@ GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent) m_loader_thread.start(); - for (QString dir : Settings().GetPaths()) + for (QString dir : Settings::Instance().GetPaths()) AddDirectory(dir); } diff --git a/Source/Core/DolphinQt2/Main.cpp b/Source/Core/DolphinQt2/Main.cpp index 781f89d2da..439c8b81c3 100644 --- a/Source/Core/DolphinQt2/Main.cpp +++ b/Source/Core/DolphinQt2/Main.cpp @@ -34,8 +34,9 @@ int main(int argc, char* argv[]) QObject::connect(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::aboutToBlock, &app, &Core::HostDispatchJobs); + auto& settings = Settings::Instance(); int retval = 0; - if (Settings().IsInDevelopmentWarningEnabled()) + if (settings.IsInDevelopmentWarningEnabled()) { InDevelopmentWarning warning_box; retval = warning_box.exec() == QDialog::Rejected; @@ -48,7 +49,7 @@ int main(int argc, char* argv[]) win.show(); #if defined(USE_ANALYTICS) && USE_ANALYTICS - if (!Settings().HasAskedForAnalyticsPermission()) + if (!settings.HasAskedForAnalyticsPermission()) { QMessageBox analytics_prompt(&win); @@ -69,9 +70,9 @@ int main(int argc, char* argv[]) const int answer = analytics_prompt.exec(); - Settings().SetAskedForAnalyticsPermission(true); - Settings().SetAnalyticsEnabled(answer == QMessageBox::Yes); - Settings().Save(); + settings.SetAskedForAnalyticsPermission(true); + settings.SetAnalyticsEnabled(answer == QMessageBox::Yes); + settings.Save(); DolphinAnalytics::Instance()->ReloadConfig(); } diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index 3382cee4c0..e6677712ec 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -206,7 +206,7 @@ void MainWindow::Play() } else { - QString default_path = Settings().GetDefaultGame(); + QString default_path = Settings::Instance().GetDefaultGame(); if (!default_path.isEmpty() && QFile::exists(default_path)) { StartGame(default_path); @@ -228,7 +228,7 @@ void MainWindow::Pause() bool MainWindow::Stop() { bool stop = true; - if (Settings().GetConfirmStop()) + if (Settings::Instance().GetConfirmStop()) { // We could pause the game here and resume it if they say no. QMessageBox::StandardButton confirm; @@ -313,7 +313,7 @@ void MainWindow::StartGame(const QString& path) void MainWindow::ShowRenderWidget() { - Settings settings; + auto& settings = Settings::Instance(); if (settings.GetRenderToMain()) { // If we're rendering to main, add it to the stack and update our title when necessary. @@ -432,6 +432,6 @@ void MainWindow::StateSaveOldest() void MainWindow::SetStateSlot(int slot) { - Settings().SetStateSlot(slot); + Settings::Instance().SetStateSlot(slot); m_state_slot = slot; } diff --git a/Source/Core/DolphinQt2/MenuBar.cpp b/Source/Core/DolphinQt2/MenuBar.cpp index f387b6864d..ef9a449621 100644 --- a/Source/Core/DolphinQt2/MenuBar.cpp +++ b/Source/Core/DolphinQt2/MenuBar.cpp @@ -140,7 +140,7 @@ void MenuBar::AddStateSlotMenu(QMenu* emu_menu) QAction* action = m_state_slot_menu->addAction(QStringLiteral("")); action->setCheckable(true); action->setActionGroup(m_state_slots); - if (Settings().GetStateSlot() == i) + if (Settings::Instance().GetStateSlot() == i) action->setChecked(true); connect(action, &QAction::triggered, this, [=]() { emit SetStateSlot(i); }); @@ -203,7 +203,7 @@ void MenuBar::AddGameListTypeSection(QMenu* view_menu) list_group->addAction(table_view); list_group->addAction(list_view); - bool prefer_table = Settings().GetPreferredView(); + bool prefer_table = Settings::Instance().GetPreferredView(); table_view->setChecked(prefer_table); list_view->setChecked(!prefer_table); @@ -213,15 +213,16 @@ void MenuBar::AddGameListTypeSection(QMenu* view_menu) void MenuBar::AddTableColumnsMenu(QMenu* view_menu) { - static const QMap columns{{tr("Platform"), &Settings().PlatformVisible()}, - {tr("ID"), &Settings().IDVisible()}, - {tr("Banner"), &Settings().BannerVisible()}, - {tr("Title"), &Settings().TitleVisible()}, - {tr("Description"), &Settings().DescriptionVisible()}, - {tr("Maker"), &Settings().MakerVisible()}, - {tr("Size"), &Settings().SizeVisible()}, - {tr("Country"), &Settings().CountryVisible()}, - {tr("Quality"), &Settings().StateVisible()}}; + auto& settings = Settings::Instance(); + static const QMap columns{{tr("Platform"), &settings.PlatformVisible()}, + {tr("ID"), &settings.IDVisible()}, + {tr("Banner"), &settings.BannerVisible()}, + {tr("Title"), &settings.TitleVisible()}, + {tr("Description"), &settings.DescriptionVisible()}, + {tr("Maker"), &settings.MakerVisible()}, + {tr("Size"), &settings.SizeVisible()}, + {tr("Country"), &settings.CountryVisible()}, + {tr("Quality"), &settings.StateVisible()}}; QActionGroup* column_group = new QActionGroup(this); QMenu* cols_menu = view_menu->addMenu(tr("Table Columns")); @@ -235,7 +236,7 @@ void MenuBar::AddTableColumnsMenu(QMenu* view_menu) action->setChecked(*config); connect(action, &QAction::toggled, [this, config, key](bool value) { *config = value; - Settings().Save(); + Settings::Instance().Save(); emit ColumnVisibilityToggled(key, value); }); } diff --git a/Source/Core/DolphinQt2/Resources.cpp b/Source/Core/DolphinQt2/Resources.cpp index 27639023cf..69b1b22515 100644 --- a/Source/Core/DolphinQt2/Resources.cpp +++ b/Source/Core/DolphinQt2/Resources.cpp @@ -47,22 +47,22 @@ QPixmap Resources::GetPixmap(const QString& name, const QString& dir) QIcon Resources::GetScaledIcon(const std::string& name) { - return GetIcon(QString::fromStdString(name), Settings().GetResourcesDir()); + return GetIcon(QString::fromStdString(name), Settings::Instance().GetResourcesDir()); } QIcon Resources::GetScaledThemeIcon(const std::string& name) { - return GetIcon(QString::fromStdString(name), Settings().GetThemeDir()); + return GetIcon(QString::fromStdString(name), Settings::Instance().GetThemeDir()); } QPixmap Resources::GetScaledPixmap(const std::string& name) { - return GetPixmap(QString::fromStdString(name), Settings().GetResourcesDir()); + return GetPixmap(QString::fromStdString(name), Settings::Instance().GetResourcesDir()); } QPixmap Resources::GetScaledThemePixmap(const std::string& name) { - return GetPixmap(QString::fromStdString(name), Settings().GetThemeDir()); + return GetPixmap(QString::fromStdString(name), Settings::Instance().GetThemeDir()); } void Resources::Init() diff --git a/Source/Core/DolphinQt2/Settings.cpp b/Source/Core/DolphinQt2/Settings.cpp index 248589a8a1..88bb0e1c28 100644 --- a/Source/Core/DolphinQt2/Settings.cpp +++ b/Source/Core/DolphinQt2/Settings.cpp @@ -17,10 +17,16 @@ static QString GetSettingsPath() return QString::fromStdString(File::GetUserPath(D_CONFIG_IDX)) + QStringLiteral("/UI.ini"); } -Settings::Settings(QObject* parent) : QSettings(GetSettingsPath(), QSettings::IniFormat, parent) +Settings::Settings() : QSettings(GetSettingsPath(), QSettings::IniFormat) { } +Settings& Settings::Instance() +{ + static Settings settings; + return settings; +} + QString Settings::GetThemeDir() const { return QString::fromStdString(File::GetThemeDir(SConfig::GetInstance().theme_name)); diff --git a/Source/Core/DolphinQt2/Settings.h b/Source/Core/DolphinQt2/Settings.h index fa01aac02d..817139056c 100644 --- a/Source/Core/DolphinQt2/Settings.h +++ b/Source/Core/DolphinQt2/Settings.h @@ -7,6 +7,7 @@ #include #include +#include "Common/NonCopyable.h" #include "Core/HW/SI/SI.h" namespace DiscIO @@ -17,12 +18,12 @@ enum class Language; class InputConfig; // UI settings to be stored in the config directory. -class Settings final : public QSettings +class Settings final : public QSettings, NonCopyable { Q_OBJECT public: - explicit Settings(QObject* parent = nullptr); + static Settings& Instance(); // UI QString GetThemeDir() const; @@ -105,4 +106,7 @@ public: void SetGCAdapterSimulatingDKBongos(int port, bool enabled); void Save(); + +private: + Settings(); }; diff --git a/Source/Core/DolphinQt2/Settings/GeneralPane.cpp b/Source/Core/DolphinQt2/Settings/GeneralPane.cpp index f9e5e53f33..06862c8473 100644 --- a/Source/Core/DolphinQt2/Settings/GeneralPane.cpp +++ b/Source/Core/DolphinQt2/Settings/GeneralPane.cpp @@ -140,11 +140,12 @@ void GeneralPane::CreateAdvanced() void GeneralPane::LoadConfig() { - m_checkbox_force_ntsc->setChecked(Settings().GetForceNTSCJ()); - m_checkbox_enable_analytics->setChecked(Settings().GetAnalyticsEnabled()); + auto& settings = Settings::Instance(); + m_checkbox_force_ntsc->setChecked(settings.GetForceNTSCJ()); + m_checkbox_enable_analytics->setChecked(settings.GetAnalyticsEnabled()); m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread); m_checkbox_cheats->setChecked(SConfig::GetInstance().bEnableCheats); - int selection = qRound(Settings().GetEmulationSpeed() * 10); + int selection = qRound(settings.GetEmulationSpeed() * 10); if (selection < m_combobox_speedlimit->count()) m_combobox_speedlimit->setCurrentIndex(selection); m_checkbox_dualcore->setChecked(SConfig::GetInstance().bCPUThread); @@ -170,8 +171,9 @@ void GeneralPane::LoadConfig() void GeneralPane::OnSaveConfig() { - Settings().SetForceNTSCJ(m_checkbox_force_ntsc->isChecked()); - Settings().SetAnalyticsEnabled(m_checkbox_enable_analytics->isChecked()); + auto& settings = Settings::Instance(); + settings.SetForceNTSCJ(m_checkbox_force_ntsc->isChecked()); + settings.SetAnalyticsEnabled(m_checkbox_enable_analytics->isChecked()); SConfig::GetInstance().bCPUThread = m_checkbox_dualcore->isChecked(); SConfig::GetInstance().bEnableCheats = m_checkbox_cheats->isChecked(); SConfig::GetInstance().m_EmulationSpeed = m_combobox_speedlimit->currentIndex() * 0.1f;