diff --git a/apps/wizard/componentselectionpage.cpp b/apps/wizard/componentselectionpage.cpp index 19a07438d..ac084616c 100644 --- a/apps/wizard/componentselectionpage.cpp +++ b/apps/wizard/componentselectionpage.cpp @@ -74,7 +74,7 @@ void Wizard::ComponentSelectionPage::initializePage() componentsList->addItem(bloodmoonItem); } else { - if (mWizard->mInstallations[path]->hasMorrowind) { + if (mWizard->mInstallations[path].hasMorrowind) { morrowindItem->setText(tr("Morrowind\t\t(installed)")); morrowindItem->setFlags(morrowindItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); morrowindItem->setData(Qt::CheckStateRole, Qt::Unchecked); @@ -85,7 +85,7 @@ void Wizard::ComponentSelectionPage::initializePage() componentsList->addItem(morrowindItem); - if (mWizard->mInstallations[path]->hasTribunal) { + if (mWizard->mInstallations[path].hasTribunal) { tribunalItem->setText(tr("Tribunal\t\t(installed)")); tribunalItem->setFlags(tribunalItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); tribunalItem->setData(Qt::CheckStateRole, Qt::Unchecked); @@ -96,7 +96,7 @@ void Wizard::ComponentSelectionPage::initializePage() componentsList->addItem(tribunalItem); - if (mWizard->mInstallations[path]->hasBloodmoon) { + if (mWizard->mInstallations[path].hasBloodmoon) { bloodmoonItem->setText(tr("Bloodmoon\t\t(installed)")); bloodmoonItem->setFlags(bloodmoonItem->flags() & !Qt::ItemIsEnabled & Qt::ItemIsUserCheckable); bloodmoonItem->setData(Qt::CheckStateRole, Qt::Unchecked); @@ -114,12 +114,12 @@ bool Wizard::ComponentSelectionPage::validatePage() QStringList components(field(QLatin1String("installation.components")).toStringList()); QString path(field(QLatin1String("installation.path")).toString()); - qDebug() << components << path << mWizard->mInstallations[path]; +// qDebug() << components << path << mWizard->mInstallations[path]; if (field(QLatin1String("installation.new")).toBool() == false) { if (components.contains(QLatin1String("Tribunal")) && !components.contains(QLatin1String("Bloodmoon"))) { - if (mWizard->mInstallations[path]->hasBloodmoon) + if (mWizard->mInstallations[path].hasBloodmoon) { QMessageBox msgBox; msgBox.setWindowTitle(tr("About to install Tribunal after Bloodmoon")); @@ -136,7 +136,7 @@ bool Wizard::ComponentSelectionPage::validatePage() if (msgBox.clickedButton() == reinstallButton) { // Force reinstallation - mWizard->mInstallations[path]->hasBloodmoon = false; + mWizard->mInstallations[path].hasBloodmoon = false; QList items = componentsList->findItems(QLatin1String("Bloodmoon"), Qt::MatchStartsWith); foreach (QListWidgetItem *item, items) { diff --git a/apps/wizard/existinginstallationpage.cpp b/apps/wizard/existinginstallationpage.cpp index 66edc1e8a..0cbdce673 100644 --- a/apps/wizard/existinginstallationpage.cpp +++ b/apps/wizard/existinginstallationpage.cpp @@ -47,7 +47,7 @@ bool Wizard::ExistingInstallationPage::validatePage() // Or failed to be detected due to the target being a symlink QString path(field(QLatin1String("installation.path")).toString()); - QFile file(mWizard->mInstallations[path]->iniPath); + QFile file(mWizard->mInstallations[path].iniPath); if (!file.exists()) { QMessageBox msgBox; @@ -78,7 +78,7 @@ bool Wizard::ExistingInstallationPage::validatePage() // A proper Morrowind.ini was selected, set it QFileInfo info(iniFile); - mWizard->mInstallations[path]->iniPath = info.absoluteFilePath(); + mWizard->mInstallations[path].iniPath = info.absoluteFilePath(); } return true; diff --git a/apps/wizard/installationpage.cpp b/apps/wizard/installationpage.cpp index a0d3dfd21..f59b6d640 100644 --- a/apps/wizard/installationpage.cpp +++ b/apps/wizard/installationpage.cpp @@ -36,11 +36,11 @@ void Wizard::InstallationPage::initializePage() installProgressBar->setMaximum((components.count() * 100)); } else { if (components.contains(QLatin1String("Tribunal")) - && !mWizard->mInstallations[path]->hasTribunal) + && !mWizard->mInstallations[path].hasTribunal) installProgressBar->setMaximum(100); if (components.contains(QLatin1String("Bloodmoon")) - && !mWizard->mInstallations[path]->hasBloodmoon) + && !mWizard->mInstallations[path].hasBloodmoon) installProgressBar->setMaximum(installProgressBar->maximum() + 100); } @@ -104,15 +104,15 @@ void Wizard::InstallationPage::startInstallation() mUnshield->setInstallComponent(Wizard::Component_Morrowind, false); if (components.contains(QLatin1String("Tribunal")) - && !mWizard->mInstallations[path]->hasTribunal) + && !mWizard->mInstallations[path].hasTribunal) mUnshield->setInstallComponent(Wizard::Component_Tribunal, true); if (components.contains(QLatin1String("Bloodmoon")) - && !mWizard->mInstallations[path]->hasBloodmoon) + && !mWizard->mInstallations[path].hasBloodmoon) mUnshield->setInstallComponent(Wizard::Component_Bloodmoon, true); // Set the location of the Morrowind.ini to update - mUnshield->setIniPath(mWizard->mInstallations[path]->iniPath); + mUnshield->setIniPath(mWizard->mInstallations[path].iniPath); mUnshield->setupSettings(); } diff --git a/apps/wizard/languageselectionpage.cpp b/apps/wizard/languageselectionpage.cpp index 7f97e6918..fbd08ffcd 100644 --- a/apps/wizard/languageselectionpage.cpp +++ b/apps/wizard/languageselectionpage.cpp @@ -2,6 +2,8 @@ #include "mainwizard.hpp" +#include + Wizard::LanguageSelectionPage::LanguageSelectionPage(MainWizard *wizard) : QWizardPage(wizard), mWizard(wizard) @@ -27,18 +29,22 @@ void Wizard::LanguageSelectionPage::initializePage() int Wizard::LanguageSelectionPage::nextId() const { - // Check if we have to install something - QString path(field(QLatin1String("installation.path")).toString()); - - if (path.isEmpty()) + if (field(QLatin1String("installation.new")).toBool() == true) { return MainWizard::Page_ComponentSelection; - - if (mWizard->mInstallations[path]->hasMorrowind == true && - mWizard->mInstallations[path]->hasTribunal == true && - mWizard->mInstallations[path]->hasBloodmoon == true) - { - return MainWizard::Page_Import; } else { - return MainWizard::Page_ComponentSelection; + QString path(field(QLatin1String("installation.path")).toString()); + + if (path.isEmpty()) + return MainWizard::Page_ComponentSelection; + + // Check if we have to install something + if (mWizard->mInstallations[path].hasMorrowind == true && + mWizard->mInstallations[path].hasTribunal == true && + mWizard->mInstallations[path].hasBloodmoon == true) + { + return MainWizard::Page_Import; + } else { + return MainWizard::Page_ComponentSelection; + } } } diff --git a/apps/wizard/mainwizard.cpp b/apps/wizard/mainwizard.cpp index fa27b548c..2a4d9f70c 100644 --- a/apps/wizard/mainwizard.cpp +++ b/apps/wizard/mainwizard.cpp @@ -246,23 +246,29 @@ void Wizard::MainWizard::runSettingsImporter() arguments.append(QLatin1String("--cfg")); arguments.append(userPath + QLatin1String("openmw.cfg")); - ProcessInvoker invoker(this); + ProcessInvoker *invoker = new ProcessInvoker(this); - if (!invoker.startProcess(QLatin1String("mwiniimport"), arguments, false)) + if (!invoker->startProcess(QLatin1String("mwiniimport"), arguments, false)) return qApp->quit();; + connect(invoker->getProcess(), SIGNAL(started()), + this, SLOT(importerStarted())); + + connect(invoker->getProcess(), SIGNAL(finished(int,QProcess::ExitStatus)), + this, SLOT(importerFinished(int,QProcess::ExitStatus))); + // Re-read the game settings - setupGameSettings(); + // setupGameSettings(); } void Wizard::MainWizard::addInstallation(const QString &path) { qDebug() << "add installation in: " << path; - Installation* install = new Installation(); + Installation install;// = new Installation(); - install->hasMorrowind = findFiles(QLatin1String("Morrowind"), path); - install->hasTribunal = findFiles(QLatin1String("Tribunal"), path); - install->hasBloodmoon = findFiles(QLatin1String("Bloodmoon"), path); + install.hasMorrowind = findFiles(QLatin1String("Morrowind"), path); + install.hasTribunal = findFiles(QLatin1String("Tribunal"), path); + install.hasBloodmoon = findFiles(QLatin1String("Bloodmoon"), path); // Try to autodetect the Morrowind.ini location QDir dir(path); @@ -276,7 +282,7 @@ void Wizard::MainWizard::addInstallation(const QString &path) } if (file.exists()) - install->iniPath = file.fileName(); + install.iniPath = file.fileName(); mInstallations.insert(QDir::toNativeSeparators(path), install); @@ -301,6 +307,21 @@ void Wizard::MainWizard::setupPages() setStartId(Page_Intro); } +void Wizard::MainWizard::importerStarted() +{ + qDebug() << "importer started!"; +} + +void Wizard::MainWizard::importerFinished(int exitCode, QProcess::ExitStatus exitStatus) +{ + qDebug() << "importer finished!"; + if (exitCode != 0 || exitStatus == QProcess::CrashExit) + return; + + // Re-read the settings + setupGameSettings(); +} + void Wizard::MainWizard::accept() { writeSettings(); diff --git a/apps/wizard/mainwizard.hpp b/apps/wizard/mainwizard.hpp index 63b7e62e8..ed1a38879 100644 --- a/apps/wizard/mainwizard.hpp +++ b/apps/wizard/mainwizard.hpp @@ -1,6 +1,7 @@ #ifndef MAINWIZARD_HPP #define MAINWIZARD_HPP +#include #include #include @@ -41,7 +42,7 @@ namespace Wizard void addInstallation(const QString &path); void runSettingsImporter(); - QMap mInstallations; + QMap mInstallations; Files::ConfigurationManager mCfgMgr; @@ -66,6 +67,10 @@ namespace Wizard QTextStream *mLog; private slots: + + void importerStarted(); + void importerFinished(int exitCode, QProcess::ExitStatus exitStatus); + void accept(); void reject();