Merge pull request #7847 from spycrab/qt_modal_more

Qt: Make a lot of message boxes modal
This commit is contained in:
spycrab 2019-03-03 17:07:45 +01:00 committed by GitHub
commit 8f06ab02ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 13 deletions

View File

@ -330,6 +330,7 @@ void ControllersWindow::OnBluetoothPassthroughResetPressed()
{ {
QMessageBox error(this); QMessageBox error(this);
error.setIcon(QMessageBox::Warning); error.setIcon(QMessageBox::Warning);
error.setWindowModality(Qt::WindowModal);
error.setWindowTitle(tr("Warning")); error.setWindowTitle(tr("Warning"));
error.setText(tr("Saved Wii Remote pairings can only be reset when a Wii game is running.")); error.setText(tr("Saved Wii Remote pairings can only be reset when a Wii game is running."));
error.exec(); error.exec();
@ -351,6 +352,7 @@ void ControllersWindow::OnBluetoothPassthroughSyncPressed()
{ {
QMessageBox error(this); QMessageBox error(this);
error.setIcon(QMessageBox::Warning); error.setIcon(QMessageBox::Warning);
error.setWindowModality(Qt::WindowModal);
error.setWindowTitle(tr("Warning")); error.setWindowTitle(tr("Warning"));
error.setText(tr("A sync can only be triggered when a Wii game is running.")); error.setText(tr("A sync can only be triggered when a Wii game is running."));
error.exec(); error.exec();

View File

@ -161,6 +161,7 @@ void MappingWindow::OnDeleteProfilePressed()
{ {
QMessageBox error(this); QMessageBox error(this);
error.setIcon(QMessageBox::Critical); error.setIcon(QMessageBox::Critical);
error.setWindowModality(Qt::WindowModal);
error.setWindowTitle(tr("Error")); error.setWindowTitle(tr("Error"));
error.setText(tr("The profile '%1' does not exist").arg(profile_name)); error.setText(tr("The profile '%1' does not exist").arg(profile_name));
error.exec(); error.exec();
@ -170,6 +171,7 @@ void MappingWindow::OnDeleteProfilePressed()
QMessageBox confirm(this); QMessageBox confirm(this);
confirm.setIcon(QMessageBox::Warning); confirm.setIcon(QMessageBox::Warning);
confirm.setWindowModality(Qt::WindowModal);
confirm.setWindowTitle(tr("Confirm")); confirm.setWindowTitle(tr("Confirm"));
confirm.setText(tr("Are you sure that you want to delete '%1'?").arg(profile_name)); confirm.setText(tr("Are you sure that you want to delete '%1'?").arg(profile_name));
confirm.setInformativeText(tr("This cannot be undone!")); confirm.setInformativeText(tr("This cannot be undone!"));
@ -186,6 +188,7 @@ void MappingWindow::OnDeleteProfilePressed()
QMessageBox result(this); QMessageBox result(this);
result.setIcon(QMessageBox::Information); result.setIcon(QMessageBox::Information);
result.setWindowModality(Qt::WindowModal);
result.setWindowTitle(tr("Success")); result.setWindowTitle(tr("Success"));
result.setText(tr("Successfully deleted '%1'.").arg(profile_name)); result.setText(tr("Successfully deleted '%1'.").arg(profile_name));
} }

View File

@ -204,7 +204,12 @@ void FIFOPlayerWindow::SaveRecording()
bool result = file->Save(path.toStdString()); bool result = file->Save(path.toStdString());
if (!result) if (!result)
QMessageBox::critical(this, tr("Error"), tr("Failed to save FIFO log.")); {
QMessageBox msg(QMessageBox::Critical, tr("Error"), tr("Failed to save FIFO log."),
QMessageBox::Ok, this);
msg.setWindowModality(Qt::WindowModal);
msg.exec();
}
} }
void FIFOPlayerWindow::StartRecording() void FIFOPlayerWindow::StartRecording()

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

View File

@ -324,6 +324,7 @@ void GeneralPane::GenerateNewIdentity()
DolphinAnalytics::Instance()->ReloadConfig(); DolphinAnalytics::Instance()->ReloadConfig();
QMessageBox message_box(this); QMessageBox message_box(this);
message_box.setIcon(QMessageBox::Information); message_box.setIcon(QMessageBox::Information);
message_box.setWindowModality(Qt::WindowModal);
message_box.setWindowTitle(tr("Identity Generation")); message_box.setWindowTitle(tr("Identity Generation"));
message_box.setText(tr("New identity generated.")); message_box.setText(tr("New identity generated."));
message_box.exec(); message_box.exec();

View File

@ -269,9 +269,12 @@ void InterfacePane::OnSaveConfig()
if (new_language != SConfig::GetInstance().m_InterfaceLanguage) if (new_language != SConfig::GetInstance().m_InterfaceLanguage)
{ {
SConfig::GetInstance().m_InterfaceLanguage = new_language; SConfig::GetInstance().m_InterfaceLanguage = new_language;
QMessageBox::information( QMessageBox msg(QMessageBox::Information, tr("Restart Required"),
this, tr("Restart Required"), tr("You must restart Dolphin in order for the change to take effect."),
tr("You must restart Dolphin in order for the change to take effect.")); QMessageBox::Ok, this);
msg.setWindowModality(Qt::WindowModal);
msg.exec();
} }
const bool use_covers = m_checkbox_use_covers->isChecked(); const bool use_covers = m_checkbox_use_covers->isChecked();

View File

@ -131,6 +131,7 @@ void USBDeviceAddToWhitelistDialog::AddUSBDeviceToWhitelist()
// i18n: Here, VID means Vendor ID (for a USB device). // i18n: Here, VID means Vendor ID (for a USB device).
QMessageBox vid_warning_box(this); QMessageBox vid_warning_box(this);
vid_warning_box.setIcon(QMessageBox::Warning); vid_warning_box.setIcon(QMessageBox::Warning);
vid_warning_box.setWindowModality(Qt::WindowModal);
vid_warning_box.setWindowTitle(tr("USB Whitelist Error")); vid_warning_box.setWindowTitle(tr("USB Whitelist Error"));
// i18n: Here, VID means Vendor ID (for a USB device). // i18n: Here, VID means Vendor ID (for a USB device).
vid_warning_box.setText(tr("The entered VID is invalid.")); vid_warning_box.setText(tr("The entered VID is invalid."));
@ -143,6 +144,7 @@ void USBDeviceAddToWhitelistDialog::AddUSBDeviceToWhitelist()
// i18n: Here, PID means Product ID (for a USB device). // i18n: Here, PID means Product ID (for a USB device).
QMessageBox pid_warning_box(this); QMessageBox pid_warning_box(this);
pid_warning_box.setIcon(QMessageBox::Warning); pid_warning_box.setIcon(QMessageBox::Warning);
pid_warning_box.setWindowModality(Qt::WindowModal);
pid_warning_box.setWindowTitle(tr("USB Whitelist Error")); pid_warning_box.setWindowTitle(tr("USB Whitelist Error"));
// i18n: Here, PID means Product ID (for a USB device). // i18n: Here, PID means Product ID (for a USB device).
pid_warning_box.setText(tr("The entered PID is invalid.")); pid_warning_box.setText(tr("The entered PID is invalid."));
@ -156,8 +158,12 @@ void USBDeviceAddToWhitelistDialog::AddUSBDeviceToWhitelist()
if (SConfig::GetInstance().IsUSBDeviceWhitelisted({vid, pid})) if (SConfig::GetInstance().IsUSBDeviceWhitelisted({vid, pid}))
{ {
QErrorMessage* error = new QErrorMessage(); QMessageBox error_box(this);
error->showMessage(tr("This USB device is already whitelisted.")); error_box.setIcon(QMessageBox::Warning);
error_box.setWindowModality(Qt::WindowModal);
error_box.setWindowTitle(tr("USB Whitelist Error"));
error_box.setText(tr("This USB device is already whitelisted."));
error_box.exec();
return; return;
} }
SConfig::GetInstance().m_usb_passthrough_devices.emplace(vid, pid); SConfig::GetInstance().m_usb_passthrough_devices.emplace(vid, pid);