Qt: add apply button to settings dialog

This commit is contained in:
Megamouse 2020-02-20 22:20:42 +01:00
parent e005581dda
commit 0ed87be47a
5 changed files with 29 additions and 8 deletions

View file

@ -1059,7 +1059,7 @@ 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)
{
@ -1067,7 +1067,8 @@ void game_list_frame::ShowContextMenu(const QPoint &pos)
ShowCustomConfigIcon(gameinfo);
}
Q_EMIT NotifyEmuSettingsChange();
}
});
dlg.exec();
});
connect(pad_configure, &QAction::triggered, [=, this]()
{

View file

@ -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();
};

View file

@ -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)
@ -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);
@ -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);

View file

@ -29,6 +29,7 @@ Q_SIGNALS:
void GuiStylesheetRequest(const QString& path);
void GuiSettingsSaveRequest();
void GuiRepaintRequest();
void EmuSettingsApplied();
private Q_SLOTS:
void OnBackupCurrentConfig();
void OnApplyConfig();

View file

@ -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>