Qt/GCMemcardManager: Make message boxes modal

This commit is contained in:
spycrab 2019-03-03 16:36:58 +01:00
parent 326e2fb300
commit 0d203cf0bb

View File

@ -306,7 +306,10 @@ void GCMemcardManager::ExportFiles(bool prompt)
QString text = count == 1 ? tr("Successfully exported the save file.") : QString text = count == 1 ? tr("Successfully exported the save file.") :
tr("Successfully exported the %1 save files.").arg(count); tr("Successfully exported the %1 save files.").arg(count);
QMessageBox::information(this, tr("Success"), text); QMessageBox msg(QMessageBox::Information, tr("Success"), text, QMessageBox::Ok, this);
msg.setWindowModality(Qt::WindowModal);
msg.exec();
} }
void GCMemcardManager::ExportAllFiles() void GCMemcardManager::ExportAllFiles()
@ -330,7 +333,10 @@ void GCMemcardManager::ImportFile()
if (result != SUCCESS) if (result != SUCCESS)
{ {
QMessageBox::critical(this, tr("Import failed"), tr("Failed to import \"%1\".").arg(path)); QMessageBox msg(QMessageBox::Critical, tr("Import failed"),
tr("Failed to import \"%1\".").arg(path), QMessageBox::Ok, this);
msg.setWindowModality(Qt::WindowModal);
msg.exec();
return; return;
} }
@ -355,7 +361,12 @@ void GCMemcardManager::CopyFiles()
const auto result = m_slot_memcard[!m_active_slot]->CopyFrom(*memcard, file_index); const auto result = m_slot_memcard[!m_active_slot]->CopyFrom(*memcard, file_index);
if (result != SUCCESS) if (result != SUCCESS)
QMessageBox::warning(this, tr("Copy failed"), tr("Failed to copy file")); {
QMessageBox msg(QMessageBox::Warning, tr("Copy failed"), tr("Failed to copy file"),
QMessageBox::Ok, this);
msg.setWindowModality(Qt::WindowModal);
msg.exec();
}
} }
for (int i = 0; i < SLOT_COUNT; i++) for (int i = 0; i < SLOT_COUNT; i++)
@ -379,8 +390,12 @@ void GCMemcardManager::DeleteFiles()
{ {
QString text = count == 1 ? tr("Do you want to delete the selected save file?") : QString text = count == 1 ? tr("Do you want to delete the selected save file?") :
tr("Do you want to delete the %1 selected save files?").arg(count); tr("Do you want to delete the %1 selected save files?").arg(count);
auto response =
QMessageBox::warning(this, tr("Question"), text, QMessageBox::Yes | QMessageBox::Abort); QMessageBox msg(QMessageBox::Warning, tr("Question"), text,
QMessageBox::Yes | QMessageBox::Abort, this);
msg.setWindowModality(Qt::WindowModal);
auto response = msg.exec();
if (response == QMessageBox::Abort) if (response == QMessageBox::Abort)
return; return;
@ -396,13 +411,25 @@ void GCMemcardManager::DeleteFiles()
for (int file_index : file_indices) for (int file_index : file_indices)
{ {
if (memcard->RemoveFile(file_index) != SUCCESS) if (memcard->RemoveFile(file_index) != SUCCESS)
QMessageBox::warning(this, tr("Remove failed"), tr("Failed to remove file")); {
QMessageBox msg(QMessageBox::Warning, tr("Remove failed"), tr("Failed to remove file"),
QMessageBox::Ok, this);
msg.setWindowModality(Qt::WindowModal);
msg.exec();
}
} }
if (!memcard->Save()) if (!memcard->Save())
{
PanicAlertT("File write failed"); PanicAlertT("File write failed");
}
else else
QMessageBox::information(this, tr("Success"), tr("Successfully deleted files.")); {
QMessageBox msg(QMessageBox::Information, tr("Success"), tr("Successfully deleted files."),
QMessageBox::Ok, this);
msg.setWindowModality(Qt::WindowModal);
msg.exec();
}
UpdateSlotTable(m_active_slot); UpdateSlotTable(m_active_slot);
UpdateActions(); UpdateActions();