Added some nice error messages to the installation process

loadfix
pvdk 11 years ago
parent 2736527e5a
commit 1262eab03a

@ -13,13 +13,20 @@ Wizard::ConclusionPage::ConclusionPage(MainWizard *wizard) :
void Wizard::ConclusionPage::initializePage()
{
if (!mWizard->mError)
{
if (field("installation.new").toBool() == true)
{
textLabel->setText(tr("The OpenMW Wizard successfully installed Morrowind on your computer.\n\n") +
tr("Click Finish to close the Wizard."));
textLabel->setText(tr("<html><head/><body><p>The OpenMW Wizard successfully installed Morrowind on your computer.</p> \
<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 {
textLabel->setText(tr("The OpenMW Wizard successfully modified your existing Morrowind installation.\n\n") +
tr("Click Finish to close the Wizard."));
textLabel->setText(tr("<html><head/><body><p>The OpenMW Wizard failed to install Morrowind on your computer.</p> \
<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());
QStringList components(field("installation.components").toStringList());
logTextEdit->append(QString("Installing to %1").arg(path));
logTextEdit->append(QString("Installing %1.").arg(components.join(", ")));
logTextEdit->appendPlainText(QString("Installing to %1").arg(path));
logTextEdit->appendPlainText(QString("Installing %1.").arg(components.join(", ")));
installProgressBar->setMinimum(0);
@ -39,11 +39,11 @@ void Wizard::InstallationPage::initializePage()
else
{
if (components.contains(QLatin1String("Tribunal"))
&& mWizard->mInstallations[path]->hasTribunal == false)
&& !mWizard->mInstallations[path]->hasTribunal)
installProgressBar->setMaximum(100);
if (components.contains(QLatin1String("Bloodmoon"))
&& mWizard->mInstallations[path]->hasBloodmoon == false)
&& !mWizard->mInstallations[path]->hasBloodmoon)
installProgressBar->setMaximum(installProgressBar->maximum() + 100);
}
@ -76,14 +76,14 @@ void Wizard::InstallationPage::startInstallation()
connect(mUnshield, SIGNAL(finished()),
this, SLOT(installationFinished()), Qt::QueuedConnection);
connect(mUnshield, SIGNAL(error(QString)),
this, SLOT(installationError(QString)), Qt::QueuedConnection);
connect(mUnshield, SIGNAL(error(QString, QString)),
this, SLOT(installationError(QString, QString)), Qt::QueuedConnection);
connect(mUnshield, SIGNAL(textChanged(QString)),
installProgressLabel, SLOT(setText(QString)), Qt::QueuedConnection);
connect(mUnshield, SIGNAL(textChanged(QString)),
logTextEdit, SLOT(append(QString)), Qt::QueuedConnection);
logTextEdit, SLOT(appendPlainText(QString)), Qt::QueuedConnection);
connect(mUnshield, SIGNAL(progressChanged(int)),
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;
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
{
if (!mWizard->mError) {
return mFinished;
} else {
return true;
}
}
int Wizard::InstallationPage::nextId() const
{
if (!mWizard->mError) {
return MainWizard::Page_Import;
} else {
return MainWizard::Page_Conclusion;
}
}

@ -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();

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

@ -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;
}

@ -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);

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

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

Loading…
Cancel
Save