mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 00:36:46 +00:00
Made the getter/setter functions thread-safe
This commit is contained in:
parent
cdbf5c68b0
commit
8db333c8d0
3 changed files with 155 additions and 148 deletions
|
@ -73,22 +73,22 @@ void Wizard::InstallationPage::startInstallation()
|
||||||
thread, SLOT(deleteLater()));
|
thread, SLOT(deleteLater()));
|
||||||
|
|
||||||
connect(mUnshield, SIGNAL(finished()),
|
connect(mUnshield, SIGNAL(finished()),
|
||||||
this, SLOT(installationFinished()));
|
this, SLOT(installationFinished()), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(mUnshield, SIGNAL(error(QString)),
|
connect(mUnshield, SIGNAL(error(QString)),
|
||||||
this, SLOT(installationError(QString)));
|
this, SLOT(installationError(QString)), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(mUnshield, SIGNAL(textChanged(QString)),
|
connect(mUnshield, SIGNAL(textChanged(QString)),
|
||||||
installProgressLabel, SLOT(setText(QString)));
|
installProgressLabel, SLOT(setText(QString)), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(mUnshield, SIGNAL(textChanged(QString)),
|
connect(mUnshield, SIGNAL(textChanged(QString)),
|
||||||
logTextEdit, SLOT(append(QString)));
|
logTextEdit, SLOT(append(QString)), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(mUnshield, SIGNAL(progressChanged(int)),
|
connect(mUnshield, SIGNAL(progressChanged(int)),
|
||||||
installProgressBar, SLOT(setValue(int)));
|
installProgressBar, SLOT(setValue(int)), Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(mUnshield, SIGNAL(requestFileDialog(QString)),
|
connect(mUnshield, SIGNAL(requestFileDialog(QString)),
|
||||||
this, SLOT(showFileDialog(QString)));
|
this, SLOT(showFileDialog(QString)), Qt::QueuedConnection);
|
||||||
|
|
||||||
if (field("installation.new").toBool() == true)
|
if (field("installation.new").toBool() == true)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <QReadLocker>
|
||||||
|
#include <QWriteLocker>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFileInfoListIterator>
|
#include <QFileInfoListIterator>
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
@ -47,68 +48,50 @@ Wizard::UnshieldWorker::~UnshieldWorker()
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setInstallMorrowind(bool install)
|
void Wizard::UnshieldWorker::setInstallMorrowind(bool install)
|
||||||
{
|
{
|
||||||
// QMutexLocker locker(&mMutex);
|
QWriteLocker writeLock(&mLock);
|
||||||
mInstallMorrowind = install;
|
mInstallMorrowind = install;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setInstallTribunal(bool install)
|
void Wizard::UnshieldWorker::setInstallTribunal(bool install)
|
||||||
{
|
{
|
||||||
// QMutexLocker locker(&mMutex);
|
QWriteLocker writeLock(&mLock);
|
||||||
mInstallTribunal = install;
|
mInstallTribunal = install;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setInstallBloodmoon(bool install)
|
void Wizard::UnshieldWorker::setInstallBloodmoon(bool install)
|
||||||
{
|
{
|
||||||
// QMutexLocker locker(&mMutex);
|
QWriteLocker writeLock(&mLock);
|
||||||
mInstallBloodmoon = install;
|
mInstallBloodmoon = install;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wizard::UnshieldWorker::getInstallMorrowind()
|
bool Wizard::UnshieldWorker::getInstallMorrowind()
|
||||||
{
|
{
|
||||||
// QMutexLocker locker(&mMutex);
|
QReadLocker readLock(&mLock);
|
||||||
return mInstallMorrowind;
|
return mInstallMorrowind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wizard::UnshieldWorker::getInstallTribunal()
|
bool Wizard::UnshieldWorker::getInstallTribunal()
|
||||||
{
|
{
|
||||||
// QMutexLocker locker(&mMutex);
|
QReadLocker readLock(&mLock);
|
||||||
return mInstallTribunal;
|
return mInstallTribunal;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wizard::UnshieldWorker::getInstallBloodmoon()
|
bool Wizard::UnshieldWorker::getInstallBloodmoon()
|
||||||
{
|
{
|
||||||
// QMutexLocker locker(&mMutex);
|
QReadLocker readLock(&mLock);
|
||||||
return mInstallBloodmoon;
|
return mInstallBloodmoon;
|
||||||
}
|
}
|
||||||
|
|
||||||
//bool Wizard::UnshieldWorker::getMorrowindDone()
|
|
||||||
//{
|
|
||||||
// QMutexLocker locker(&mMutex);
|
|
||||||
// return mMorrowindDone;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//bool Wizard::UnshieldWorker::tribunalDone()
|
|
||||||
//{
|
|
||||||
// QMutexLocker locker(&mMutex);
|
|
||||||
// return mTribunalDone;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//bool Wizard::UnshieldWorker::bloodmoonDone()
|
|
||||||
//{
|
|
||||||
// return mBloodmoonDone;
|
|
||||||
//}
|
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setMorrowindPath(const QString &path)
|
void Wizard::UnshieldWorker::setMorrowindPath(const QString &path)
|
||||||
{
|
{
|
||||||
qDebug() << "setmorrowindpath!";
|
QWriteLocker writeLock(&mLock);
|
||||||
QMutexLocker locker(&mMutex);
|
|
||||||
mMorrowindPath = path;
|
mMorrowindPath = path;
|
||||||
mWait.wakeAll();
|
mWait.wakeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setTribunalPath(const QString &path)
|
void Wizard::UnshieldWorker::setTribunalPath(const QString &path)
|
||||||
{
|
{
|
||||||
//QMutexLocker locker(&mMutex);
|
QWriteLocker writeLock(&mLock);
|
||||||
mTribunalPath = path;
|
mTribunalPath = path;
|
||||||
mWait.wakeAll();
|
mWait.wakeAll();
|
||||||
|
|
||||||
|
@ -116,7 +99,7 @@ void Wizard::UnshieldWorker::setTribunalPath(const QString &path)
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setBloodmoonPath(const QString &path)
|
void Wizard::UnshieldWorker::setBloodmoonPath(const QString &path)
|
||||||
{
|
{
|
||||||
//QMutexLocker locker(&mMutex);
|
QWriteLocker writeLock(&mLock);
|
||||||
mBloodmoonPath = path;
|
mBloodmoonPath = path;
|
||||||
mWait.wakeAll();
|
mWait.wakeAll();
|
||||||
|
|
||||||
|
@ -124,57 +107,99 @@ void Wizard::UnshieldWorker::setBloodmoonPath(const QString &path)
|
||||||
|
|
||||||
QString Wizard::UnshieldWorker::getMorrowindPath()
|
QString Wizard::UnshieldWorker::getMorrowindPath()
|
||||||
{
|
{
|
||||||
qDebug() << "getmorrowindpath!";
|
QReadLocker readLock(&mLock);
|
||||||
//QMutexLocker locker(&mMutex);
|
|
||||||
//mWait.wakeAll();
|
|
||||||
return mMorrowindPath;
|
return mMorrowindPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Wizard::UnshieldWorker::getTribunalPath()
|
QString Wizard::UnshieldWorker::getTribunalPath()
|
||||||
{
|
{
|
||||||
//QMutexLocker locker(&mMutex);
|
QReadLocker readLock(&mLock);
|
||||||
return mTribunalPath;
|
return mTribunalPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Wizard::UnshieldWorker::getBloodmoonPath()
|
QString Wizard::UnshieldWorker::getBloodmoonPath()
|
||||||
{
|
{
|
||||||
//QMutexLocker locker(&mMutex);
|
QReadLocker readLock(&mLock);
|
||||||
return mBloodmoonPath;
|
return mBloodmoonPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setPath(const QString &path)
|
void Wizard::UnshieldWorker::setPath(const QString &path)
|
||||||
{
|
{
|
||||||
|
QWriteLocker writeLock(&mLock);
|
||||||
mPath = path;
|
mPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setIniPath(const QString &path)
|
void Wizard::UnshieldWorker::setIniPath(const QString &path)
|
||||||
{
|
{
|
||||||
|
QWriteLocker writeLock(&mLock);
|
||||||
mIniPath = path;
|
mIniPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Wizard::UnshieldWorker::getPath()
|
||||||
|
{
|
||||||
|
QReadLocker readLock(&mLock);
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Wizard::UnshieldWorker::getIniPath()
|
||||||
|
{
|
||||||
|
QReadLocker readLock(&mLock);
|
||||||
|
return mIniPath;
|
||||||
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setIniCodec(QTextCodec *codec)
|
void Wizard::UnshieldWorker::setIniCodec(QTextCodec *codec)
|
||||||
{
|
{
|
||||||
|
QWriteLocker writeLock(&mLock);
|
||||||
mIniCodec = codec;
|
mIniCodec = codec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wizard::UnshieldWorker::setMorrowindDone(bool done)
|
||||||
|
{
|
||||||
|
QWriteLocker writeLock(&mLock);
|
||||||
|
mMorrowindDone = done;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Wizard::UnshieldWorker::setTribunalDone(bool done)
|
||||||
|
{
|
||||||
|
QWriteLocker writeLock(&mLock);
|
||||||
|
mTribunalDone = done;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Wizard::UnshieldWorker::setBloodmoonDone(bool done)
|
||||||
|
{
|
||||||
|
QWriteLocker writeLock(&mLock);
|
||||||
|
mBloodmoonDone = done;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Wizard::UnshieldWorker::getMorrowindDone()
|
||||||
|
{
|
||||||
|
QReadLocker readLock(&mLock);
|
||||||
|
return mMorrowindDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Wizard::UnshieldWorker::getTribunalDone()
|
||||||
|
{
|
||||||
|
QReadLocker readLock(&mLock);
|
||||||
|
return mTribunalDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Wizard::UnshieldWorker::getBloodmoonDone()
|
||||||
|
{
|
||||||
|
QReadLocker readLock(&mLock);
|
||||||
|
return mBloodmoonDone;
|
||||||
|
}
|
||||||
|
|
||||||
void Wizard::UnshieldWorker::setupSettings()
|
void Wizard::UnshieldWorker::setupSettings()
|
||||||
{
|
{
|
||||||
// Create Morrowind.ini settings map
|
// Create Morrowind.ini settings map
|
||||||
if (mIniPath.isEmpty())
|
if (getIniPath().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QFile file(mIniPath);
|
QFile file(getIniPath());
|
||||||
|
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
// TODO: Emit error signal
|
// TODO: Emit error signal
|
||||||
QMessageBox msgBox;
|
qDebug() << "Error opening .ini file!";
|
||||||
msgBox.setWindowTitle(tr("Error opening Morrowind configuration file"));
|
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
||||||
msgBox.setText(QObject::tr("<br><b>Could not open %0 for reading</b><br><br> \
|
|
||||||
Please make sure you have the right permissions \
|
|
||||||
and try again.<br>").arg(file.fileName()));
|
|
||||||
msgBox.exec();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +333,7 @@ void Wizard::UnshieldWorker::installDirectories(const QString &source)
|
||||||
if (directories.contains(info.fileName())) {
|
if (directories.contains(info.fileName())) {
|
||||||
qDebug() << "found " << info.fileName();
|
qDebug() << "found " << info.fileName();
|
||||||
emit textChanged(tr("Extracting: %1 directory").arg(info.fileName()));
|
emit textChanged(tr("Extracting: %1 directory").arg(info.fileName()));
|
||||||
copyDirectory(info.absoluteFilePath(), mPath + QDir::separator() + info.fileName());
|
copyDirectory(info.absoluteFilePath(), getPath() + QDir::separator() + info.fileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +341,7 @@ void Wizard::UnshieldWorker::installDirectories(const QString &source)
|
||||||
QFileInfo info(dir.absoluteFilePath("Data Files"));
|
QFileInfo info(dir.absoluteFilePath("Data Files"));
|
||||||
if (info.exists()) {
|
if (info.exists()) {
|
||||||
emit textChanged(tr("Extracting: Data Files directory"));
|
emit textChanged(tr("Extracting: Data Files directory"));
|
||||||
copyDirectory(info.absoluteFilePath(), mPath);
|
copyDirectory(info.absoluteFilePath(), getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -325,36 +350,32 @@ void Wizard::UnshieldWorker::installDirectories(const QString &source)
|
||||||
void Wizard::UnshieldWorker::extract()
|
void Wizard::UnshieldWorker::extract()
|
||||||
{
|
{
|
||||||
qDebug() << "extract!";
|
qDebug() << "extract!";
|
||||||
|
|
||||||
QMutexLocker locker(&mMutex);
|
|
||||||
|
|
||||||
QDir disk;
|
QDir disk;
|
||||||
|
|
||||||
qDebug() << "hi!";
|
|
||||||
|
|
||||||
if (getInstallMorrowind())
|
if (getInstallMorrowind())
|
||||||
{
|
{
|
||||||
while (!mMorrowindDone)
|
while (!getMorrowindDone())
|
||||||
{
|
{
|
||||||
if (getMorrowindPath().isEmpty()) {
|
if (getMorrowindPath().isEmpty()) {
|
||||||
qDebug() << "request file dialog";
|
qDebug() << "request file dialog";
|
||||||
|
QReadLocker readLock(&mLock);
|
||||||
emit requestFileDialog(QLatin1String("Morrowind"));
|
emit requestFileDialog(QLatin1String("Morrowind"));
|
||||||
mWait.wait(&mMutex);
|
mWait.wait(&mLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mMorrowindDone && !getMorrowindPath().isEmpty()) {
|
if (!getMorrowindPath().isEmpty()) {
|
||||||
disk.setPath(getMorrowindPath());
|
disk.setPath(getMorrowindPath());
|
||||||
|
|
||||||
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Morrowind.bsa"))) {
|
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Morrowind.bsa"))
|
||||||
qDebug() << "found";
|
| findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Tribunal.bsa"))
|
||||||
|
| findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Bloodmoon.bsa")))
|
||||||
|
{
|
||||||
|
QReadLocker readLock(&mLock);
|
||||||
emit requestFileDialog(QLatin1String("Morrowind"));
|
emit requestFileDialog(QLatin1String("Morrowind"));
|
||||||
mWait.wait(&mMutex);
|
mWait.wait(&mLock);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "install morrowind!";
|
|
||||||
|
|
||||||
if (installMorrowind()) {
|
if (installMorrowind()) {
|
||||||
mMorrowindDone = true;
|
setMorrowindDone(true);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Erorr installing Morrowind";
|
qDebug() << "Erorr installing Morrowind";
|
||||||
return;
|
return;
|
||||||
|
@ -366,41 +387,31 @@ void Wizard::UnshieldWorker::extract()
|
||||||
|
|
||||||
if (getInstallTribunal())
|
if (getInstallTribunal())
|
||||||
{
|
{
|
||||||
while (!mTribunalDone)
|
while (!getTribunalDone())
|
||||||
{
|
{
|
||||||
QDir tribunal(disk);
|
|
||||||
|
|
||||||
if (!tribunal.cd(QLatin1String("Tribunal"))) {
|
|
||||||
qDebug() << "not found on cd!";
|
|
||||||
emit requestFileDialog(QLatin1String("Tribunal"));
|
|
||||||
mWait.wait(&mMutex);
|
|
||||||
|
|
||||||
} else if (tribunal.exists(QLatin1String("data1.hdr"))) {
|
|
||||||
qDebug() << "Exists! " << tribunal.absolutePath();
|
|
||||||
mTribunalPath = tribunal.absolutePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getTribunalPath().isEmpty()) {
|
if (getTribunalPath().isEmpty()) {
|
||||||
qDebug() << "request file dialog";
|
qDebug() << "request file dialog";
|
||||||
|
QReadLocker locker(&mLock);
|
||||||
emit requestFileDialog(QLatin1String("Tribunal"));
|
emit requestFileDialog(QLatin1String("Tribunal"));
|
||||||
mWait.wait(&mMutex);
|
mWait.wait(&mLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the dir is up-to-date
|
if (!getTribunalPath().isEmpty()) {
|
||||||
tribunal.setPath(getTribunalPath());
|
disk.setPath(getTribunalPath());
|
||||||
|
|
||||||
if (!findFile(tribunal.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Tribunal.bsa"))) {
|
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Tribunal.bsa")))
|
||||||
qDebug() << "file not found!";
|
{
|
||||||
emit requestFileDialog(QLatin1String("Tribunal"));
|
qDebug() << "found";
|
||||||
mWait.wait(&mMutex);
|
QReadLocker locker(&mLock);
|
||||||
|
emit requestFileDialog(QLatin1String("Tribunal"));
|
||||||
} else {
|
mWait.wait(&mLock);
|
||||||
qDebug() << "install tribunal!";
|
|
||||||
if (installTribunal()) {
|
|
||||||
mTribunalDone = true;
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Erorr installing Tribunal";
|
if (installTribunal()) {
|
||||||
return;
|
setTribunalDone(true);
|
||||||
|
} else {
|
||||||
|
qDebug() << "Erorr installing Tribunal";
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,50 +419,35 @@ void Wizard::UnshieldWorker::extract()
|
||||||
|
|
||||||
if (getInstallBloodmoon())
|
if (getInstallBloodmoon())
|
||||||
{
|
{
|
||||||
while (!mBloodmoonDone)
|
while (!getBloodmoonDone())
|
||||||
{
|
{
|
||||||
QDir bloodmoon(disk);
|
|
||||||
|
|
||||||
qDebug() << "bloodmoon!: " << bloodmoon.absolutePath();
|
|
||||||
|
|
||||||
if (!bloodmoon.cd(QLatin1String("Bloodmoon"))) {
|
|
||||||
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
|
||||||
mWait.wait(&mMutex);
|
|
||||||
|
|
||||||
} else if (bloodmoon.exists(QLatin1String("data1.hdr"))) {
|
|
||||||
mBloodmoonPath = bloodmoon.absolutePath();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getBloodmoonPath().isEmpty()) {
|
if (getBloodmoonPath().isEmpty()) {
|
||||||
qDebug() << "request file dialog";
|
qDebug() << "request file dialog";
|
||||||
|
QReadLocker locker(&mLock);
|
||||||
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
||||||
mWait.wait(&mMutex);
|
mWait.wait(&mLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the dir is up-to-date
|
if (!getBloodmoonPath().isEmpty()) {
|
||||||
bloodmoon.setPath(getBloodmoonPath());
|
disk.setPath(getBloodmoonPath());
|
||||||
|
|
||||||
if (!findFile(bloodmoon.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Bloodmoon.bsa"))) {
|
if (!findFile(disk.absoluteFilePath(QLatin1String("data1.hdr")), QLatin1String("Bloodmoon.bsa")))
|
||||||
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
{
|
||||||
mWait.wait(&mMutex);
|
QReadLocker locker(&mLock);
|
||||||
|
emit requestFileDialog(QLatin1String("Bloodmoon"));
|
||||||
} else {
|
mWait.wait(&mLock);
|
||||||
qDebug() << "install bloodmoon!";
|
|
||||||
if (installBloodmoon()) {
|
|
||||||
mBloodmoonDone = true;
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Erorr installing Bloodmoon";
|
if (installBloodmoon()) {
|
||||||
return;
|
setBloodmoonDone(true);
|
||||||
|
} else {
|
||||||
|
qDebug() << "Erorr installing Bloodmoon";
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the temporary directory
|
|
||||||
removeDirectory(mPath + QDir::separator() + QLatin1String("extract-temp"));
|
|
||||||
|
|
||||||
locker.unlock();
|
|
||||||
|
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
if (mInstallMorrowind)
|
if (mInstallMorrowind)
|
||||||
|
@ -472,16 +468,19 @@ void Wizard::UnshieldWorker::extract()
|
||||||
|
|
||||||
bool Wizard::UnshieldWorker::installMorrowind()
|
bool Wizard::UnshieldWorker::installMorrowind()
|
||||||
{
|
{
|
||||||
emit textChanged(QLatin1String("Installing Morrowind\n"));
|
qDebug() << "install morrowind!";
|
||||||
|
emit textChanged(QLatin1String("Installing Morrowind"));
|
||||||
|
|
||||||
QDir disk(getMorrowindPath());
|
QDir disk(getMorrowindPath());
|
||||||
|
|
||||||
if (!disk.exists())
|
if (!disk.exists()) {
|
||||||
|
qDebug() << "getMorrowindPath: " << getMorrowindPath();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Create temporary extract directory
|
// Create temporary extract directory
|
||||||
// TODO: Use QTemporaryDir in Qt 5.0
|
// TODO: Use QTemporaryDir in Qt 5.0
|
||||||
QString tempPath(mPath + QDir::separator() + QLatin1String("extract-temp"));
|
QString tempPath(getPath() + QDir::separator() + QLatin1String("extract-temp"));
|
||||||
QDir temp;
|
QDir temp;
|
||||||
|
|
||||||
// Make sure the temporary folder is empty
|
// Make sure the temporary folder is empty
|
||||||
|
@ -494,8 +493,6 @@ bool Wizard::UnshieldWorker::installMorrowind()
|
||||||
|
|
||||||
temp.setPath(tempPath);
|
temp.setPath(tempPath);
|
||||||
|
|
||||||
QString cabFile(disk.absoluteFilePath(QLatin1String("data1.hdr")));
|
|
||||||
|
|
||||||
if (!temp.mkdir(QLatin1String("morrowind"))) {
|
if (!temp.mkdir(QLatin1String("morrowind"))) {
|
||||||
qDebug() << "Can't make dir";
|
qDebug() << "Can't make dir";
|
||||||
return false;
|
return false;
|
||||||
|
@ -511,7 +508,8 @@ bool Wizard::UnshieldWorker::installMorrowind()
|
||||||
|
|
||||||
// TODO: Throw error;
|
// TODO: Throw error;
|
||||||
// Move the files from the temporary path to the destination folder
|
// Move the files from the temporary path to the destination folder
|
||||||
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath)) {
|
emit textChanged(tr("Moving installation files"));
|
||||||
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) {
|
||||||
qDebug() << "failed to move files!";
|
qDebug() << "failed to move files!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -525,16 +523,17 @@ bool Wizard::UnshieldWorker::installMorrowind()
|
||||||
|
|
||||||
QFileInfo info(iniPath);
|
QFileInfo info(iniPath);
|
||||||
|
|
||||||
qDebug() << info.absoluteFilePath() << mPath;
|
qDebug() << info.absoluteFilePath() << getPath();
|
||||||
|
|
||||||
if (info.exists()) {
|
if (info.exists()) {
|
||||||
emit textChanged(tr("Extracting: Morrowind.ini"));
|
emit textChanged(tr("Extracting: Morrowind.ini"));
|
||||||
moveFile(info.absoluteFilePath(), mPath + QDir::separator() + QLatin1String("Morrowind.ini"));
|
moveFile(info.absoluteFilePath(), getPath() + QDir::separator() + QLatin1String("Morrowind.ini"));
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Could not find ini file!";
|
qDebug() << "Could not find ini file!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit textChanged(tr("Morrowind installation finished!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,7 +550,7 @@ bool Wizard::UnshieldWorker::installTribunal()
|
||||||
|
|
||||||
// Create temporary extract directory
|
// Create temporary extract directory
|
||||||
// TODO: Use QTemporaryDir in Qt 5.0
|
// TODO: Use QTemporaryDir in Qt 5.0
|
||||||
QString tempPath(mPath + QDir::separator() + QLatin1String("extract-temp"));
|
QString tempPath(getPath() + QDir::separator() + QLatin1String("extract-temp"));
|
||||||
QDir temp;
|
QDir temp;
|
||||||
|
|
||||||
// Make sure the temporary folder is empty
|
// Make sure the temporary folder is empty
|
||||||
|
@ -579,7 +578,8 @@ bool Wizard::UnshieldWorker::installTribunal()
|
||||||
|
|
||||||
// TODO: Throw error;
|
// TODO: Throw error;
|
||||||
// Move the files from the temporary path to the destination folder
|
// Move the files from the temporary path to the destination folder
|
||||||
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath)) {
|
emit textChanged(tr("Moving installation files"));
|
||||||
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) {
|
||||||
qDebug() << "failed to move files!";
|
qDebug() << "failed to move files!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -587,6 +587,7 @@ bool Wizard::UnshieldWorker::installTribunal()
|
||||||
// Install files outside of cab archives
|
// Install files outside of cab archives
|
||||||
installDirectories(disk.absolutePath());
|
installDirectories(disk.absolutePath());
|
||||||
|
|
||||||
|
emit textChanged(tr("Tribunal installation finished!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,13 +598,12 @@ bool Wizard::UnshieldWorker::installBloodmoon()
|
||||||
QDir disk(getBloodmoonPath());
|
QDir disk(getBloodmoonPath());
|
||||||
|
|
||||||
if (!disk.exists()) {
|
if (!disk.exists()) {
|
||||||
qDebug() << "disk does not exist! " << disk.absolutePath() << getTribunalPath();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create temporary extract directory
|
// Create temporary extract directory
|
||||||
// TODO: Use QTemporaryDir in Qt 5.0
|
// TODO: Use QTemporaryDir in Qt 5.0
|
||||||
QString tempPath(mPath + QDir::separator() + QLatin1String("extract-temp"));
|
QString tempPath(getPath() + QDir::separator() + QLatin1String("extract-temp"));
|
||||||
QDir temp;
|
QDir temp;
|
||||||
|
|
||||||
// Make sure the temporary folder is empty
|
// Make sure the temporary folder is empty
|
||||||
|
@ -631,7 +631,8 @@ bool Wizard::UnshieldWorker::installBloodmoon()
|
||||||
|
|
||||||
// TODO: Throw error;
|
// TODO: Throw error;
|
||||||
// Move the files from the temporary path to the destination folder
|
// Move the files from the temporary path to the destination folder
|
||||||
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), mPath)) {
|
emit textChanged(tr("Moving installation files"));
|
||||||
|
if (!moveDirectory(temp.absoluteFilePath(QLatin1String("Data Files")), getPath())) {
|
||||||
qDebug() << "failed to move files!";
|
qDebug() << "failed to move files!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -640,13 +641,14 @@ bool Wizard::UnshieldWorker::installBloodmoon()
|
||||||
installDirectories(disk.absolutePath());
|
installDirectories(disk.absolutePath());
|
||||||
|
|
||||||
QFileInfo patch(temp.absoluteFilePath(QLatin1String("Tribunal Patch") + QDir::separator() + QLatin1String("Tribunal.esm")));
|
QFileInfo patch(temp.absoluteFilePath(QLatin1String("Tribunal Patch") + QDir::separator() + QLatin1String("Tribunal.esm")));
|
||||||
QFileInfo original(mPath + QDir::separator() + QLatin1String("Tribunal.esm"));
|
QFileInfo original(getPath() + QDir::separator() + QLatin1String("Tribunal.esm"));
|
||||||
|
|
||||||
if (original.exists() && patch.exists()) {
|
if (original.exists() && patch.exists()) {
|
||||||
emit textChanged(tr("Extracting: Tribunal patch"));
|
emit textChanged(tr("Extracting: Tribunal patch"));
|
||||||
copyFile(patch.absoluteFilePath(), original.absoluteFilePath());
|
copyFile(patch.absoluteFilePath(), original.absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit textChanged(tr("Bloodmoon installation finished!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,7 +671,6 @@ bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outp
|
||||||
path.replace(QLatin1Char('\\'), QDir::separator());
|
path.replace(QLatin1Char('\\'), QDir::separator());
|
||||||
path = QDir::toNativeSeparators(path);
|
path = QDir::toNativeSeparators(path);
|
||||||
|
|
||||||
qDebug() << "path is: " << path << QString::fromLatin1(unshield_directory_name(unshield, directory)) + QLatin1Char('/');
|
|
||||||
// Ensure the target path exists
|
// Ensure the target path exists
|
||||||
QDir dir;
|
QDir dir;
|
||||||
dir.mkpath(path);
|
dir.mkpath(path);
|
||||||
|
@ -678,12 +679,12 @@ bool Wizard::UnshieldWorker::extractFile(Unshield *unshield, const QString &outp
|
||||||
fileName.append(QString::fromLatin1(unshield_file_name(unshield, index)));
|
fileName.append(QString::fromLatin1(unshield_file_name(unshield, index)));
|
||||||
|
|
||||||
// Calculate the percentage done
|
// Calculate the percentage done
|
||||||
int progress = qFloor(((float) counter / (float) unshield_file_count(unshield)) * 100);
|
int progress = (((float) counter / (float) unshield_file_count(unshield)) * 100);
|
||||||
|
|
||||||
if (mMorrowindDone)
|
if (getMorrowindDone())
|
||||||
progress = progress + 100;
|
progress = progress + 100;
|
||||||
|
|
||||||
if (mTribunalDone)
|
if (getTribunalDone())
|
||||||
progress = progress + 100;
|
progress = progress + 100;
|
||||||
|
|
||||||
qDebug() << progress << counter << unshield_file_count(unshield);
|
qDebug() << progress << counter << unshield_file_count(unshield);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QWaitCondition>
|
#include <QWaitCondition>
|
||||||
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
#include <libunshield.h>
|
#include <libunshield.h>
|
||||||
|
|
||||||
|
@ -39,17 +40,20 @@ namespace Wizard
|
||||||
void setPath(const QString &path);
|
void setPath(const QString &path);
|
||||||
void setIniPath(const QString &path);
|
void setIniPath(const QString &path);
|
||||||
|
|
||||||
|
QString getPath();
|
||||||
|
QString getIniPath();
|
||||||
|
|
||||||
void setIniCodec(QTextCodec *codec);
|
void setIniCodec(QTextCodec *codec);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// void setMorrowindDone(bool done);
|
void setMorrowindDone(bool done);
|
||||||
// void setTribunalDone(bool done);
|
void setTribunalDone(bool done);
|
||||||
// void setBloodmoonDone(bool done);
|
void setBloodmoonDone(bool done);
|
||||||
|
|
||||||
// bool getMorrowindDone();
|
bool getMorrowindDone();
|
||||||
// bool getTribunalDone();
|
bool getTribunalDone();
|
||||||
// bool getBloodmoonDone();
|
bool getBloodmoonDone();
|
||||||
|
|
||||||
bool removeDirectory(const QString &dirName);
|
bool removeDirectory(const QString &dirName);
|
||||||
|
|
||||||
|
@ -93,6 +97,8 @@ namespace Wizard
|
||||||
QWaitCondition mWait;
|
QWaitCondition mWait;
|
||||||
QMutex mMutex;
|
QMutex mMutex;
|
||||||
|
|
||||||
|
QReadWriteLock mLock;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void extract();
|
void extract();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue