Store the wizard Q3A path in InstallWizard instead of a field.

This commit is contained in:
Jonathan Young 2014-05-15 17:21:13 +10:00
parent 8e5e041322
commit c09b876566
5 changed files with 27 additions and 11 deletions

View file

@ -60,6 +60,16 @@ void InstallWizard::setIsQuake3PatchRequired(bool value)
isQuake3PatchRequired = value;
}
QString InstallWizard::getQuakePath() const
{
return quakePath;
}
void InstallWizard::setQuakePath(const QString &path)
{
quakePath = path;
}
void InstallWizard::cancel()
{
if (currentId() == Page_Copy)
@ -79,7 +89,7 @@ void InstallWizard::on_InstallWizard_finished(int result)
#ifdef Q_OS_WIN32
if (result == QDialog::Accepted)
{
settings->setQuakePath(field("quake3Path").toString());
settings->setQuakePath(quakePath);
}
#else
result = result; // Silence warning.

View file

@ -30,6 +30,9 @@ public:
bool getIsQuake3PatchRequired() const;
void setIsQuake3PatchRequired(bool value);
QString getQuakePath() const;
void setQuakePath(const QString &path);
enum
{
Page_Setup,
@ -49,6 +52,7 @@ private:
Settings *settings;
QList<CopyFile> copyFiles;
bool isQuake3PatchRequired;
QString quakePath;
};
#endif // INSTALLWIZARD_H

View file

@ -79,7 +79,7 @@ void InstallWizard_Copy::initializePage()
isCopyFinished = false;
// Try to create the destination directory and baseq3 subdirectory.
const QString quake3Path(field("quake3Path").toString() + QString("/baseq3"));
const QString quake3Path(((InstallWizard *)wizard())->getQuakePath() + QString("/baseq3"));
QDir dir;
if (!dir.mkpath(quake3Path))

View file

@ -224,7 +224,7 @@ void InstallWizard_Patch::downloadFinished()
if (strncmp(header.name, pakPrefix, strlen(pakPrefix)) == 0)
{
QString filename(field("quake3Path").toString());
QString filename(((InstallWizard *)wizard())->getQuakePath());
filename.append('/');
filename.append(header.name);

View file

@ -56,6 +56,8 @@ void InstallWizard_Setup::initializePage()
bool InstallWizard_Setup::validatePage()
{
InstallWizard *iw = (InstallWizard *)wizard();
if (ui->stackPages->currentIndex() == Page_Install)
{
QDir dir(ui->cbInstallSource->currentText());
@ -67,11 +69,11 @@ bool InstallWizard_Setup::validatePage()
}
// CD doesn't contain latest patch.
((InstallWizard *)wizard())->setIsQuake3PatchRequired(true);
iw->setIsQuake3PatchRequired(true);
// Copy page will copy baseq3/pak0.pk3.
((InstallWizard *)wizard())->addCopyFile(ui->cbInstallSource->currentText() + QString("/QUAKE3/baseq3/pak0.pk3"), ui->txtInstallDest->text() + QString("/baseq3/pak0.pk3"));
registerField("quake3Path", ui->txtInstallDest);
iw->addCopyFile(ui->cbInstallSource->currentText() + QString("/QUAKE3/baseq3/pak0.pk3"), ui->txtInstallDest->text() + QString("/baseq3/pak0.pk3"));
iw->setQuakePath(ui->txtInstallDest->text());
}
else if (ui->stackPages->currentIndex() == Page_InstallSteam)
{
@ -98,10 +100,10 @@ bool InstallWizard_Setup::validatePage()
for (int i = 0; i < pakFiles.size(); i++)
{
((InstallWizard *)wizard())->addCopyFile(pakFiles.at(i).absoluteFilePath(), ui->txtInstallSteamDest->text() + QString("/baseq3/") + pakFiles.at(i).fileName());
iw->addCopyFile(pakFiles.at(i).absoluteFilePath(), ui->txtInstallSteamDest->text() + QString("/baseq3/") + pakFiles.at(i).fileName());
}
registerField("quake3Path", ui->txtInstallSteamDest);
iw->setQuakePath(ui->txtInstallSteamDest->text());
}
#ifdef Q_OS_WIN32
else if (ui->stackPages->currentIndex() == Page_Locate)
@ -125,7 +127,7 @@ bool InstallWizard_Setup::validatePage()
{
// pak1.pk3 doesn't exist, must be a fresh install.
((InstallWizard *)wizard())->setIsQuake3PatchRequired(true);
registerField("quake3Path", ui->txtLocatePath);
iw->setQuakePath(ui->txtLocatePath->text());
return true;
}
@ -136,8 +138,8 @@ bool InstallWizard_Setup::validatePage()
}
const QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Md5).toHex();
((InstallWizard *)wizard())->setIsQuake3PatchRequired(hash != "48911719d91be25adb957f2d325db4a0");
registerField("quake3Path", ui->txtLocatePath);
iw->setIsQuake3PatchRequired(hash != "48911719d91be25adb957f2d325db4a0");
iw->setQuakePath(ui->txtLocatePath->text());
}
#endif