2013-12-08 21:35:57 +01:00
|
|
|
#include "installationpage.hpp"
|
|
|
|
|
2013-12-13 13:38:49 +01:00
|
|
|
#include <QDebug>
|
2013-12-24 19:38:21 +01:00
|
|
|
#include <QTextCodec>
|
2014-01-24 22:25:22 +01:00
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QFileDialog>
|
2013-12-13 13:38:49 +01:00
|
|
|
|
2013-12-08 22:58:29 +01:00
|
|
|
#include "mainwizard.hpp"
|
2013-12-24 19:38:21 +01:00
|
|
|
#include "inisettings.hpp"
|
2014-01-01 22:46:29 +01:00
|
|
|
#include "unshield/unshieldworker.hpp"
|
2013-12-08 22:58:29 +01:00
|
|
|
|
2013-12-13 13:38:49 +01:00
|
|
|
Wizard::InstallationPage::InstallationPage(MainWizard *wizard) :
|
|
|
|
QWizardPage(wizard),
|
|
|
|
mWizard(wizard)
|
2013-12-08 21:35:57 +01:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2013-12-26 18:02:34 +01:00
|
|
|
|
|
|
|
mFinished = false;
|
2013-12-08 21:35:57 +01:00
|
|
|
}
|
2013-12-08 22:58:29 +01:00
|
|
|
|
2013-12-13 13:38:49 +01:00
|
|
|
void Wizard::InstallationPage::initializePage()
|
|
|
|
{
|
2013-12-24 23:09:31 +01:00
|
|
|
QString path(field("installation.path").toString());
|
|
|
|
QStringList components(field("installation.components").toStringList());
|
2013-12-15 15:13:49 +01:00
|
|
|
|
|
|
|
logTextEdit->append(QString("Installing to %1").arg(path));
|
|
|
|
logTextEdit->append(QString("Installing %1.").arg(components.join(", ")));
|
2013-12-15 13:12:48 +01:00
|
|
|
|
2013-12-24 19:38:21 +01:00
|
|
|
installProgressBar->setMinimum(0);
|
|
|
|
|
|
|
|
// Set the progressbar maximum to a multiple of 100
|
|
|
|
// That way installing all three components would yield 300%
|
|
|
|
// When one component is done the bar will be filled by 33%
|
|
|
|
|
|
|
|
if (field("installation.new").toBool() == true)
|
|
|
|
{
|
|
|
|
installProgressBar->setMaximum((components.count() * 100));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-12-25 18:52:34 +01:00
|
|
|
if (components.contains(QLatin1String("Tribunal"))
|
|
|
|
&& mWizard->mInstallations[path]->hasTribunal == false)
|
2013-12-24 19:38:21 +01:00
|
|
|
installProgressBar->setMaximum(100);
|
|
|
|
|
2013-12-25 18:52:34 +01:00
|
|
|
if (components.contains(QLatin1String("Bloodmoon"))
|
|
|
|
&& mWizard->mInstallations[path]->hasBloodmoon == false)
|
2013-12-24 19:38:21 +01:00
|
|
|
installProgressBar->setMaximum(installProgressBar->maximum() + 100);
|
|
|
|
}
|
|
|
|
|
2013-12-25 18:52:34 +01:00
|
|
|
startInstallation();
|
2013-12-13 13:38:49 +01:00
|
|
|
}
|
|
|
|
|
2013-12-25 18:52:34 +01:00
|
|
|
void Wizard::InstallationPage::startInstallation()
|
|
|
|
{
|
|
|
|
QStringList components(field("installation.components").toStringList());
|
|
|
|
QString path(field("installation.path").toString());
|
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
QThread *thread = new QThread();
|
|
|
|
mUnshield = new UnshieldWorker();
|
2014-01-01 22:46:29 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->moveToThread(thread);
|
2014-01-01 22:46:29 +01:00
|
|
|
|
|
|
|
connect(thread, SIGNAL(started()),
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield, SLOT(extract()));
|
2014-01-01 22:46:29 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
connect(mUnshield, SIGNAL(finished()),
|
2014-01-01 22:46:29 +01:00
|
|
|
thread, SLOT(quit()));
|
2013-12-25 18:52:34 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
connect(mUnshield, SIGNAL(finished()),
|
|
|
|
mUnshield, SLOT(deleteLater()));
|
2013-12-25 18:52:34 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
connect(mUnshield, SIGNAL(finished()),
|
2014-01-01 22:46:29 +01:00
|
|
|
thread, SLOT(deleteLater()));
|
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
connect(mUnshield, SIGNAL(finished()),
|
2014-01-27 15:12:02 +01:00
|
|
|
this, SLOT(installationFinished()), Qt::QueuedConnection);
|
2013-12-25 18:52:34 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
connect(mUnshield, SIGNAL(error(QString)),
|
2014-01-27 15:12:02 +01:00
|
|
|
this, SLOT(installationError(QString)), Qt::QueuedConnection);
|
2014-01-17 13:21:44 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
connect(mUnshield, SIGNAL(textChanged(QString)),
|
2014-01-27 15:12:02 +01:00
|
|
|
installProgressLabel, SLOT(setText(QString)), Qt::QueuedConnection);
|
2013-12-25 18:52:34 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
connect(mUnshield, SIGNAL(textChanged(QString)),
|
2014-01-27 15:12:02 +01:00
|
|
|
logTextEdit, SLOT(append(QString)), Qt::QueuedConnection);
|
2013-12-25 18:52:34 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
connect(mUnshield, SIGNAL(progressChanged(int)),
|
2014-01-27 15:12:02 +01:00
|
|
|
installProgressBar, SLOT(setValue(int)), Qt::QueuedConnection);
|
2013-12-26 18:02:34 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
connect(mUnshield, SIGNAL(requestFileDialog(QString)),
|
2014-01-27 15:12:02 +01:00
|
|
|
this, SLOT(showFileDialog(QString)), Qt::QueuedConnection);
|
2014-01-24 22:25:22 +01:00
|
|
|
|
2013-12-25 18:52:34 +01:00
|
|
|
if (field("installation.new").toBool() == true)
|
|
|
|
{
|
|
|
|
// Always install Morrowind
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setInstallMorrowind(true);
|
2013-12-25 18:52:34 +01:00
|
|
|
|
|
|
|
if (components.contains(QLatin1String("Tribunal")))
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setInstallTribunal(true);
|
2013-12-25 18:52:34 +01:00
|
|
|
|
|
|
|
if (components.contains(QLatin1String("Bloodmoon")))
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setInstallBloodmoon(true);
|
2013-12-25 18:52:34 +01:00
|
|
|
} else {
|
|
|
|
// Morrowind should already be installed
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setInstallMorrowind(false);
|
2013-12-25 18:52:34 +01:00
|
|
|
|
|
|
|
if (components.contains(QLatin1String("Tribunal"))
|
|
|
|
&& mWizard->mInstallations[path]->hasTribunal == false)
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setInstallTribunal(true);
|
2013-12-25 18:52:34 +01:00
|
|
|
|
|
|
|
if (components.contains(QLatin1String("Bloodmoon"))
|
|
|
|
&& mWizard->mInstallations[path]->hasBloodmoon == false)
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setInstallBloodmoon(true);
|
2013-12-25 18:52:34 +01:00
|
|
|
|
2013-12-26 18:02:34 +01:00
|
|
|
// Set the location of the Morrowind.ini to update
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setIniPath(mWizard->mInstallations[path]->iniPath);
|
2013-12-26 18:02:34 +01:00
|
|
|
}
|
2013-12-25 18:52:34 +01:00
|
|
|
|
|
|
|
// Set the installation target path
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setPath(path);
|
2013-12-25 18:52:34 +01:00
|
|
|
|
2013-12-26 18:02:34 +01:00
|
|
|
// Set the right codec to use for Morrowind.ini
|
|
|
|
QString language(field("installation.language").toString());
|
|
|
|
|
|
|
|
if (language == QLatin1String("Polish")) {
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setIniCodec(QTextCodec::codecForName("windows-1250"));
|
2013-12-26 18:02:34 +01:00
|
|
|
}
|
|
|
|
else if (language == QLatin1String("Russian")) {
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setIniCodec(QTextCodec::codecForName("windows-1251"));
|
2013-12-26 18:02:34 +01:00
|
|
|
}
|
|
|
|
else {
|
2014-01-24 22:25:22 +01:00
|
|
|
mUnshield->setIniCodec(QTextCodec::codecForName("windows-1252"));
|
2013-12-26 18:02:34 +01:00
|
|
|
}
|
|
|
|
|
2014-01-01 22:46:29 +01:00
|
|
|
thread->start();
|
2014-01-24 22:25:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//void Wizard::InstallationPage::installAddons()
|
|
|
|
//{
|
|
|
|
// qDebug() << "component finished";
|
|
|
|
|
|
|
|
// QStringList components(field("installation.components").toStringList());
|
|
|
|
|
|
|
|
// if (components.contains(QLatin1String("Tribunal")) && !mUnshield->tribunalDone())
|
|
|
|
// {
|
|
|
|
// QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
// this,
|
|
|
|
// tr("Select Tribunal installation file"),
|
|
|
|
// QDir::rootPath(),
|
|
|
|
// tr("InstallShield header files (*.hdr)"));
|
|
|
|
|
|
|
|
// if (fileName.isEmpty()) {
|
|
|
|
// qDebug() << "Cancel was clicked!";
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// QFileInfo info(fileName);
|
|
|
|
// mUnshield->installTribunal(info.absolutePath());
|
|
|
|
// }
|
2013-12-25 18:52:34 +01:00
|
|
|
|
2014-01-24 22:25:22 +01:00
|
|
|
// if (components.contains(QLatin1String("Bloodmoon")) && !mUnshield->bloodmoonDone())
|
|
|
|
// {
|
|
|
|
// QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
// this,
|
|
|
|
// tr("Select Bloodmoon installation file"),
|
|
|
|
// QDir::rootPath(),
|
|
|
|
// tr("InstallShield header files (*.hdr)"));
|
|
|
|
|
|
|
|
// if (fileName.isEmpty()) {
|
|
|
|
// qDebug() << "Cancel was clicked!";
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// QFileInfo info(fileName);
|
|
|
|
// mUnshield->installBloodmoon(info.absolutePath());
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
void Wizard::InstallationPage::showFileDialog(const QString &component)
|
|
|
|
{
|
|
|
|
QString fileName;
|
|
|
|
|
|
|
|
if (field("installation.new").toBool() == true)
|
|
|
|
{
|
|
|
|
fileName = QFileDialog::getOpenFileName(
|
|
|
|
this,
|
|
|
|
tr("Select %0 installation file").arg(component),
|
|
|
|
QDir::rootPath(),
|
|
|
|
tr("InstallShield header files (*.hdr)"));
|
|
|
|
|
|
|
|
if (fileName.isEmpty()) {
|
|
|
|
qDebug() << "Cancel was clicked!";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QFileInfo info(fileName);
|
|
|
|
|
|
|
|
if (component == QLatin1String("Morrowind"))
|
|
|
|
{
|
|
|
|
mUnshield->setMorrowindPath(info.absolutePath());
|
|
|
|
}
|
|
|
|
else if (component == QLatin1String("Tribunal"))
|
|
|
|
{
|
|
|
|
mUnshield->setTribunalPath(info.absolutePath());
|
|
|
|
}
|
|
|
|
else if (component == QLatin1String("Bloodmoon"))
|
|
|
|
{
|
|
|
|
mUnshield->setBloodmoonPath(info.absolutePath());
|
|
|
|
}
|
|
|
|
}
|
2013-12-25 18:52:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Wizard::InstallationPage::installationFinished()
|
|
|
|
{
|
2014-01-01 22:46:29 +01:00
|
|
|
qDebug() << "finished!";
|
2013-12-25 18:52:34 +01:00
|
|
|
mFinished = true;
|
2013-12-26 18:02:34 +01:00
|
|
|
emit completeChanged();
|
2014-01-17 13:21:44 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Wizard::InstallationPage::installationError(const QString &text)
|
|
|
|
{
|
|
|
|
qDebug() << "error: " << text;
|
2013-12-25 18:52:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Wizard::InstallationPage::isComplete() const
|
|
|
|
{
|
|
|
|
return mFinished;
|
|
|
|
}
|
|
|
|
|
2013-12-08 22:58:29 +01:00
|
|
|
int Wizard::InstallationPage::nextId() const
|
|
|
|
{
|
|
|
|
return MainWizard::Page_Import;
|
|
|
|
}
|