diff --git a/apps/wizard/conclusionpage.cpp b/apps/wizard/conclusionpage.cpp index 55b03b912..61d58eaba 100644 --- a/apps/wizard/conclusionpage.cpp +++ b/apps/wizard/conclusionpage.cpp @@ -13,13 +13,20 @@ Wizard::ConclusionPage::ConclusionPage(MainWizard *wizard) : void Wizard::ConclusionPage::initializePage() { - if (field("installation.new").toBool() == true) + if (!mWizard->mError) { - textLabel->setText(tr("The OpenMW Wizard successfully installed Morrowind on your computer.\n\n") + - tr("Click Finish to close the Wizard.")); + if (field("installation.new").toBool() == true) + { + textLabel->setText(tr("
The OpenMW Wizard successfully installed Morrowind on your computer.
\ +Click Finish to close the Wizard.
")); + } else { + textLabel->setText(tr("The OpenMW Wizard successfully modified your existing Morrowind installation.
\ +Click Finish to close the Wizard.
")); + } } else { - textLabel->setText(tr("The OpenMW Wizard successfully modified your existing Morrowind installation.\n\n") + - tr("Click Finish to close the Wizard.")); + textLabel->setText(tr("The OpenMW Wizard failed to install Morrowind on your computer.
\ +Please report any bugs you might have encountered to our \
+ bug tracker.
Make sure to include the installation log.
The Wizard has encountered an error
\ +The error reported was:
%1
\ +Press "Show Details..." for more information.
").arg(text)); + + msgBox.setDetailedText(details); + msgBox.exec(); + + mWizard->mError = true; + emit completeChanged(); + } bool Wizard::InstallationPage::isComplete() const { - return mFinished; + if (!mWizard->mError) { + return mFinished; + } else { + return true; + } } int Wizard::InstallationPage::nextId() const { - return MainWizard::Page_Import; + if (!mWizard->mError) { + return MainWizard::Page_Import; + } else { + return MainWizard::Page_Conclusion; + } } diff --git a/apps/wizard/installationpage.hpp b/apps/wizard/installationpage.hpp index 3989177ab..7001b2630 100644 --- a/apps/wizard/installationpage.hpp +++ b/apps/wizard/installationpage.hpp @@ -37,7 +37,7 @@ namespace Wizard void showFileDialog(Wizard::Component component); void installationFinished(); - void installationError(const QString &text); + void installationError(const QString &text, const QString &details); protected: void initializePage(); diff --git a/apps/wizard/mainwizard.hpp b/apps/wizard/mainwizard.hpp index 0d4c05fce..31a93ffbb 100644 --- a/apps/wizard/mainwizard.hpp +++ b/apps/wizard/mainwizard.hpp @@ -44,6 +44,8 @@ namespace Wizard Files::ConfigurationManager mCfgMgr; + bool mError; + private: void setupInstallations(); diff --git a/apps/wizard/unshield/unshieldworker.cpp b/apps/wizard/unshield/unshieldworker.cpp index 9c635818b..7becec101 100644 --- a/apps/wizard/unshield/unshieldworker.cpp +++ b/apps/wizard/unshield/unshieldworker.cpp @@ -185,8 +185,8 @@ void Wizard::UnshieldWorker::setupSettings() QFile file(getIniPath()); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - // TODO: Emit error signal qDebug() << "Error opening .ini file!"; + emit error(tr("Failed to open Morrowind configuration file!"), tr("Opening %1 failed: %2.").arg(getIniPath(), file.errorString())); return; } @@ -240,6 +240,7 @@ bool Wizard::UnshieldWorker::copyFile(const QString &source, const QString &dest } } else { qDebug() << "copy failed! " << file.errorString(); + emit error(tr("Failed to copy file!"), tr("Copying %1 to %2 failed: %3.").arg(source, destination, file.errorString())); } return false; @@ -274,7 +275,6 @@ bool Wizard::UnshieldWorker::copyDirectory(const QString &source, const QString if (info.isDir()) { result = moveDirectory(info.absoluteFilePath(), destDir.absolutePath() + relativePath); } else { -// qDebug() << "moving: " << info.absoluteFilePath() << " to: " << destDir.absolutePath() + relativePath; result = moveFile(info.absoluteFilePath(), destDir.absolutePath() + relativePath); } } @@ -363,6 +363,7 @@ void Wizard::UnshieldWorker::extract() setComponentDone(Wizard::Component_Morrowind, true); } else { qDebug() << "Erorr installing Morrowind"; + return; } } @@ -414,8 +415,10 @@ void Wizard::UnshieldWorker::setupAddon(Component component) if (component == Wizard::Component_Bloodmoon) name = QLatin1String("Bloodmoon"); - if (name.isEmpty()) - return; // Not a valid addon + if (name.isEmpty()) { + emit error(tr("Component parameter is invalid!"), tr("An invalid component parameter was supplied.")); + return; + } if (!disk.cd(name)) { qDebug() << "not found on cd!"; @@ -474,8 +477,10 @@ bool Wizard::UnshieldWorker::installComponent(Component component) break; } - if (name.isEmpty()) + if (name.isEmpty()) { + emit error(tr("Component parameter is invalid!"), tr("An invalid component parameter was supplied.")); return false; + } emit textChanged(tr("Installing %0").arg(name)); @@ -483,6 +488,7 @@ bool Wizard::UnshieldWorker::installComponent(Component component) if (!disk.exists()) { qDebug() << "Component path not set: " << getComponentPath(Wizard::Component_Morrowind); + emit error(tr("Component path not set!"), tr("The source path for %0 was not set.").arg(name)); return false; } @@ -496,29 +502,34 @@ bool Wizard::UnshieldWorker::installComponent(Component component) if (!temp.mkpath(tempPath)) { qDebug() << "Can't make path"; + emit error(tr("Cannot create temporary directory!"), tr("Failed to create %0.").arg(tempPath)); return false; } temp.setPath(tempPath); if (!temp.mkdir(name)) { - qDebug() << "Can't make dir"; + emit error(tr("Cannot create temporary directory!"), tr("Failed to create %0.").arg(temp.absoluteFilePath(name))); return false; } if (!temp.cd(name)) { qDebug() << "Can't cd to dir"; + emit error(tr("Cannot move into temporary directory!"), tr("Failed to move into %0.").arg(temp.absoluteFilePath(name))); return false; } // Extract the installation files - extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath()); + if (!extractCab(disk.absoluteFilePath(QLatin1String("data1.hdr")), temp.absolutePath())) + return false; - // TODO: Throw error; // Move the files from the temporary path to the destination folder emit textChanged(tr("Moving installation files")); if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) { qDebug() << "failed to move files!"; + emit error(tr("Moving extracted files failed!"), + tr("Failed to move files from %0 to %1.").arg(temp.absoluteFilePath(QLatin1String("Data Files")), + getPath())); return false; } @@ -538,6 +549,7 @@ bool Wizard::UnshieldWorker::installComponent(Component component) moveFile(info.absoluteFilePath(), getPath() + QDir::separator() + QLatin1String("Morrowind.ini")); } else { qDebug() << "Could not find ini file!"; + emit error(tr("Could not find Morrowind configuration file!"), tr("Failed to find %0.").arg(iniPath)); return false; } } @@ -599,7 +611,7 @@ bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outp success = unshield_file_save(unshield, index, fileName.toLatin1().constData()); if (!success) { - emit error(tr("Failed to extract %1").arg(fileName)); + emit error(tr("Failed to extract %1.").arg(QString::fromLatin1(unshield_file_name(unshield, index))), tr("Complete path: %1.").arg(fileName)); dir.remove(fileName); } @@ -611,9 +623,8 @@ bool Wizard::UnshieldWorker::findFile(const QString &cabFile, const QString &fil Unshield *unshield; unshield = unshield_open(cabFile.toLatin1().constData()); - // TODO: Proper error if (!unshield) { - emit error(tr("Failed to open %1").arg(cabFile)); + emit error(tr("Failed to open InstallShield Cabinet File."), tr("Opening %1 failed.").arg(cabFile)); return false; } @@ -635,15 +646,16 @@ bool Wizard::UnshieldWorker::findFile(const QString &cabFile, const QString &fil return false; } -void Wizard::UnshieldWorker::extractCab(const QString &cabFile, const QString &outputDir) +bool Wizard::UnshieldWorker::extractCab(const QString &cabFile, const QString &outputDir) { + bool success; + Unshield *unshield; unshield = unshield_open(cabFile.toLatin1().constData()); - // TODO: Proper error if (!unshield) { - emit error(tr("Failed to open %1").arg(cabFile)); - return; + emit error(tr("Failed to open InstallShield Cabinet File."), tr("Opening %1 failed.").arg(cabFile)); + return false; } int counter = 0; @@ -655,11 +667,12 @@ void Wizard::UnshieldWorker::extractCab(const QString &cabFile, const QString &o for (size_t j=group->first_file; j<=group->last_file; ++j) { if (unshield_file_is_valid(unshield, j)) { - extractFile(unshield, outputDir, group->name, j, counter); + success = extractFile(unshield, outputDir, group->name, j, counter); ++counter; } } } unshield_close(unshield); + return success; } diff --git a/apps/wizard/unshield/unshieldworker.hpp b/apps/wizard/unshield/unshieldworker.hpp index fb55bc88f..501daaf30 100644 --- a/apps/wizard/unshield/unshieldworker.hpp +++ b/apps/wizard/unshield/unshieldworker.hpp @@ -62,7 +62,7 @@ namespace Wizard void setupSettings(); - void extractCab(const QString &cabFile, const QString &outputDir); + bool extractCab(const QString &cabFile, const QString &outputDir); bool extractFile(Unshield *unshield, const QString &outputDir, const QString &prefix, int index, int counter); bool findFile(const QString &cabFile, const QString &fileName); @@ -109,7 +109,7 @@ namespace Wizard void textChanged(const QString &text); void logTextChanged(const QString &text); - void error(const QString &text); + void error(const QString &text, const QString &details); void progressChanged(int progress); diff --git a/files/ui/wizard/conclusionpage.ui b/files/ui/wizard/conclusionpage.ui index a27f66789..eb6828b38 100644 --- a/files/ui/wizard/conclusionpage.ui +++ b/files/ui/wizard/conclusionpage.ui @@ -22,9 +22,15 @@