Added some nice error messages to the installation process

loadfix
pvdk 11 years ago
parent 2736527e5a
commit 1262eab03a

@ -12,14 +12,21 @@ Wizard::ConclusionPage::ConclusionPage(MainWizard *wizard) :
} }
void Wizard::ConclusionPage::initializePage() void Wizard::ConclusionPage::initializePage()
{
if (!mWizard->mError)
{ {
if (field("installation.new").toBool() == true) if (field("installation.new").toBool() == true)
{ {
textLabel->setText(tr("The OpenMW Wizard successfully installed Morrowind on your computer.\n\n") + textLabel->setText(tr("<html><head/><body><p>The OpenMW Wizard successfully installed Morrowind on your computer.</p> \
tr("Click Finish to close the Wizard.")); <p>Click Finish to close the Wizard.</p></body></html>"));
} else {
textLabel->setText(tr("<html><head/><body><p>The OpenMW Wizard successfully modified your existing Morrowind installation.</p> \
<p>Click Finish to close the Wizard.</p></body></html>"));
}
} else { } else {
textLabel->setText(tr("The OpenMW Wizard successfully modified your existing Morrowind installation.\n\n") + textLabel->setText(tr("<html><head/><body><p>The OpenMW Wizard failed to install Morrowind on your computer.</p> \
tr("Click Finish to close the Wizard.")); <p>Please report any bugs you might have encountered to our \
<a href=\"https://bugs.openmw.org\">bug tracker</a>.<br/>Make sure to include the installation log.</p><br/></body></html>"));
} }
} }

@ -23,8 +23,8 @@ void Wizard::InstallationPage::initializePage()
QString path(field("installation.path").toString()); QString path(field("installation.path").toString());
QStringList components(field("installation.components").toStringList()); QStringList components(field("installation.components").toStringList());
logTextEdit->append(QString("Installing to %1").arg(path)); logTextEdit->appendPlainText(QString("Installing to %1").arg(path));
logTextEdit->append(QString("Installing %1.").arg(components.join(", "))); logTextEdit->appendPlainText(QString("Installing %1.").arg(components.join(", ")));
installProgressBar->setMinimum(0); installProgressBar->setMinimum(0);
@ -39,11 +39,11 @@ void Wizard::InstallationPage::initializePage()
else else
{ {
if (components.contains(QLatin1String("Tribunal")) if (components.contains(QLatin1String("Tribunal"))
&& mWizard->mInstallations[path]->hasTribunal == false) && !mWizard->mInstallations[path]->hasTribunal)
installProgressBar->setMaximum(100); installProgressBar->setMaximum(100);
if (components.contains(QLatin1String("Bloodmoon")) if (components.contains(QLatin1String("Bloodmoon"))
&& mWizard->mInstallations[path]->hasBloodmoon == false) && !mWizard->mInstallations[path]->hasBloodmoon)
installProgressBar->setMaximum(installProgressBar->maximum() + 100); installProgressBar->setMaximum(installProgressBar->maximum() + 100);
} }
@ -76,14 +76,14 @@ void Wizard::InstallationPage::startInstallation()
connect(mUnshield, SIGNAL(finished()), connect(mUnshield, SIGNAL(finished()),
this, SLOT(installationFinished()), Qt::QueuedConnection); this, SLOT(installationFinished()), Qt::QueuedConnection);
connect(mUnshield, SIGNAL(error(QString)), connect(mUnshield, SIGNAL(error(QString, QString)),
this, SLOT(installationError(QString)), Qt::QueuedConnection); this, SLOT(installationError(QString, QString)), Qt::QueuedConnection);
connect(mUnshield, SIGNAL(textChanged(QString)), connect(mUnshield, SIGNAL(textChanged(QString)),
installProgressLabel, SLOT(setText(QString)), Qt::QueuedConnection); installProgressLabel, SLOT(setText(QString)), Qt::QueuedConnection);
connect(mUnshield, SIGNAL(textChanged(QString)), connect(mUnshield, SIGNAL(textChanged(QString)),
logTextEdit, SLOT(append(QString)), Qt::QueuedConnection); logTextEdit, SLOT(appendPlainText(QString)), Qt::QueuedConnection);
connect(mUnshield, SIGNAL(progressChanged(int)), connect(mUnshield, SIGNAL(progressChanged(int)),
installProgressBar, SLOT(setValue(int)), Qt::QueuedConnection); installProgressBar, SLOT(setValue(int)), Qt::QueuedConnection);
@ -170,17 +170,45 @@ void Wizard::InstallationPage::installationFinished()
} }
void Wizard::InstallationPage::installationError(const QString &text) void Wizard::InstallationPage::installationError(const QString &text, const QString &details)
{ {
qDebug() << "error: " << text; qDebug() << "error: " << text;
installProgressLabel->setText(tr("Installation failed!"));
logTextEdit->appendHtml(tr("<b><font color='red'>Error: %1</b>").arg(text));
logTextEdit->appendHtml(tr("<b><font color='red'>%1</b>").arg(details));
QMessageBox msgBox;
msgBox.setWindowTitle(tr("An error occurred"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<html><head/><body><p><b>The Wizard has encountered an error</b></p> \
<p>The error reported was:</p><p>%1</p> \
<p>Press &quot;Show Details...&quot; for more information.</p></body></html>").arg(text));
msgBox.setDetailedText(details);
msgBox.exec();
mWizard->mError = true;
emit completeChanged();
} }
bool Wizard::InstallationPage::isComplete() const bool Wizard::InstallationPage::isComplete() const
{ {
if (!mWizard->mError) {
return mFinished; return mFinished;
} else {
return true;
}
} }
int Wizard::InstallationPage::nextId() const int Wizard::InstallationPage::nextId() const
{ {
if (!mWizard->mError) {
return MainWizard::Page_Import; return MainWizard::Page_Import;
} else {
return MainWizard::Page_Conclusion;
}
} }

@ -37,7 +37,7 @@ namespace Wizard
void showFileDialog(Wizard::Component component); void showFileDialog(Wizard::Component component);
void installationFinished(); void installationFinished();
void installationError(const QString &text); void installationError(const QString &text, const QString &details);
protected: protected:
void initializePage(); void initializePage();

@ -44,6 +44,8 @@ namespace Wizard
Files::ConfigurationManager mCfgMgr; Files::ConfigurationManager mCfgMgr;
bool mError;
private: private:
void setupInstallations(); void setupInstallations();

@ -185,8 +185,8 @@ void Wizard::UnshieldWorker::setupSettings()
QFile file(getIniPath()); QFile file(getIniPath());
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
// TODO: Emit error signal
qDebug() << "Error opening .ini file!"; qDebug() << "Error opening .ini file!";
emit error(tr("Failed to open Morrowind configuration file!"), tr("Opening %1 failed: %2.").arg(getIniPath(), file.errorString()));
return; return;
} }
@ -240,6 +240,7 @@ bool Wizard::UnshieldWorker::copyFile(const QString &source, const QString &dest
} }
} else { } else {
qDebug() << "copy failed! " << file.errorString(); 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; return false;
@ -274,7 +275,6 @@ bool Wizard::UnshieldWorker::copyDirectory(const QString &source, const QString
if (info.isDir()) { if (info.isDir()) {
result = moveDirectory(info.absoluteFilePath(), destDir.absolutePath() + relativePath); result = moveDirectory(info.absoluteFilePath(), destDir.absolutePath() + relativePath);
} else { } else {
// qDebug() << "moving: " << info.absoluteFilePath() << " to: " << destDir.absolutePath() + relativePath;
result = moveFile(info.absoluteFilePath(), destDir.absolutePath() + relativePath); result = moveFile(info.absoluteFilePath(), destDir.absolutePath() + relativePath);
} }
} }
@ -363,6 +363,7 @@ void Wizard::UnshieldWorker::extract()
setComponentDone(Wizard::Component_Morrowind, true); setComponentDone(Wizard::Component_Morrowind, true);
} else { } else {
qDebug() << "Erorr installing Morrowind"; qDebug() << "Erorr installing Morrowind";
return; return;
} }
} }
@ -414,8 +415,10 @@ void Wizard::UnshieldWorker::setupAddon(Component component)
if (component == Wizard::Component_Bloodmoon) if (component == Wizard::Component_Bloodmoon)
name = QLatin1String("Bloodmoon"); name = QLatin1String("Bloodmoon");
if (name.isEmpty()) if (name.isEmpty()) {
return; // Not a valid addon emit error(tr("Component parameter is invalid!"), tr("An invalid component parameter was supplied."));
return;
}
if (!disk.cd(name)) { if (!disk.cd(name)) {
qDebug() << "not found on cd!"; qDebug() << "not found on cd!";
@ -474,8 +477,10 @@ bool Wizard::UnshieldWorker::installComponent(Component component)
break; break;
} }
if (name.isEmpty()) if (name.isEmpty()) {
emit error(tr("Component parameter is invalid!"), tr("An invalid component parameter was supplied."));
return false; return false;
}
emit textChanged(tr("Installing %0").arg(name)); emit textChanged(tr("Installing %0").arg(name));
@ -483,6 +488,7 @@ bool Wizard::UnshieldWorker::installComponent(Component component)
if (!disk.exists()) { if (!disk.exists()) {
qDebug() << "Component path not set: " << getComponentPath(Wizard::Component_Morrowind); 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; return false;
} }
@ -496,29 +502,34 @@ bool Wizard::UnshieldWorker::installComponent(Component component)
if (!temp.mkpath(tempPath)) { if (!temp.mkpath(tempPath)) {
qDebug() << "Can't make path"; qDebug() << "Can't make path";
emit error(tr("Cannot create temporary directory!"), tr("Failed to create %0.").arg(tempPath));
return false; return false;
} }
temp.setPath(tempPath); temp.setPath(tempPath);
if (!temp.mkdir(name)) { 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; return false;
} }
if (!temp.cd(name)) { if (!temp.cd(name)) {
qDebug() << "Can't cd to dir"; 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; return false;
} }
// Extract the installation files // 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 // Move the files from the temporary path to the destination folder
emit textChanged(tr("Moving installation files")); emit textChanged(tr("Moving installation files"));
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) { if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) {
qDebug() << "failed to move files!"; 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; return false;
} }
@ -538,6 +549,7 @@ bool Wizard::UnshieldWorker::installComponent(Component component)
moveFile(info.absoluteFilePath(), getPath() + QDir::separator() + QLatin1String("Morrowind.ini")); moveFile(info.absoluteFilePath(), getPath() + QDir::separator() + QLatin1String("Morrowind.ini"));
} else { } else {
qDebug() << "Could not find ini file!"; qDebug() << "Could not find ini file!";
emit error(tr("Could not find Morrowind configuration file!"), tr("Failed to find %0.").arg(iniPath));
return false; return false;
} }
} }
@ -599,7 +611,7 @@ bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outp
success = unshield_file_save(unshield, index, fileName.toLatin1().constData()); success = unshield_file_save(unshield, index, fileName.toLatin1().constData());
if (!success) { 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); dir.remove(fileName);
} }
@ -611,9 +623,8 @@ bool Wizard::UnshieldWorker::findFile(const QString &cabFile, const QString &fil
Unshield *unshield; Unshield *unshield;
unshield = unshield_open(cabFile.toLatin1().constData()); unshield = unshield_open(cabFile.toLatin1().constData());
// TODO: Proper error
if (!unshield) { 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; return false;
} }
@ -635,15 +646,16 @@ bool Wizard::UnshieldWorker::findFile(const QString &cabFile, const QString &fil
return false; 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;
unshield = unshield_open(cabFile.toLatin1().constData()); unshield = unshield_open(cabFile.toLatin1().constData());
// TODO: Proper error
if (!unshield) { 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; return false;
} }
int counter = 0; 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) for (size_t j=group->first_file; j<=group->last_file; ++j)
{ {
if (unshield_file_is_valid(unshield, j)) { if (unshield_file_is_valid(unshield, j)) {
extractFile(unshield, outputDir, group->name, j, counter); success = extractFile(unshield, outputDir, group->name, j, counter);
++counter; ++counter;
} }
} }
} }
unshield_close(unshield); unshield_close(unshield);
return success;
} }

@ -62,7 +62,7 @@ namespace Wizard
void setupSettings(); 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 extractFile(Unshield *unshield, const QString &outputDir, const QString &prefix, int index, int counter);
bool findFile(const QString &cabFile, const QString &fileName); bool findFile(const QString &cabFile, const QString &fileName);
@ -109,7 +109,7 @@ namespace Wizard
void textChanged(const QString &text); void textChanged(const QString &text);
void logTextChanged(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); void progressChanged(int progress);

@ -22,9 +22,15 @@
<property name="text"> <property name="text">
<string>Placeholder</string> <string>Placeholder</string>
</property> </property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>

@ -23,7 +23,7 @@
<item> <item>
<widget class="QLabel" name="installProgressLabel"> <widget class="QLabel" name="installProgressLabel">
<property name="text"> <property name="text">
<string>Extracting: %1</string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
@ -35,7 +35,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTextEdit" name="logTextEdit"> <widget class="QPlainTextEdit" name="logTextEdit">
<property name="undoRedoEnabled"> <property name="undoRedoEnabled">
<bool>false</bool> <bool>false</bool>
</property> </property>

Loading…
Cancel
Save