1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 03:21:41 +00:00
OpenMW/apps/wizard/installationpage.cpp

136 lines
3.9 KiB
C++
Raw Normal View History

2013-12-08 20:35:57 +00:00
#include "installationpage.hpp"
#include <QDebug>
2013-12-24 18:38:21 +00:00
#include <QTextCodec>
2013-12-08 21:58:29 +00:00
#include "mainwizard.hpp"
2013-12-24 18:38:21 +00:00
#include "inisettings.hpp"
2013-12-25 17:52:34 +00:00
#include "unshieldthread.hpp"
2013-12-08 21:58:29 +00:00
Wizard::InstallationPage::InstallationPage(MainWizard *wizard) :
QWizardPage(wizard),
mWizard(wizard)
2013-12-08 20:35:57 +00:00
{
setupUi(this);
2013-12-26 17:02:34 +00:00
mFinished = false;
2013-12-08 20:35:57 +00:00
}
2013-12-08 21:58:29 +00:00
void Wizard::InstallationPage::initializePage()
{
2013-12-24 22:09:31 +00:00
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(", ")));
2013-12-24 18:38:21 +00: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 17:52:34 +00:00
if (components.contains(QLatin1String("Tribunal"))
&& mWizard->mInstallations[path]->hasTribunal == false)
2013-12-24 18:38:21 +00:00
installProgressBar->setMaximum(100);
2013-12-25 17:52:34 +00:00
if (components.contains(QLatin1String("Bloodmoon"))
&& mWizard->mInstallations[path]->hasBloodmoon == false)
2013-12-24 18:38:21 +00:00
installProgressBar->setMaximum(installProgressBar->maximum() + 100);
}
installProgressBar->setValue(100);
2013-12-25 17:52:34 +00:00
startInstallation();
}
2013-12-25 17:52:34 +00:00
void Wizard::InstallationPage::startInstallation()
{
QStringList components(field("installation.components").toStringList());
QString path(field("installation.path").toString());
UnshieldThread *unshield = new UnshieldThread();
connect(unshield, SIGNAL(finished()),
unshield, SLOT(deleteLater()));
connect(unshield, SIGNAL(finished()),
this, SLOT(installationFinished()));
connect(unshield, SIGNAL(textChanged(QString)),
installProgressLabel, SLOT(setText(QString)));
connect(unshield, SIGNAL(textChanged(QString)),
logTextEdit, SLOT(append(QString)));
2013-12-26 17:02:34 +00:00
connect(unshield, SIGNAL(progressChanged(int)),
installProgressBar, SLOT(setValue(int)));
2013-12-25 17:52:34 +00:00
if (field("installation.new").toBool() == true)
{
// Always install Morrowind
unshield->setInstallMorrowind(true);
if (components.contains(QLatin1String("Tribunal")))
unshield->setInstallTribunal(true);
if (components.contains(QLatin1String("Bloodmoon")))
unshield->setInstallBloodmoon(true);
} else {
// Morrowind should already be installed
unshield->setInstallMorrowind(false);
if (components.contains(QLatin1String("Tribunal"))
&& mWizard->mInstallations[path]->hasTribunal == false)
2013-12-26 17:02:34 +00:00
unshield->setInstallTribunal(true);
2013-12-25 17:52:34 +00:00
if (components.contains(QLatin1String("Bloodmoon"))
&& mWizard->mInstallations[path]->hasBloodmoon == false)
unshield->setInstallBloodmoon(true);
2013-12-26 17:02:34 +00:00
// Set the location of the Morrowind.ini to update
unshield->setIniPath(mWizard->mInstallations[path]->iniPath);
}
2013-12-25 17:52:34 +00:00
// Set the installation target path
unshield->setPath(path);
2013-12-26 17:02:34 +00:00
// Set the right codec to use for Morrowind.ini
QString language(field("installation.language").toString());
if (language == QLatin1String("Polish")) {
unshield->setIniCodec(QTextCodec::codecForName("windows-1250"));
}
else if (language == QLatin1String("Russian")) {
unshield->setIniCodec(QTextCodec::codecForName("windows-1251"));
}
else {
unshield->setIniCodec(QTextCodec::codecForName("windows-1252"));
}
2013-12-25 17:52:34 +00:00
unshield->start();
}
void Wizard::InstallationPage::installationFinished()
{
mFinished = true;
2013-12-26 17:02:34 +00:00
emit completeChanged();
2013-12-25 17:52:34 +00:00
}
bool Wizard::InstallationPage::isComplete() const
{
return mFinished;
}
2013-12-08 21:58:29 +00:00
int Wizard::InstallationPage::nextId() const
{
return MainWizard::Page_Import;
}