mirror of https://github.com/ioquake/launch.git
Added install wizard. So far it only has the user select their q3a location on windows.
This commit is contained in:
parent
f0a58961d3
commit
dc4563dd6a
|
@ -0,0 +1,31 @@
|
|||
#include "installwizard.h"
|
||||
#include "ui_installwizard.h"
|
||||
#include "installwizard_locatepage.h"
|
||||
#include "settings.h"
|
||||
|
||||
InstallWizard::InstallWizard(QWidget *parent, Settings *settings) :
|
||||
QWizard(parent),
|
||||
ui(new Ui::InstallWizard),
|
||||
settings(settings)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
setPage(Page_Locate, new InstallWizard_LocatePage(this, settings));
|
||||
#endif
|
||||
}
|
||||
|
||||
InstallWizard::~InstallWizard()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void InstallWizard::on_InstallWizard_customButtonClicked(int which)
|
||||
{
|
||||
if (which == QWizard::FinishButton)
|
||||
{
|
||||
#ifdef Q_OS_WIN32
|
||||
settings->setQuakePath(field("quake3Path").toString());
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef INSTALLWIZARD_H
|
||||
#define INSTALLWIZARD_H
|
||||
|
||||
#include <QWizard>
|
||||
|
||||
namespace Ui {
|
||||
class InstallWizard;
|
||||
}
|
||||
|
||||
class Settings;
|
||||
|
||||
class InstallWizard : public QWizard
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InstallWizard(QWidget *parent, Settings *settings);
|
||||
~InstallWizard();
|
||||
|
||||
enum
|
||||
{
|
||||
Page_Locate
|
||||
};
|
||||
|
||||
private slots:
|
||||
void on_InstallWizard_customButtonClicked(int which);
|
||||
|
||||
private:
|
||||
Ui::InstallWizard *ui;
|
||||
Settings *settings;
|
||||
};
|
||||
|
||||
#endif // INSTALLWIZARD_H
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>InstallWizard</class>
|
||||
<widget class="QWizard" name="InstallWizard">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Quake 3: Arena Install Wizard</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="imgs.qrc">
|
||||
<normaloff>:/imgs/iolICO.png</normaloff>:/imgs/iolICO.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="imgs.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -0,0 +1,50 @@
|
|||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include "installwizard_locatepage.h"
|
||||
#include "ui_installwizard_locatepage.h"
|
||||
#include "settings.h"
|
||||
|
||||
InstallWizard_LocatePage::InstallWizard_LocatePage(QWidget *parent, Settings *settings) :
|
||||
QWizardPage(parent),
|
||||
ui(new Ui::InstallWizard_LocatePage),
|
||||
settings(settings)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
registerField("quake3Path*", ui->txtLocation);
|
||||
}
|
||||
|
||||
InstallWizard_LocatePage::~InstallWizard_LocatePage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void InstallWizard_LocatePage::initializePage()
|
||||
{
|
||||
ui->txtLocation->setText(settings->getQuakePath());
|
||||
}
|
||||
|
||||
void InstallWizard_LocatePage::on_btnBrowse_clicked()
|
||||
{
|
||||
const QString location = QFileDialog::getExistingDirectory(this, tr("Select Quake 3: 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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef INSTALLWIZARD_LOCATEPAGE_H
|
||||
#define INSTALLWIZARD_LOCATEPAGE_H
|
||||
|
||||
#include <QWizardPage>
|
||||
|
||||
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();
|
||||
|
||||
private:
|
||||
Ui::InstallWizard_LocatePage *ui;
|
||||
Settings *settings;
|
||||
};
|
||||
|
||||
#endif // INSTALLWIZARD_LOCATEPAGE_H
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>InstallWizard_LocatePage</class>
|
||||
<widget class="QWizardPage" name="InstallWizard_LocatePage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>WizardPage</string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Locate Quake 3: Arena</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="btnBrowse">
|
||||
<property name="text">
|
||||
<string>Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="txtLocation"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
12
launch.pro
12
launch.pro
|
@ -14,12 +14,18 @@ TEMPLATE = app
|
|||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
settings.cpp
|
||||
settings.cpp \
|
||||
installwizard.cpp \
|
||||
installwizard_locatepage.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
settings.h
|
||||
settings.h \
|
||||
installwizard.h \
|
||||
installwizard_locatepage.h
|
||||
|
||||
FORMS += mainwindow.ui
|
||||
FORMS += mainwindow.ui \
|
||||
installwizard.ui \
|
||||
installwizard_locatepage.ui
|
||||
|
||||
OTHER_FILES += \
|
||||
README.md \
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "installwizard.h"
|
||||
|
||||
ioLaunch::ioLaunch(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
|
@ -86,30 +87,13 @@ void ioLaunch::on_btnLaunch_clicked()
|
|||
QString ioq3;
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
// Prompt the user to set the ioq3 path if the settings value either doesn't exist or is invalid.
|
||||
bool promptForPath = true;
|
||||
|
||||
if (settings.containsQuakePath())
|
||||
if(!isQuake3PathValid())
|
||||
{
|
||||
const QString path = settings.getQuakePath();
|
||||
const QDir dir(path);
|
||||
InstallWizard wizard(this, &settings);
|
||||
wizard.exec();
|
||||
|
||||
if (!path.isEmpty() && dir.exists())
|
||||
promptForPath = false;
|
||||
}
|
||||
|
||||
if(promptForPath)
|
||||
{
|
||||
QMessageBox msg;
|
||||
msg.setText("Please select your Quake3 directory");
|
||||
msg.exec();
|
||||
|
||||
const QString path = QFileDialog::getExistingDirectory (this, tr("Directory"));
|
||||
|
||||
if (path.isEmpty())
|
||||
if(!isQuake3PathValid())
|
||||
return;
|
||||
|
||||
settings.setQuakePath(path);
|
||||
}
|
||||
|
||||
ioq3 = QString("\"") + settings.getQuakePath() + "/ioquake3.x86.exe\"";
|
||||
|
@ -218,6 +202,12 @@ void ioLaunch::on_sbHeight_valueChanged(int arg1)
|
|||
settings.setResolutionHeight(arg1);
|
||||
}
|
||||
|
||||
void ioLaunch::on_btnRunInstallWizard_clicked()
|
||||
{
|
||||
InstallWizard wizard(this, &settings);
|
||||
wizard.exec();
|
||||
}
|
||||
|
||||
// Since q3config.cfg is generated it's nice and clean and shouldn't need a full parser.
|
||||
static QString ParseToken(const QString &s, int &offset)
|
||||
{
|
||||
|
@ -258,6 +248,16 @@ static QString ParseToken(const QString &s, int &offset)
|
|||
return s.mid(start, end - start);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
bool ioLaunch::isQuake3PathValid() const
|
||||
{
|
||||
if (!settings.containsQuakePath())
|
||||
return false;
|
||||
|
||||
return !settings.getQuakePath().isEmpty() && QDir(settings.getQuakePath()).exists();
|
||||
}
|
||||
#endif
|
||||
|
||||
void ioLaunch::parseQuake3Config()
|
||||
{
|
||||
QFile file(homePath + "/baseq3/q3config.cfg");
|
||||
|
|
|
@ -35,7 +35,14 @@ private slots:
|
|||
|
||||
void on_sbHeight_valueChanged(int arg1);
|
||||
|
||||
void on_btnRunInstallWizard_clicked();
|
||||
|
||||
private:
|
||||
#ifdef Q_OS_WIN32
|
||||
// Returns false if the settings ioq3 path either doesn't exist or is invalid.
|
||||
bool isQuake3PathValid() const;
|
||||
#endif
|
||||
|
||||
void parseQuake3Config();
|
||||
|
||||
Ui::ioLaunch *ui;
|
||||
|
|
|
@ -339,6 +339,19 @@ QTabWidget::tab-bar{
|
|||
<string>H</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnRunInstallWizard">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>101</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Run Install Wizard</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabRend2">
|
||||
<attribute name="title">
|
||||
|
|
Loading…
Reference in New Issue