Working on the Unshield functionality

pull/136/head
pvdk 11 years ago
parent dddd9cba57
commit 40486370d9

@ -9,6 +9,7 @@
#include "mainwizard.hpp"
#include "inisettings.hpp"
#include "unshieldthread.hpp"
Wizard::InstallationPage::InstallationPage(MainWizard *wizard) :
QWizardPage(wizard),
@ -37,10 +38,12 @@ void Wizard::InstallationPage::initializePage()
}
else
{
if (components.contains("Tribunal") && mWizard->mInstallations[path]->hasTribunal == false)
if (components.contains(QLatin1String("Tribunal"))
&& mWizard->mInstallations[path]->hasTribunal == false)
installProgressBar->setMaximum(100);
if (components.contains("Bloodmoon") && mWizard->mInstallations[path]->hasBloodmoon == false)
if (components.contains(QLatin1String("Bloodmoon"))
&& mWizard->mInstallations[path]->hasBloodmoon == false)
installProgressBar->setMaximum(installProgressBar->maximum() + 100);
}
@ -48,6 +51,9 @@ void Wizard::InstallationPage::initializePage()
if (field("installation.new").toBool() == false)
setupSettings();
startInstallation();
}
void Wizard::InstallationPage::setupSettings()
@ -90,6 +96,67 @@ void Wizard::InstallationPage::setupSettings()
qDebug() << iniSettings.value("Game Files/GameFile0");
}
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)));
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)
unshield->setInstallTribunal(false);
if (components.contains(QLatin1String("Bloodmoon"))
&& mWizard->mInstallations[path]->hasBloodmoon == false)
unshield->setInstallBloodmoon(true);
}
// Set the installation target path
unshield->setPath(path);
unshield->start();
}
void Wizard::InstallationPage::installationFinished()
{
qDebug() << "Installation finished!";
mFinished = true;
}
bool Wizard::InstallationPage::isComplete() const
{
return mFinished;
}
int Wizard::InstallationPage::nextId() const
{
return MainWizard::Page_Import;

@ -16,11 +16,17 @@ namespace Wizard
InstallationPage(MainWizard *wizard);
int nextId() const;
virtual bool isComplete() const;
private:
MainWizard *mWizard;
bool mFinished;
void setupSettings();
void startInstallation();
private slots:
void installationFinished();
protected:
void initializePage();

@ -0,0 +1,61 @@
#include "unshieldthread.hpp"
#include <QDebug>
#include <QStringList>
Wizard::UnshieldThread::UnshieldThread(QObject *parent) :
QThread(parent)
{
unshield_set_log_level(0);
mInstallMorrowind = false;
mInstallTribunal = false;
mInstallBloodmoon = false;
}
void Wizard::UnshieldThread::setInstallMorrowind(bool install)
{
mInstallMorrowind = install;
}
void Wizard::UnshieldThread::setInstallTribunal(bool install)
{
mInstallTribunal = install;
}
void Wizard::UnshieldThread::setInstallBloodmoon(bool install)
{
mInstallBloodmoon = install;
}
void Wizard::UnshieldThread::setPath(const QString &path)
{
mPath = path;
}
void Wizard::UnshieldThread::extract()
{
emit textChanged(QLatin1String("Starting installation"));
emit textChanged(QLatin1String("Installation target: ") + mPath);
QStringList components;
if (mInstallMorrowind)
components << QLatin1String("Morrowind");
if (mInstallTribunal)
components << QLatin1String("Tribunal");
if (mInstallBloodmoon)
components << QLatin1String("Bloodmoon");
emit textChanged(QLatin1String("Components: ") + components.join(QLatin1String(", ")));
}
void Wizard::UnshieldThread::run()
{
qDebug() << "From worker thread: " << currentThreadId();
extract();
}

@ -0,0 +1,47 @@
#ifndef UNSHIELDTHREAD_HPP
#define UNSHIELDTHREAD_HPP
#include <QThread>
#include <libunshield.h>
namespace Wizard
{
class UnshieldThread : public QThread
{
Q_OBJECT
public:
explicit UnshieldThread(QObject *parent = 0);
void setInstallMorrowind(bool install);
void setInstallTribunal(bool install);
void setInstallBloodmoon(bool install);
void setPath(const QString &path);
private:
void extract();
void extractCab(const QString &cabFile,
const QString &outputDir, bool extractIni);
//void extractFile(Unshield *unshield,
// )
bool mInstallMorrowind;
bool mInstallTribunal;
bool mInstallBloodmoon;
QString mPath;
protected:
virtual void run();
signals:
void textChanged(const QString &text);
};
}
#endif // UNSHIELDTHREAD_HPP

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>518</width>
<height>423</height>
<width>516</width>
<height>421</height>
</rect>
</property>
<property name="windowTitle">
@ -21,7 +21,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="InstallProgressLabel">
<widget class="QLabel" name="installProgressLabel">
<property name="text">
<string>Extracting: %1</string>
</property>

Loading…
Cancel
Save