diff --git a/apps/wizard/existinginstallationpage.cpp b/apps/wizard/existinginstallationpage.cpp index 56743eb44a..d37dd949d6 100644 --- a/apps/wizard/existinginstallationpage.cpp +++ b/apps/wizard/existinginstallationpage.cpp @@ -19,7 +19,6 @@ Wizard::ExistingInstallationPage::ExistingInstallationPage(MainWizard *wizard) : installationsList->addItem(mEmptyItem); mEmptyItem->setHidden(true); - connect(installationsList, SIGNAL(currentTextChanged(QString)), this, SLOT(textChanged(QString))); diff --git a/apps/wizard/installationpage.cpp b/apps/wizard/installationpage.cpp index 74666c394c..a0d3dfd21b 100644 --- a/apps/wizard/installationpage.cpp +++ b/apps/wizard/installationpage.cpp @@ -80,6 +80,9 @@ void Wizard::InstallationPage::startInstallation() connect(mUnshield, SIGNAL(textChanged(QString)), logTextEdit, SLOT(appendPlainText(QString)), Qt::QueuedConnection); + connect(mUnshield, SIGNAL(textChanged(QString)), + mWizard, SLOT(addLogText(QString)), Qt::QueuedConnection); + connect(mUnshield, SIGNAL(progressChanged(int)), installProgressBar, SLOT(setValue(int)), Qt::QueuedConnection); @@ -153,6 +156,8 @@ void Wizard::InstallationPage::showFileDialog(Wizard::Component component) if (path.isEmpty()) { logTextEdit->appendHtml(tr("
\
Error: The installation was aborted by the user
\ %1
").arg(details)); + mWizard->addLogText(QLatin1String("Error: ") + text); + mWizard->addLogText(details); + + mWizard->mError = true; QMessageBox msgBox; msgBox.setWindowTitle(tr("An error occurred")); msgBox.setIcon(QMessageBox::Critical); @@ -196,7 +205,7 @@ void Wizard::InstallationPage::installationError(const QString &text, const QStr msgBox.setDetailedText(details); msgBox.exec(); - mWizard->mError = true; + emit completeChanged(); } diff --git a/apps/wizard/mainwizard.cpp b/apps/wizard/mainwizard.cpp index 6a72d71fbc..11e44c6b06 100644 --- a/apps/wizard/mainwizard.cpp +++ b/apps/wizard/mainwizard.cpp @@ -4,6 +4,8 @@ #includeCould not open %1 for writing
\ +Please make sure you have the right permissions \ + and try again.
")); + + QFile *file = new QFile(logPath); + + if (!file->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) { + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Error opening Wizard log file")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setText(message.arg(file->fileName())); + msgBox.exec(); + return qApp->quit(); + } + + qDebug() << logPath; + + mLog = new QTextStream(file); + mLog->setCodec(QTextCodec::codecForName("UTF-8")); + + //addLogText(QLatin1String("test test 123 test")); +} + +void Wizard::MainWizard::addLogText(const QString &text) +{ + + qDebug() << "AddLogText called! " << text; + if (!text.isEmpty()) { + qDebug() << "logging " << text; + *mLog << text << endl; + } + +// file.close(); +} + void Wizard::MainWizard::setupGameSettings() { QString userPath(QString::fromUtf8(mCfgMgr.getUserConfigPath().string().c_str())); diff --git a/apps/wizard/mainwizard.hpp b/apps/wizard/mainwizard.hpp index f55709badc..dcb07a8c2b 100644 --- a/apps/wizard/mainwizard.hpp +++ b/apps/wizard/mainwizard.hpp @@ -46,8 +46,12 @@ namespace Wizard bool mError; + public slots: + void addLogText(const QString &text); + private: + void setupLog(); void setupGameSettings(); void setupInstallations(); void setupPages(); @@ -56,6 +60,8 @@ namespace Wizard Config::GameSettings mGameSettings; + QTextStream *mLog; + private slots: void accept(); void reject(); diff --git a/apps/wizard/unshield/unshieldworker.cpp b/apps/wizard/unshield/unshieldworker.cpp index 70c780b3b8..f0b9a86745 100644 --- a/apps/wizard/unshield/unshieldworker.cpp +++ b/apps/wizard/unshield/unshieldworker.cpp @@ -153,37 +153,39 @@ void Wizard::UnshieldWorker::setIniCodec(QTextCodec *codec) mIniCodec = codec; } -void Wizard::UnshieldWorker::setupSettings() +bool Wizard::UnshieldWorker::setupSettings() { // Create Morrowind.ini settings map if (getIniPath().isEmpty()) - return; + return false; QFile file(getIniPath()); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { emit error(tr("Failed to open Morrowind configuration file!"), tr("Opening %1 failed: %2.").arg(getIniPath(), file.errorString())); - return; + return false; } QTextStream stream(&file); stream.setCodec(mIniCodec); mIniSettings.readFile(stream); + + return true; } -void Wizard::UnshieldWorker::writeSettings() +bool Wizard::UnshieldWorker::writeSettings() { if (getIniPath().isEmpty()) - return; + return false; QFile file(getIniPath()); if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { emit error(tr("Failed to open Morrowind configuration file!"), tr("Opening %1 failed: %2.").arg(getIniPath(), file.errorString())); - return; + return false; } QTextStream stream(&file); @@ -192,7 +194,10 @@ void Wizard::UnshieldWorker::writeSettings() if (!mIniSettings.writeFile(getIniPath(), stream)) { emit error(tr("Failed to write Morrowind configuration file!"), tr("Writing to %1 failed: %2.").arg(getIniPath(), file.errorString())); + return false; } + + return true; } bool Wizard::UnshieldWorker::removeDirectory(const QString &dirName) @@ -383,7 +388,8 @@ void Wizard::UnshieldWorker::extract() } // Write the settings to the Morrowind config file - writeSettings(); + if (!writeSettings()) + return false; // Remove the temporary directory removeDirectory(getPath() + QDir::separator() + QLatin1String("extract-temp")); @@ -626,7 +632,9 @@ bool Wizard::UnshieldWorker::installComponent(Component component, const QString // Setup Morrowind configuration setIniPath(getPath() + QDir::separator() + QLatin1String("Morrowind.ini")); - setupSettings(); + + if (!setupSettings()) + return false; } if (component == Wizard::Component_Tribunal) diff --git a/apps/wizard/unshield/unshieldworker.hpp b/apps/wizard/unshield/unshieldworker.hpp index 36215bf5d7..e5a712977e 100644 --- a/apps/wizard/unshield/unshieldworker.hpp +++ b/apps/wizard/unshield/unshieldworker.hpp @@ -42,11 +42,11 @@ namespace Wizard void setIniCodec(QTextCodec *codec); - void setupSettings(); + bool setupSettings(); private: - void writeSettings(); + bool writeSettings(); bool getInstallComponent(Component component); @@ -114,7 +114,6 @@ namespace Wizard void requestFileDialog(Wizard::Component component); void textChanged(const QString &text); - void logTextChanged(const QString &text); void error(const QString &text, const QString &details); void progressChanged(int progress);