From 6348af586e80545cae112850ab369b1a93ba45c9 Mon Sep 17 00:00:00 2001 From: pvdk Date: Fri, 30 May 2014 02:12:48 +0200 Subject: [PATCH] Fixed some problems with the launcher and the wizard --- apps/launcher/datafilespage.cpp | 10 +--- apps/launcher/datafilespage.hpp | 2 - apps/launcher/main.cpp | 10 ++-- apps/launcher/maindialog.cpp | 71 ++++++++++++------------ apps/wizard/existinginstallationpage.cpp | 14 +++-- apps/wizard/mainwizard.cpp | 6 -- 6 files changed, 50 insertions(+), 63 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 6b53d89a4..17951f2e4 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -36,7 +36,7 @@ Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, Config: this, SLOT(updateOkButton(QString))); buildView(); - setupDataFiles(); + loadSettings(); } void Launcher::DataFilesPage::buildView() @@ -67,7 +67,7 @@ void Launcher::DataFilesPage::buildView() this, SLOT (slotProfileChangedByUser(QString, QString))); } -void Launcher::DataFilesPage::setupDataFiles() +bool Launcher::DataFilesPage::loadSettings() { QStringList paths = mGameSettings.getDataDirs(); @@ -79,12 +79,6 @@ void Launcher::DataFilesPage::setupDataFiles() if (!mDataLocal.isEmpty()) mSelector->addFiles(mDataLocal); - loadSettings(); -} - -bool Launcher::DataFilesPage::loadSettings() -{ - QStringList paths = mGameSettings.getDataDirs(); paths.insert (0, mDataLocal); PathIterator pathIterator (paths); diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 908394ae1..5beeb0e03 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -41,8 +41,6 @@ namespace Launcher void saveSettings(const QString &profile = ""); bool loadSettings(); - void setupDataFiles(); - signals: void signalProfileChanged (int index); diff --git a/apps/launcher/main.cpp b/apps/launcher/main.cpp index 67320bff0..da319426d 100644 --- a/apps/launcher/main.cpp +++ b/apps/launcher/main.cpp @@ -52,12 +52,12 @@ int main(int argc, char *argv[]) Launcher::MainDialog mainWin; - if (!mainWin.setup()) { + if (!mainWin.showFirstRunDialog()) return 0; - //mainWin.show(); - }/* else { - return 0; - }*/ + +// if (!mainWin.setup()) +// return 0; + int returnValue = app.exec(); SDL_Quit(); diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 708969516..c66de0b03 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -165,40 +165,44 @@ void Launcher::MainDialog::createPages() bool Launcher::MainDialog::showFirstRunDialog() { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("First run")); - msgBox.setIcon(QMessageBox::Question); - msgBox.setStandardButtons(QMessageBox::NoButton); - msgBox.setText(tr("

Welcome to OpenMW!

\ -

It is recommended to run the Installation Wizard.

\ -

The Wizard will let you select an existing Morrowind installation, \ - or install Morrowind for OpenMW to use.

")); - QAbstractButton *wizardButton = - msgBox.addButton(tr("Run &Installation Wizard"), QMessageBox::AcceptRole); // ActionRole doesn't work?! - QAbstractButton *skipButton = - msgBox.addButton(tr("Skip"), QMessageBox::RejectRole); - Q_UNUSED(skipButton); // Surpress compiler unused warning - - msgBox.exec(); - - if (msgBox.clickedButton() == wizardButton) + if (!setupLauncherSettings()) + return false; + + if (mLauncherSettings.value(QString("General/firstrun"), QString("true")) == QLatin1String("true")) { - if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false)) { - return false; - } else { - return true; + QMessageBox msgBox; + msgBox.setWindowTitle(tr("First run")); + msgBox.setIcon(QMessageBox::Question); + msgBox.setStandardButtons(QMessageBox::NoButton); + msgBox.setText(tr("

Welcome to OpenMW!

\ +

It is recommended to run the Installation Wizard.

\ +

The Wizard will let you select an existing Morrowind installation, \ + or install Morrowind for OpenMW to use.

")); + + QAbstractButton *wizardButton = + msgBox.addButton(tr("Run &Installation Wizard"), QMessageBox::AcceptRole); // ActionRole doesn't work?! + QAbstractButton *skipButton = + msgBox.addButton(tr("Skip"), QMessageBox::RejectRole); + + Q_UNUSED(skipButton); // Surpress compiler unused warning + + msgBox.exec(); + + if (msgBox.clickedButton() == wizardButton) + { + if (!mWizardInvoker->startProcess(QLatin1String("openmw-wizard"), false)) { + return false; + } else { + return true; + } } } - show(); - return true; + return setup(); } bool Launcher::MainDialog::setup() { - if (!setupLauncherSettings()) - return false; - if (!setupGameSettings()) return false; @@ -214,17 +218,7 @@ bool Launcher::MainDialog::setup() loadSettings(); - // Check if we need to run the wizard - if (mLauncherSettings.value(QString("General/firstrun"), QString("true")) == QLatin1String("true")) - { - if (!showFirstRunDialog()) { - return false; - } else { - return true; - } - } - - show(); // Show ourselves if the wizard is not being run + show(); return true; } @@ -629,6 +623,9 @@ void Launcher::MainDialog::wizardFinished(int exitCode, QProcess::ExitStatus exi if (exitCode != 0 || exitStatus == QProcess::CrashExit) return qApp->quit(); + if (!setup()) + return; + reloadSettings(); show(); } diff --git a/apps/wizard/existinginstallationpage.cpp b/apps/wizard/existinginstallationpage.cpp index 7171cb26b..83ea20f5a 100644 --- a/apps/wizard/existinginstallationpage.cpp +++ b/apps/wizard/existinginstallationpage.cpp @@ -15,14 +15,16 @@ Wizard::ExistingInstallationPage::ExistingInstallationPage(QWidget *parent) : setupUi(this); + // Add a placeholder item to the list of installations + QListWidgetItem *emptyItem = new QListWidgetItem(tr("No existing installations detected")); + emptyItem->setFlags(Qt::NoItemFlags); + + installationsList->insertItem(0, emptyItem); + } void Wizard::ExistingInstallationPage::initializePage() { - QListWidgetItem *emptyItem = new QListWidgetItem(tr("No existing installations detected")); - emptyItem->setFlags(Qt::NoItemFlags); - installationsList->addItem(emptyItem); - // Add the available installation paths QStringList paths(mWizard->mInstallations.keys()); @@ -35,7 +37,9 @@ void Wizard::ExistingInstallationPage::initializePage() foreach (const QString &path, paths) { QListWidgetItem *item = new QListWidgetItem(path); - installationsList->addItem(item); + + if (installationsList->findItems(path, Qt::MatchExactly).isEmpty()) + installationsList->addItem(item); } connect(installationsList, SIGNAL(currentTextChanged(QString)), diff --git a/apps/wizard/mainwizard.cpp b/apps/wizard/mainwizard.cpp index 2469cfa8b..e587d77e5 100644 --- a/apps/wizard/mainwizard.cpp +++ b/apps/wizard/mainwizard.cpp @@ -37,9 +37,6 @@ Wizard::MainWizard::MainWizard(QWidget *parent) : setWindowIcon(QIcon(QLatin1String(":/images/openmw-wizard.png"))); setMinimumWidth(550); - // This prevents initializePage() being called multiple times - setOption(QWizard::IndependentPages); - // Set the property for comboboxes to the text instead of index setDefaultProperty("QComboBox", "currentText", "currentIndexChanged"); @@ -283,9 +280,6 @@ void Wizard::MainWizard::runSettingsImporter() if (!mImporterInvoker->startProcess(QLatin1String("mwiniimport"), arguments, false)) return qApp->quit(); - - // Re-read the game settings - setupGameSettings(); } void Wizard::MainWizard::addInstallation(const QString &path)