mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
DolphinQt2: make Settings a singleton
With this, we can get signals when properties change.
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user