diff --git a/apps/wizard/mainwizard.cpp b/apps/wizard/mainwizard.cpp index 2affa170a4..7c419de031 100644 --- a/apps/wizard/mainwizard.cpp +++ b/apps/wizard/mainwizard.cpp @@ -56,11 +56,13 @@ Wizard::MainWizard::MainWizard(Files::ConfigurationManager&& cfgMgr, QWidget* pa const QString userPath(Files::pathToQString(mCfgMgr.getUserConfigPath())); if (!QDir(userPath).exists()) { + const QString title = tr("Error creating OpenMW configuration directory"); const QString message = tr( "
Could not create %1
" "Please make sure you have the right permissions and try again.
"); - showCriticalError(tr("Error creating OpenMW configuration directory"), message.arg(userPath)); - // TODO: consider quitting instantly if this or config file opening fails + QMessageBox::critical(nullptr, title, message.arg(userPath)); + QApplication::quit(); + return; } std::filesystem::create_directories(mCfgMgr.getUserDataPath()); @@ -96,7 +98,8 @@ void Wizard::MainWizard::setupGameSettings() { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - showCriticalError(title, message.arg(file.fileName())); + QMessageBox::critical(nullptr, title, message.arg(file.fileName())); + QApplication::quit(); return; } QTextStream stream(&file); @@ -118,7 +121,8 @@ void Wizard::MainWizard::setupGameSettings() { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - showCriticalError(title, message.arg(file.fileName())); + QMessageBox::critical(nullptr, title, message.arg(file.fileName())); + QApplication::quit(); return; } QTextStream stream(&file); @@ -148,7 +152,8 @@ void Wizard::MainWizard::setupLauncherSettings() "Could not open %1 for reading
" "Please make sure you have the right permissions " "and try again.
"); - showCriticalError(title, message.arg(file.fileName())); + QMessageBox::critical(nullptr, title, message.arg(file.fileName())); + QApplication::quit(); return; } QTextStream stream(&file); @@ -286,16 +291,10 @@ void Wizard::MainWizard::accept() void Wizard::MainWizard::reject() { - QMessageBox msgBox(this); - msgBox.setWindowTitle(tr("Quit Wizard")); - msgBox.setIcon(QMessageBox::Question); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setText(tr("Are you sure you want to exit the Wizard?")); - - if (msgBox.exec() == QMessageBox::Yes) - { + const QString title = tr("Quit Wizard"); + const QString message = tr("Are you sure you want to exit the Wizard?"); + if (QMessageBox::question(this, title, message) == QMessageBox::Yes) QWizard::reject(); - } } void Wizard::MainWizard::writeSettings() @@ -335,7 +334,8 @@ void Wizard::MainWizard::writeSettings() if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) { - showCriticalError(writeTitle, writeMessage.arg(file.fileName()), this); + QMessageBox::critical(this, writeTitle, writeMessage.arg(file.fileName())); + QApplication::quit(); return; } @@ -351,7 +351,8 @@ void Wizard::MainWizard::writeSettings() if (!file.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) { - showCriticalError(writeTitle, writeMessage.arg(file.fileName()), this); + QMessageBox::critical(this, writeTitle, writeMessage.arg(file.fileName())); + QApplication::quit(); return; } @@ -374,14 +375,3 @@ bool Wizard::MainWizard::findFiles(const QString& name, const QString& path) return entries.contains(name + QLatin1String(".esm"), Qt::CaseInsensitive) && entries.contains(name + QLatin1String(".bsa"), Qt::CaseInsensitive); } - -void Wizard::MainWizard::showCriticalError(const QString& title, const QString& message, QWidget* parent) -{ - QMessageBox msgBox(parent); - msgBox.setWindowTitle(title); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(message); - connect(&msgBox, &QDialog::finished, qApp, &QApplication::quit, Qt::QueuedConnection); - msgBox.exec(); -} diff --git a/apps/wizard/mainwizard.hpp b/apps/wizard/mainwizard.hpp index 77ecfa23bb..895935f9f2 100644 --- a/apps/wizard/mainwizard.hpp +++ b/apps/wizard/mainwizard.hpp @@ -69,8 +69,6 @@ namespace Wizard void writeSettings(); - void showCriticalError(const QString& title, const QString& message, QWidget* parent = nullptr); - Config::GameSettings mGameSettings; Config::LauncherSettings mLauncherSettings;