Skip to content

Commit

Permalink
Qt: add apply button to settings dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Feb 21, 2020
1 parent e005581 commit 0ed87be
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
5 changes: 3 additions & 2 deletions rpcs3/rpcs3qt/game_list_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,15 +1059,16 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
connect(configure, &QAction::triggered, [=, this]()
{
settings_dialog dlg(m_gui_settings, m_emu_settings, 0, this, &currGame);
if (dlg.exec() == QDialog::Accepted)
connect(&dlg, &settings_dialog::EmuSettingsApplied, [this, gameinfo]()
{
if (!gameinfo->hasCustomConfig)
{
gameinfo->hasCustomConfig = true;
ShowCustomConfigIcon(gameinfo);
}
Q_EMIT NotifyEmuSettingsChange();
}
});
dlg.exec();
});
connect(pad_configure, &QAction::triggered, [=, this]()
{
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/rpcs3qt/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,8 +1333,8 @@ void main_window::CreateConnects()
connect(&dlg, &settings_dialog::GuiSettingsSyncRequest, this, &main_window::ConfigureGuiFromSettings);
connect(&dlg, &settings_dialog::GuiStylesheetRequest, this, &main_window::RequestGlobalStylesheetChange);
connect(&dlg, &settings_dialog::GuiRepaintRequest, this, &main_window::RepaintGui);
connect(&dlg, &settings_dialog::accepted, this, &main_window::NotifyEmuSettingsChange);
connect(&dlg, &settings_dialog::accepted, m_logFrame, &log_frame::LoadSettings);
connect(&dlg, &settings_dialog::EmuSettingsApplied, this, &main_window::NotifyEmuSettingsChange);
connect(&dlg, &settings_dialog::EmuSettingsApplied, m_logFrame, &log_frame::LoadSettings);
dlg.exec();
};

Expand Down
25 changes: 22 additions & 3 deletions rpcs3/rpcs3qt/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
m_discord_state = xgui_settings->GetValue(gui::m_discordState).toString();

// Various connects
connect(ui->buttonBox, &QDialogButtonBox::accepted, [this, use_discord_old = m_use_discord, discord_state_old = m_discord_state]

const auto apply_configs = [this, use_discord_old = m_use_discord, discord_state_old = m_discord_state](bool do_exit)
{
std::set<std::string> selectedlle;
for (int i = 0; i<ui->lleList->count(); ++i)
for (int i = 0; i < ui->lleList->count(); ++i)
{
const auto& item = ui->lleList->item(i);
if (item->checkState() != Qt::CheckState::Unchecked)
Expand All @@ -106,7 +107,13 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
std::vector<std::string> selected_ls = std::vector<std::string>(selectedlle.begin(), selectedlle.end());
xemu_settings->SaveSelectedLibraries(selected_ls);
xemu_settings->SaveSettings();
accept();

if (do_exit)
{
accept();
}

Q_EMIT EmuSettingsApplied();

// Discord Settings can be saved regardless of WITH_DISCORD_RPC
xgui_settings->SetValue(gui::m_richPresence, m_use_discord);
Expand All @@ -130,6 +137,18 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
discord::update_presence(sstr(m_discord_state), "Idle", false);
}
#endif
};

connect(ui->buttonBox, &QDialogButtonBox::clicked, [=, this](QAbstractButton* button)
{
if (button == ui->buttonBox->button(QDialogButtonBox::Save))
{
apply_configs(true);
}
else if (button == ui->buttonBox->button(QDialogButtonBox::Apply))
{
apply_configs(false);
}
});

connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/settings_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class settings_dialog : public QDialog
void GuiStylesheetRequest(const QString& path);
void GuiSettingsSaveRequest();
void GuiRepaintRequest();
void EmuSettingsApplied();
private Q_SLOTS:
void OnBackupCurrentConfig();
void OnApplyConfig();
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3220,7 +3220,7 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Close|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
Expand Down

0 comments on commit 0ed87be

Please sign in to comment.