Qt: Use QDialog::Accepted/Rejected in more places

This commit is contained in:
Davide Pesavento 2025-06-21 15:52:22 -04:00 committed by Connor McLaughlin
parent 842f7414d9
commit 976bf834ed
8 changed files with 13 additions and 17 deletions

View File

@ -220,8 +220,7 @@ void AchievementSettingsWidget::onLoginLogoutPressed()
}
AchievementLoginDialog login(this, Achievements::LoginRequestReason::UserInitiated);
int res = login.exec();
if (res == QDialog::Rejected)
if (login.exec() == QDialog::Rejected)
return;
updateLoginState();

View File

@ -401,7 +401,7 @@ bool ControllerBindingWidget::doMultipleDeviceAutomaticBinding(QWidget* parent,
connect(&bb, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
layout->addWidget(&bb);
if (dialog.exec() == 0)
if (dialog.exec() == QDialog::Rejected)
return false;
auto lock = Host::GetSettingsLock();

View File

@ -186,7 +186,7 @@ void DebuggerWindow::onFollowAddressTriggered()
void DebuggerWindow::onAddBreakpointTriggered()
{
DebuggerAddBreakpointDialog dlg(this);
if (!dlg.exec())
if (dlg.exec() == QDialog::Rejected)
return;
addBreakpoint(dlg.getType(), dlg.getAddress());

View File

@ -635,7 +635,7 @@ void GameCheatSettingsWidget::newCode()
{
Cheats::CodeInfo new_code;
CheatCodeEditorDialog dlg(this, &new_code, getGroupNames());
if (!dlg.exec())
if (dlg.exec() == QDialog::Rejected)
{
// cancelled
return;
@ -653,7 +653,7 @@ void GameCheatSettingsWidget::editCode(const std::string_view code_name)
return;
CheatCodeEditorDialog dlg(this, code, getGroupNames());
if (!dlg.exec())
if (dlg.exec() == QDialog::Rejected)
{
// no changes
return;
@ -949,7 +949,7 @@ void CheatCodeEditorDialog::onRangeMaxChanged(int value)
void CheatCodeEditorDialog::onEditChoiceClicked()
{
GameCheatCodeChoiceEditorDialog dlg(this, m_new_options);
if (dlg.exec())
if (dlg.exec() == QDialog::Accepted)
m_new_options = dlg.getNewOptions();
}

View File

@ -1331,7 +1331,7 @@ void GraphicsSettingsWidget::onTextureReplacementOptionsClicked()
idlg.setLabelText(tr("Texture Replacement Configuration (config.yaml)"));
idlg.setTextValue(QString::fromStdString(config.ExportToYAML(false)));
idlg.setOkButtonText(tr("Save"));
if (idlg.exec())
if (idlg.exec() != QDialog::Rejected)
{
const QString path = QFileDialog::getSaveFileName(&dlg, tr("Save Configuration"), QString(),
tr("Configuration Files (config.yaml)"));

View File

@ -471,7 +471,7 @@ void InputVibrationBindingWidget::onClicked()
input_dialog.setComboBoxEditable(false);
input_dialog.setComboBoxItems(std::move(input_options));
input_dialog.setTextValue(current);
if (input_dialog.exec() == 0)
if (input_dialog.exec() == QDialog::Rejected)
return;
const QString new_value(input_dialog.textValue());

View File

@ -697,7 +697,7 @@ std::string MainWindow::getDeviceDiscPath(const QString& title)
input_dialog.setOptions(QInputDialog::UseListViewForComboBoxItems);
input_dialog.setComboBoxEditable(false);
input_dialog.setComboBoxItems(std::move(input_options));
if (input_dialog.exec() == 0)
if (input_dialog.exec() == QDialog::Rejected)
return ret;
const int selected_index = input_dialog.comboBoxItems().indexOf(input_dialog.textValue());
@ -1065,7 +1065,7 @@ const GameList::Entry* MainWindow::resolveDiscSetEntry(const GameList::Entry* en
const int res = dlg.exec();
lock.lock();
return res ? GameList::GetEntryForPath(dlg.getSelectedDiscPath()) : nullptr;
return res == QDialog::Accepted ? GameList::GetEntryForPath(dlg.getSelectedDiscPath()) : nullptr;
}
std::shared_ptr<SystemBootParameters> MainWindow::getSystemBootParameters(std::string file)

View File

@ -721,13 +721,10 @@ MemoryCardRenameFileDialog::~MemoryCardRenameFileDialog() = default;
std::string MemoryCardRenameFileDialog::promptForNewName(QWidget* parent, std::string_view old_name)
{
MemoryCardRenameFileDialog dlg(parent, old_name);
if (dlg.exec() == QDialog::Rejected)
return {};
std::string ret;
if (dlg.exec() != 1)
return ret;
ret = dlg.m_ui.fullFilename->text().toStdString();
return ret;
return dlg.m_ui.fullFilename->text().toStdString();
}
void MemoryCardRenameFileDialog::setupAdditionalUi()