diff --git a/installwizard.cpp b/installwizard.cpp
index 2b61496..2c55605 100644
--- a/installwizard.cpp
+++ b/installwizard.cpp
@@ -2,10 +2,8 @@
#include "installwizard.h"
#include "ui_installwizard.h"
#include "installwizard_installtype.h"
-#include "installwizard_locate.h"
#include "installwizard_copy.h"
#include "installwizard_eula.h"
-#include "installwizard_install.h"
#include "installwizard_patch.h"
#include "installwizard_finished.h"
#include "settings.h"
@@ -26,17 +24,11 @@ InstallWizard::InstallWizard(QWidget *parent, Settings *settings) :
ui->setupUi(this);
connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
- setPage(Page_InstallType, new InstallWizard_InstallType(this));
-
-#ifdef Q_OS_WIN32
- setPage(Page_Locate, new InstallWizard_LocatePage(this, settings));
-#endif
-
- setPage(Page_Install, new InstallWizard_Install());
- setPage(Page_Eula, new InstallWizard_Eula());
- setPage(Page_Copy, new InstallWizard_Copy());
- setPage(Page_Patch, new InstallWizard_Patch());
- setPage(Page_Finished, new InstallWizard_Finished());
+ setPage(Page_InstallType, new InstallWizard_InstallType(this, settings));
+ setPage(Page_Eula, new InstallWizard_Eula(this));
+ setPage(Page_Copy, new InstallWizard_Copy(this));
+ setPage(Page_Patch, new InstallWizard_Patch(this));
+ setPage(Page_Finished, new InstallWizard_Finished(this));
}
InstallWizard::~InstallWizard()
diff --git a/installwizard.h b/installwizard.h
index 90b4d27..c4aa641 100644
--- a/installwizard.h
+++ b/installwizard.h
@@ -21,8 +21,6 @@ public:
enum
{
Page_InstallType,
- Page_Locate,
- Page_Install,
Page_Eula,
Page_Copy,
Page_Patch,
diff --git a/installwizard.ui b/installwizard.ui
index c744a8b..ffc8935 100644
--- a/installwizard.ui
+++ b/installwizard.ui
@@ -6,8 +6,8 @@
0
0
- 400
- 300
+ 640
+ 480
diff --git a/installwizard_copy.ui b/installwizard_copy.ui
index 1f2984f..90befed 100644
--- a/installwizard_copy.ui
+++ b/installwizard_copy.ui
@@ -6,8 +6,8 @@
0
0
- 400
- 300
+ 640
+ 480
diff --git a/installwizard_eula.ui b/installwizard_eula.ui
index dd04469..0e680bd 100644
--- a/installwizard_eula.ui
+++ b/installwizard_eula.ui
@@ -6,8 +6,8 @@
0
0
- 400
- 300
+ 640
+ 480
diff --git a/installwizard_finished.ui b/installwizard_finished.ui
index 1d033f3..0719960 100644
--- a/installwizard_finished.ui
+++ b/installwizard_finished.ui
@@ -6,8 +6,8 @@
0
0
- 400
- 300
+ 640
+ 480
diff --git a/installwizard_install.cpp b/installwizard_install.cpp
deleted file mode 100644
index ea29dcd..0000000
--- a/installwizard_install.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#include
-#include
-#include
-#include "installwizard_install.h"
-#include "ui_installwizard_install.h"
-#include "installwizard.h"
-
-InstallWizard_Install::InstallWizard_Install(QWidget *parent) :
- QWizardPage(parent),
- ui(new Ui::InstallWizard_Install)
-{
- ui->setupUi(this);
-}
-
-InstallWizard_Install::~InstallWizard_Install()
-{
- delete ui;
-}
-
-void InstallWizard_Install::initializePage()
-{
-#ifdef Q_OS_WIN32
- // Use the same default install directory as the Q3A installer.
- ui->txtDest->setText(QString(qgetenv("PROGRAMFILES").constData()) + QString("\\Quake III Arena"));
-#endif
-
- registerField("pak0*", ui->txtSource);
- registerField("quake3Path*", ui->txtDest);
-}
-
-bool InstallWizard_Install::validatePage()
-{
- if (!QFileInfo::exists(ui->txtSource->text()))
- {
- QMessageBox::warning(wizard(), "Missing source", QString("Source file '%1' does not exist.").arg(ui->txtSource->text()));
- return false;
- }
-
- return true;
-}
-
-bool InstallWizard_Install::isComplete() const
-{
- return !ui->txtSource->text().isEmpty() && !ui->txtDest->text().isEmpty();
-}
-
-int InstallWizard_Install::nextId() const
-{
- return InstallWizard::Page_Eula;
-}
-
-void InstallWizard_Install::on_btnBrowseSource_clicked()
-{
- const QString location = QFileDialog::getOpenFileName(wizard(), "Select pak0.pk3 location", QString(), "Quake III Arena Pak File (pak0.pk3)");
-
- if (!location.isEmpty())
- {
- ui->txtSource->setText(location);
- }
-}
-
-void InstallWizard_Install::on_btnBrowseDest_clicked()
-{
- const QString location = QFileDialog::getExistingDirectory(this, tr("Select Quake III Arena Location"), ui->txtDest->text());
-
- if (!location.isEmpty())
- {
- ui->txtDest->setText(location);
- }
-}
diff --git a/installwizard_install.h b/installwizard_install.h
deleted file mode 100644
index 5f7da40..0000000
--- a/installwizard_install.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef INSTALLWIZARD_INSTALL_H
-#define INSTALLWIZARD_INSTALL_H
-
-#include
-
-namespace Ui {
-class InstallWizard_Install;
-}
-
-class InstallWizard_Install : public QWizardPage
-{
- Q_OBJECT
-
-public:
- explicit InstallWizard_Install(QWidget *parent = 0);
- ~InstallWizard_Install();
- virtual void initializePage();
- virtual bool validatePage();
- virtual bool isComplete() const;
- virtual int nextId() const;
-
-private slots:
- void on_btnBrowseSource_clicked();
-
- void on_btnBrowseDest_clicked();
-
-private:
- Ui::InstallWizard_Install *ui;
-};
-
-#endif // INSTALLWIZARD_INSTALL_H
diff --git a/installwizard_install.ui b/installwizard_install.ui
deleted file mode 100644
index 4739e4e..0000000
--- a/installwizard_install.ui
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
- InstallWizard_Install
-
-
-
- 0
- 0
- 400
- 300
-
-
-
- WizardPage
-
-
- -
-
-
- Source (pak0.pk3):
-
-
-
- -
-
-
-
-
-
- -
-
-
- Browse...
-
-
-
-
-
- -
-
-
- Destination:
-
-
-
- -
-
-
-
-
-
- -
-
-
- Browse...
-
-
-
-
-
-
-
-
-
-
diff --git a/installwizard_installtype.cpp b/installwizard_installtype.cpp
index 7b4d40a..9736779 100644
--- a/installwizard_installtype.cpp
+++ b/installwizard_installtype.cpp
@@ -1,16 +1,24 @@
+#include
+#include
+#include
+#include
#include "installwizard_installtype.h"
#include "ui_installwizard_installtype.h"
#include "installwizard.h"
+#include "settings.h"
-InstallWizard_InstallType::InstallWizard_InstallType(QWidget *parent) :
+InstallWizard_InstallType::InstallWizard_InstallType(QWidget *parent, Settings *settings) :
QWizardPage(parent),
- ui(new Ui::InstallWizard_InstallType)
+ ui(new Ui::InstallWizard_InstallType),
+ settings(settings),
+ isQuake3PatchRequired(false)
{
ui->setupUi(this);
#ifndef Q_OS_WIN32
ui->rbLocate->setEnabled(false);
ui->rbInstall->setChecked(true);
+ ui->stackPages->setCurrentIndex(Page_Install);
#endif
}
@@ -19,16 +27,104 @@ InstallWizard_InstallType::~InstallWizard_InstallType()
delete ui;
}
-int InstallWizard_InstallType::nextId() const
+void InstallWizard_InstallType::initializePage()
{
- if (ui->rbInstall->isChecked())
+ ui->txtLocatePath->setText(settings->getQuakePath());
+
+#ifdef Q_OS_WIN32
+ // Use the same default install directory as the Q3A installer.
+ ui->txtInstallDest->setText(QString(qgetenv("PROGRAMFILES").constData()) + QString("\\Quake III Arena"));
+#endif
+
+ registerField("pak0", ui->txtInstallSource);
+}
+
+bool InstallWizard_InstallType::validatePage()
+{
+ if (ui->stackPages->currentIndex() == Page_Install)
{
- return InstallWizard::Page_Install;
+ if (!QFileInfo::exists(ui->txtInstallSource->text()))
+ {
+ QMessageBox::warning(wizard(), "Missing source", QString("Source file '%1' does not exist.").arg(ui->txtInstallSource->text()));
+ return false;
+ }
+
+ registerField("quake3Path", ui->txtInstallDest);
}
#ifdef Q_OS_WIN32
- else if (ui->rbLocate->isChecked())
+ else if (ui->stackPages->currentIndex() == Page_Locate)
{
- return InstallWizard::Page_Locate;
+ if (ui->txtLocatePath->text().isEmpty())
+ return false;
+
+ QDir dir(ui->txtLocatePath->text());
+
+ if (!dir.exists())
+ {
+ QMessageBox::warning(this, "Invalid location", "The selected location doesn't exist. Please select a valid directory.");
+ return false;
+ }
+
+ // Check if the Quake 3 installation needs patching.
+ const QString pakFilename(ui->txtLocatePath->text() + "/baseq3/pak1.pk3");
+ QFile file(pakFilename);
+
+ if (!file.exists())
+ {
+ // pak1.pk3 doesn't exist, must be a fresh install.
+ isQuake3PatchRequired = true;
+ registerField("quake3Path", ui->txtLocatePath);
+ return true;
+ }
+
+ if (!file.open(QIODevice::ReadOnly))
+ {
+ QMessageBox::warning(this, "Missing file", QString("Unable to open file '%1'").arg(pakFilename));
+ return false;
+ }
+
+ const QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Md5).toHex();
+ isQuake3PatchRequired = (hash != "48911719d91be25adb957f2d325db4a0");
+ registerField("quake3Path", ui->txtLocatePath);
+ }
+#endif
+
+ return true;
+}
+
+bool InstallWizard_InstallType::isComplete() const
+{
+ if (ui->stackPages->currentIndex() == Page_Install)
+ {
+ return !ui->txtInstallSource->text().isEmpty() && !ui->txtInstallDest->text().isEmpty();
+ }
+#ifdef Q_OS_WIN32
+ else if (ui->stackPages->currentIndex() == Page_Locate)
+ {
+ return !ui->txtLocatePath->text().isEmpty();
+ }
+#endif
+
+ return true;
+}
+
+int InstallWizard_InstallType::nextId() const
+{
+ if (ui->stackPages->currentIndex() == Page_Install)
+ {
+ return InstallWizard::Page_Eula;
+ }
+#ifdef Q_OS_WIN32
+ else if (ui->stackPages->currentIndex() == Page_Locate)
+ {
+ if (isQuake3PatchRequired)
+ {
+ return InstallWizard::Page_Eula;
+ }
+ else
+ {
+ return InstallWizard::Page_Finished;
+ }
}
#endif
@@ -36,3 +132,59 @@ int InstallWizard_InstallType::nextId() const
Q_ASSERT(false);
return InstallWizard::Page_Finished;
}
+
+void InstallWizard_InstallType::on_rbLocate_clicked()
+{
+ ui->stackPages->setCurrentIndex(Page_Locate);
+}
+
+void InstallWizard_InstallType::on_rbInstall_clicked()
+{
+ ui->stackPages->setCurrentIndex(Page_Install);
+}
+
+void InstallWizard_InstallType::on_btnLocateBrowse_clicked()
+{
+ const QString location = QFileDialog::getExistingDirectory(this, tr("Select Quake III Arena Location"), settings->getQuakePath());
+
+ if (!location.isEmpty())
+ {
+ ui->txtLocatePath->setText(location);
+ emit completeChanged();
+ }
+}
+
+void InstallWizard_InstallType::on_txtLocatePath_textChanged(const QString & /*arg1*/)
+{
+ emit completeChanged();
+}
+
+void InstallWizard_InstallType::on_btnInstallBrowseSource_clicked()
+{
+ const QString location = QFileDialog::getOpenFileName(wizard(), "Select pak0.pk3 location", QString(), "Quake III Arena Pak File (pak0.pk3)");
+
+ if (!location.isEmpty())
+ {
+ ui->txtInstallSource->setText(location);
+ }
+}
+
+void InstallWizard_InstallType::on_btnInstallBrowseDest_clicked()
+{
+ const QString location = QFileDialog::getExistingDirectory(this, tr("Select Quake III Arena Location"), ui->txtInstallDest->text());
+
+ if (!location.isEmpty())
+ {
+ ui->txtInstallDest->setText(location);
+ }
+}
+
+void InstallWizard_InstallType::on_txtInstallSource_textChanged(const QString & /*arg1*/)
+{
+ emit completeChanged();
+}
+
+void InstallWizard_InstallType::on_txtInstallDest_textChanged(const QString & /*arg1*/)
+{
+ emit completeChanged();
+}
diff --git a/installwizard_installtype.h b/installwizard_installtype.h
index 3502012..29e7943 100644
--- a/installwizard_installtype.h
+++ b/installwizard_installtype.h
@@ -7,17 +7,48 @@ namespace Ui {
class InstallWizard_InstallType;
}
+class Settings;
+
class InstallWizard_InstallType : public QWizardPage
{
Q_OBJECT
public:
- explicit InstallWizard_InstallType(QWidget *parent = 0);
+ explicit InstallWizard_InstallType(QWidget *parent, Settings *settings);
~InstallWizard_InstallType();
+ virtual void initializePage();
+ virtual bool validatePage();
+ virtual bool isComplete() const;
virtual int nextId() const;
+private slots:
+ void on_rbLocate_clicked();
+
+ void on_rbInstall_clicked();
+
+ void on_btnLocateBrowse_clicked();
+
+ void on_txtLocatePath_textChanged(const QString &arg1);
+
+ void on_btnInstallBrowseSource_clicked();
+
+ void on_btnInstallBrowseDest_clicked();
+
+ void on_txtInstallSource_textChanged(const QString &arg1);
+
+ void on_txtInstallDest_textChanged(const QString &arg1);
+
private:
+ enum
+ {
+ Page_Locate,
+ Page_Install
+ };
+
Ui::InstallWizard_InstallType *ui;
+
+ Settings *settings;
+ bool isQuake3PatchRequired;
};
#endif // INSTALLWIZARD_INSTALLTYPE_H
diff --git a/installwizard_installtype.ui b/installwizard_installtype.ui
index 6bf0bb1..ddadfec 100644
--- a/installwizard_installtype.ui
+++ b/installwizard_installtype.ui
@@ -6,8 +6,8 @@
0
0
- 400
- 300
+ 640
+ 480
@@ -16,22 +16,131 @@
Select the installation type
-
+
-
-
-
- Locate an existing Quake III Arena installation
-
-
- true
+
+
-
+
+
+ Locate Quake III Arena
+
+
+ true
+
+
+
+ -
+
+
+ Install from CD or Steam
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
-
-
-
- Install from CD or Steam
-
+
+
+
+
-
+
+
-
+
+
+ -
+
+
+ Browse...
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ -
+
+
-
+
+
+ Source (pak0.pk3):
+
+
+
+ -
+
+
-
+
+
+ -
+
+
+ Browse...
+
+
+
+
+
+ -
+
+
+ Destination:
+
+
+
+ -
+
+
-
+
+
+ -
+
+
+ Browse...
+
+
+
+
+
+
+
+
+
diff --git a/installwizard_locate.cpp b/installwizard_locate.cpp
deleted file mode 100644
index 1f7cae9..0000000
--- a/installwizard_locate.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-#include
-#include
-#include
-#include "installwizard_locate.h"
-#include "ui_installwizard_locate.h"
-#include "installwizard.h"
-#include "settings.h"
-
-InstallWizard_LocatePage::InstallWizard_LocatePage(QWidget *parent, Settings *settings) :
- QWizardPage(parent),
- ui(new Ui::InstallWizard_LocatePage),
- settings(settings),
- isQuake3PatchRequired(false)
-{
- ui->setupUi(this);
-}
-
-InstallWizard_LocatePage::~InstallWizard_LocatePage()
-{
- delete ui;
-}
-
-void InstallWizard_LocatePage::initializePage()
-{
- registerField("quake3Path*", ui->txtLocation);
- ui->txtLocation->setText(settings->getQuakePath());
-}
-
-void InstallWizard_LocatePage::on_btnBrowse_clicked()
-{
- const QString location = QFileDialog::getExistingDirectory(this, tr("Select Quake III Arena Location"), settings->getQuakePath());
-
- if (!location.isEmpty())
- {
- ui->txtLocation->setText(location);
- }
-}
-
-bool InstallWizard_LocatePage::validatePage()
-{
- if (ui->txtLocation->text().isEmpty())
- return false;
-
- QDir dir(ui->txtLocation->text());
-
- if (!dir.exists())
- {
- QMessageBox::warning(this, "Invalid location", "The selected location doesn't exist. Please select a valid directory.");
- return false;
- }
-
- // Check if the Quake 3 installation needs patching.
- const QString pakFilename(ui->txtLocation->text() + "/baseq3/pak1.pk3");
- QFile file(pakFilename);
-
- if (!file.exists())
- {
- // pak1.pk3 doesn't exist, must be a fresh install.
- isQuake3PatchRequired = true;
- return true;
- }
-
- if (!file.open(QIODevice::ReadOnly))
- {
- QMessageBox::warning(this, "Missing file", QString("Unable to open file '%1'").arg(pakFilename));
- return false;
- }
-
- const QByteArray hash = QCryptographicHash::hash(file.readAll(), QCryptographicHash::Md5).toHex();
- isQuake3PatchRequired = (hash != "48911719d91be25adb957f2d325db4a0");
-
- return true;
-}
-
-int InstallWizard_LocatePage::nextId() const
-{
- if (isQuake3PatchRequired)
- {
- return InstallWizard::Page_Eula;
- }
- else
- {
- return InstallWizard::Page_Finished;
- }
-}
diff --git a/installwizard_locate.h b/installwizard_locate.h
deleted file mode 100644
index c673354..0000000
--- a/installwizard_locate.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef INSTALLWIZARD_LOCATEPAGE_H
-#define INSTALLWIZARD_LOCATEPAGE_H
-
-#include
-
-namespace Ui {
-class InstallWizard_LocatePage;
-}
-
-class Settings;
-
-class InstallWizard_LocatePage : public QWizardPage
-{
- Q_OBJECT
-
-public:
- explicit InstallWizard_LocatePage(QWidget *parent, Settings *settings);
- ~InstallWizard_LocatePage();
- virtual void initializePage();
-
-private slots:
- void on_btnBrowse_clicked();
-
-protected:
- virtual bool validatePage();
- virtual int nextId() const;
-
-private:
- Ui::InstallWizard_LocatePage *ui;
- Settings *settings;
- bool isQuake3PatchRequired;
-};
-
-#endif // INSTALLWIZARD_LOCATEPAGE_H
diff --git a/installwizard_locate.ui b/installwizard_locate.ui
deleted file mode 100644
index 26e0f4d..0000000
--- a/installwizard_locate.ui
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
- InstallWizard_LocatePage
-
-
-
- 0
- 0
- 400
- 300
-
-
-
- WizardPage
-
-
- Locate Quake III Arena
-
-
- -
-
-
- Browse...
-
-
-
- -
-
-
-
-
-
-
-
diff --git a/installwizard_patch.ui b/installwizard_patch.ui
index 710cb6d..75f20f6 100644
--- a/installwizard_patch.ui
+++ b/installwizard_patch.ui
@@ -6,8 +6,8 @@
0
0
- 400
- 300
+ 640
+ 480
diff --git a/launch.pro b/launch.pro
index a3c5c0a..59fdbaf 100644
--- a/launch.pro
+++ b/launch.pro
@@ -16,33 +16,27 @@ SOURCES += main.cpp\
mainwindow.cpp \
settings.cpp \
installwizard.cpp \
- installwizard_locate.cpp \
installwizard_installtype.cpp \
installwizard_finished.cpp \
installwizard_patch.cpp \
installwizard_eula.cpp \
- installwizard_install.cpp \
installwizard_copy.cpp
HEADERS += mainwindow.h \
settings.h \
installwizard.h \
- installwizard_locate.h \
installwizard_installtype.h \
installwizard_finished.h \
installwizard_patch.h \
installwizard_eula.h \
- installwizard_install.h \
installwizard_copy.h
FORMS += mainwindow.ui \
installwizard.ui \
- installwizard_locate.ui \
installwizard_installtype.ui \
installwizard_finished.ui \
installwizard_patch.ui \
installwizard_eula.ui \
- installwizard_install.ui \
installwizard_copy.ui
OTHER_FILES += \