Split the project into two executables (the launcher and the configurator)

Sat, 06 Jun 2015 23:02:51 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 06 Jun 2015 23:02:51 +0300
changeset 44
d0bf58f3560f
parent 43
1394901b557a
child 45
f5b526a3423a

Split the project into two executables (the launcher and the configurator)

.hgignore file | annotate | diff | comparison | revisions
CMakeLists.txt file | annotate | diff | comparison | revisions
src-common/config.cpp file | annotate | diff | comparison | revisions
src-common/config.h file | annotate | diff | comparison | revisions
src-common/misc.cpp file | annotate | diff | comparison | revisions
src-common/misc.h file | annotate | diff | comparison | revisions
src-common/types.h file | annotate | diff | comparison | revisions
src-common/version.cpp file | annotate | diff | comparison | revisions
src-common/version.h file | annotate | diff | comparison | revisions
src-config/addversionprompt.cpp file | annotate | diff | comparison | revisions
src-config/addversionprompt.h file | annotate | diff | comparison | revisions
src-config/configwindow.cpp file | annotate | diff | comparison | revisions
src-config/configwindow.h file | annotate | diff | comparison | revisions
src-config/main.cpp file | annotate | diff | comparison | revisions
src/config.cpp file | annotate | diff | comparison | revisions
src/config.h file | annotate | diff | comparison | revisions
src/configwindow.cpp file | annotate | diff | comparison | revisions
src/configwindow.h file | annotate | diff | comparison | revisions
src/main.cpp file | annotate | diff | comparison | revisions
src/main.h file | annotate | diff | comparison | revisions
src/misc.cpp file | annotate | diff | comparison | revisions
src/misc.h file | annotate | diff | comparison | revisions
src/prompts.cpp file | annotate | diff | comparison | revisions
src/prompts.h file | annotate | diff | comparison | revisions
src/types.h file | annotate | diff | comparison | revisions
--- a/.hgignore	Sat Jun 06 22:28:34 2015 +0300
+++ b/.hgignore	Sat Jun 06 23:02:51 2015 +0300
@@ -6,3 +6,5 @@
 *~
 .kdev4
 *.kdev4
+.*.kate-swp
+.kdev_include_paths
\ No newline at end of file
--- a/CMakeLists.txt	Sat Jun 06 22:28:34 2015 +0300
+++ b/CMakeLists.txt	Sat Jun 06 23:02:51 2015 +0300
@@ -14,22 +14,32 @@
 include_directories (${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
 
 set (ZCINEMA_SOURCES
-	src/config.cpp
-	src/configwindow.cpp
 	src/demo.cpp
 	src/main.cpp
-	src/misc.cpp
 	src/prompts.cpp
 )
 
+set (ZCINEMA_COMMON_SOURCES
+	src-common/config.cpp
+	src-common/misc.cpp
+	src-common/version.cpp
+)
+
+set (ZCINEMA_CONFIG_SOURCES
+	src-config/configwindow.cpp
+	src-config/addversionprompt.cpp
+	src-config/main.cpp
+)
+
 set (ZCINEMA_HEADERS
-	src/config.h
-	src/configwindow.h
+	src-common/config.h
+	src-common/misc.h
+	src-common/types.h
+	src-common/version.h
+	src-config/addversionprompt.h
+	src-config/configwindow.h
 	src/demo.h
-	src/main.h
-	src/misc.h
 	src/prompts.h
-	src/types.h
 )
 
 set (ZCINEMA_FORMS
@@ -48,41 +58,54 @@
 endif()
 
 include_directories ("${PROJECT_BINARY_DIR}")
+include_directories ("${PROJECT_SOURCE_DIR}/src")
 include_directories ("${PROJECT_BINARY_DIR}/src")
+include_directories ("${PROJECT_SOURCE_DIR}/src-common")
+include_directories ("${PROJECT_BINARY_DIR}/src-common")
+include_directories ("${PROJECT_SOURCE_DIR}/src-config")
+include_directories ("${PROJECT_BINARY_DIR}/src-config")
 
 if (USE_QT5)
 	qt5_generate_moc (ZCINEMA_MOC ${ZCINEMA_HEADERS})
 	qt5_add_resources (ZCINEMA_QRC ${ZCINEMA_RESOURCES})
 	qt5_wrap_ui (ZCINEMA_FORMS_HEADERS ${ZCINEMA_FORMS})
-	add_executable (${PROJECT_NAME} WIN32 ${ZCINEMA_SOURCES} ${ZCINEMA_HEADERS} ${ZCINEMA_MOC}
-		${ZCINEMA_QRC} ${ZCINEMA_FORMS_HEADERS})
+
+	add_library (${PROJECT_NAME}-common STATIC
+		${ZCINEMA_COMMON_SOURCES}
+		${ZCINEMA_MOC}
+		${ZCINEMA_QRC}
+		${ZCINEMA_FORMS_HEADERS})
 else()
 	qt4_wrap_cpp (ZCINEMA_MOC ${ZCINEMA_HEADERS})
 	qt4_wrap_ui (ZCINEMA_FORMS_HEADERS ${ZCINEMA_FORMS})
 	qt4_add_resources (ZCINEMA_RCC ${ZCINEMA_RESOURCES})
-	add_executable (${PROJECT_NAME} WIN32 ${ZCINEMA_SOURCES} ${ZCINEMA_HEADERS} ${ZCINEMA_RCC}
-		${ZCINEMA_FORMS_HEADERS} ${ZCINEMA_MOC})
+
+	add_library (${PROJECT_NAME}-common STATIC
+		${ZCINEMA_COMMON_SOURCES}
+		${ZCINEMA_MOC}
+		${ZCINEMA_RCC}
+		${ZCINEMA_FORMS_HEADERS})
 endif()
 
+add_executable (${PROJECT_NAME} WIN32 ${ZCINEMA_SOURCES})
+add_executable (${PROJECT_NAME}-config WIN32 ${ZCINEMA_CONFIG_SOURCES})
+
 if (USE_QT5)
-	target_link_libraries (${PROJECT_NAME} Qt5::Widgets Qt5::Network Qt5::OpenGL ${OPENGL_LIBRARIES})
+	target_link_libraries (${PROJECT_NAME}-common Qt5::Widgets)
 else()
-	target_link_libraries (${PROJECT_NAME}
-		${QT_QTCORE_LIBRARY}
-		${QT_QTGUI_LIBRARY}
-		${QT_QTNETWORK_LIBRARY}
-		${QT_QTOPENGL_LIBRARY}
-		${OPENGL_LIBRARIES}
-	)
+	target_link_libraries (${PROJECT_NAME}-common ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
 endif()
 
+target_link_libraries (${PROJECT_NAME} ${PROJECT_NAME}-common)
+target_link_libraries (${PROJECT_NAME}-config ${PROJECT_NAME}-common)
+
 add_custom_target (make_hginfo
 	COMMAND python
 		"${CMAKE_SOURCE_DIR}/updaterevision.py"
 		"${CMAKE_CURRENT_BINARY_DIR}/hginfo.h"
 	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
 
-add_dependencies (${PROJECT_NAME} make_hginfo)
+add_dependencies (${PROJECT_NAME}-common make_hginfo)
 
 # With clang, we need to set -Wno-deprecated since Qt headers seem to use the register keyword
 # which clang doesn't seem to like.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-common/config.cpp	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,100 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <assert.h>
+#include <QDir>
+#include <QTextStream>
+#include <QSettings>
+#include "config.h"
+
+typedef QMap<QString, QVariant> DefaultsMap;
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+static QSettings* getSettingsObject()
+{
+	return new QSettings;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+static DefaultsMap& getDefaults()
+{
+	static DefaultsMap defaults;
+
+	if (defaults.isEmpty())
+	{
+		// Initialize defaults here.
+	}
+
+	return defaults;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void Config::reset()
+{
+	DefaultsMap& defaults = getDefaults();
+
+	for (DefaultsMap::iterator it = defaults.begin(); it != defaults.end(); ++it)
+		set (it.key(), it.value());
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+QVariant Config::get (const QString& name)
+{
+	QSettings* settings = getSettingsObject();
+	DefaultsMap& defaults = getDefaults();
+	DefaultsMap::iterator it = defaults.find (name);
+	QVariant def = it != defaults.end() ? *it : QVariant();
+	QVariant value = settings->value (name, def);
+	settings->deleteLater();
+	return value;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+bool Config::set (const QString& name, const QVariant& value)
+{
+	QSettings* settings = getSettingsObject();
+	settings->setValue (name, value);
+	settings->deleteLater();
+	return settings->status() == QSettings::NoError;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void Config::sync()
+{
+	QSettings* settings = getSettingsObject();
+	settings->sync();
+	settings->deleteLater();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-common/config.h	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,28 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+#include <QVariant>
+
+namespace Config
+{
+	void reset();
+	QVariant get (const QString& name);
+	bool set (const QString& name, const QVariant& value);
+	void sync();
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-common/misc.cpp	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,61 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <QFileDialog>
+#include "misc.h"
+#include "config.h"
+
+//
+// -----------------------------------------------------------------------------
+//
+
+void commonInit()
+{
+	qRegisterMetaType<ZandronumVersion> ("ZandronumVersion");
+	qRegisterMetaTypeStreamOperators<ZandronumVersion> ("ZandronumVersion");
+}
+
+//
+// -----------------------------------------------------------------------------
+//
+
+QString basename (const QString& path)
+{
+	int lastpos = path.lastIndexOf ("/");
+
+	if (lastpos != -1)
+		return path.mid (lastpos + 1);
+
+	return path;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+QString getBinaryPath (QWidget* parent)
+{
+#ifdef _WIN32
+# define ZAN_EXE_NAME "zandronum.exe"
+#else
+# define ZAN_EXE_NAME "zandronum"
+#endif
+
+	return QFileDialog::getOpenFileName (parent, "", "",
+		"Zandronum Binaries (" ZAN_EXE_NAME ")(" ZAN_EXE_NAME ");;All files (*)(*)");
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-common/misc.h	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,70 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+#include "types.h"
+
+inline quint32 makeByteID (quint8 a, quint8 b, quint8 c, quint8 d)
+{
+	return a | (b << 8) | (c << 16) | (d << 24);
+}
+
+void commonInit();
+QString basename (const QString& path);
+bool confirm (const QString& text);
+QString getBinaryPath (QWidget* parent);
+
+//
+// -----------------------------------------------------------------------------
+//
+
+template<typename T>
+T clamp (T a, T min, T max)
+{
+	return (a > max) ? max : (a < min) ? min : a;
+}
+
+//
+// -----------------------------------------------------------------------------
+//
+
+template<typename T>
+T min (T a, T b)
+{
+	return (a < b) ? a : b;
+}
+
+//
+// -----------------------------------------------------------------------------
+//
+
+template<typename T>
+T max (T a, T b)
+{
+	return (a > b) ? a : b;
+}
+
+//
+// -----------------------------------------------------------------------------
+//
+
+template<typename T>
+T abs (T a)
+{
+	return (a < 0) ? -a : a;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-common/types.h	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,62 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+#include <QString>
+#include <QList>
+#include <QVariant>
+
+template<class T> using list = QList<T>;
+template<class T> using initlist = std::initializer_list<T>;
+using std::size_t;
+
+typedef qint8 int8;
+typedef qint16 int16;
+typedef qint32 int32;
+typedef qint64 int64;
+typedef quint8 uint8;
+typedef quint16 uint16;
+typedef quint32 uint32;
+typedef quint64 uint64;
+
+struct ZandronumVersion
+{
+	ZandronumVersion (QString name, bool isRelease, QString binaryPath) :
+		name (name),
+		binaryPath (binaryPath),
+		isRelease (isRelease) {}
+
+	ZandronumVersion() :
+		isRelease (false) {}
+
+	QString name;
+	QString binaryPath;
+	bool isRelease;
+};
+
+inline QDataStream& operator<< (QDataStream& out, const ZandronumVersion& version)
+{
+	return (out << version.name << version.binaryPath << version.isRelease);
+}
+
+inline QDataStream& operator>> (QDataStream& in, ZandronumVersion& version)
+{
+	return (in >> version.name >> version.binaryPath >> version.isRelease);
+}
+
+Q_DECLARE_METATYPE (ZandronumVersion)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-common/version.cpp	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,55 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "version.h"
+#include "hginfo.h"
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+QString versionString()
+{
+#ifndef RELEASE
+# ifdef HG_NODE
+	// non-release with hg info
+	return VERSION_STRING "-" HG_NODE;
+# else
+	// non-release, no hg info
+	return VERSION_STRING "-beta";
+# endif
+#else
+	// release
+	return VERSION_STRING;
+#endif
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+QString versionSignature()
+{
+#ifdef HG_DATE_STRING
+# define DATE_INFO " (" HG_DATE_STRING ")"
+#else
+# define DATE_INFO ""
+#endif
+
+	return QString (APPNAME) + " " + versionString() + DATE_INFO;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-common/version.h	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,42 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+#define APPNAME "ZCinema"
+#define UNIXNAME "zcinema"
+#define VERSION_MAJOR 1
+#define VERSION_MINOR 0
+#define VERSION_PATCH 0
+// #define RELEASE
+
+#define MACRO_TO_STRING(A) MACRO_TO_STRING_(A)
+#define MACRO_TO_STRING_(A) #A
+
+#if VERSION_PATCH == 0
+# define VERSION_STRING MACRO_TO_STRING (VERSION_MAJOR) \
+                    "." MACRO_TO_STRING (VERSION_MINOR)
+#else
+# define VERSION_STRING MACRO_TO_STRING (VERSION_MAJOR) \
+                    "." MACRO_TO_STRING (VERSION_MINOR) \
+                    "." MACRO_TO_STRING (VERSION_PATCH)
+#endif
+
+#include "config.h"
+
+QString versionString();
+QString versionSignature();
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-config/addversionprompt.cpp	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,85 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <QTableWidget>
+#include "addversionprompt.h"
+#include "configwindow.h"
+#include "misc.h"
+#include "ui_addversion.h"
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+AddVersionPrompt::AddVersionPrompt (VersionGuiEntry* entry, QWidget* parent, Qt::WindowFlags f)
+	: QDialog (parent, f),
+	ui (*new Ui_AddVersion),
+	m_entry (entry)
+{
+	ui.setupUi (this);
+	connect (ui.buttonBox, SIGNAL (accepted()), this, SLOT (acceptPressed()));
+	connect (ui.buttonBox, SIGNAL (rejected()), this, SLOT (reject()));
+	connect (ui.findExeButton, SIGNAL (clicked()), this, SLOT (findExePath()));
+
+	ui.nameField->setText (entry->name);
+	ui.exePathField->setText (entry->pathItem->text());
+	ui.releaseCheckbox->setChecked (entry->isRelease);
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void AddVersionPrompt::acceptPressed()
+{
+	m_entry->name = ui.nameField->text();
+	m_entry->isRelease = ui.releaseCheckbox->isChecked();
+	m_entry->labelItem->setText (m_entry->name);
+	m_entry->pathItem->setText (ui.exePathField->text());
+	accept();
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+AddVersionPrompt::~AddVersionPrompt()
+{
+	delete &ui;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void AddVersionPrompt::findExePath()
+{
+	QString path = getBinaryPath (this);
+
+	if (not path.isEmpty())
+		ui.exePathField->setText (path);
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+VersionGuiEntry* AddVersionPrompt::getVersionInfo()
+{
+	return m_entry;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-config/addversionprompt.h	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,23 @@
+#include <QDialog>
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+class AddVersionPrompt : public QDialog
+{
+	Q_OBJECT
+
+public:
+	AddVersionPrompt (struct VersionGuiEntry* entry, QWidget* parent = NULL, Qt::WindowFlags f = 0);
+	virtual ~AddVersionPrompt();
+	VersionGuiEntry* getVersionInfo();
+
+private slots:
+	void acceptPressed();
+	void findExePath();
+
+private:
+	class Ui_AddVersion& ui;
+	struct VersionGuiEntry* m_entry;
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-config/configwindow.cpp	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,303 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <QFileDialog>
+#include <QMessageBox>
+#include "addversionprompt.h"
+#include "config.h"
+#include "configwindow.h"
+#include "version.h"
+#include "ui_configbox.h"
+
+//
+// -----------------------------------------------------------------------------
+//
+
+bool confirm (const QString& text)
+{
+	return QMessageBox::question (NULL, QObject::tr ("Confirm"), text,
+		QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::No;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+ConfigWindow::ConfigWindow (QWidget* parent, Qt::WindowFlags f) :
+	QDialog (parent, f),
+	ui (*new Ui_ConfigBox)
+{
+	ui.setupUi (this);
+
+	QStringList wadpaths = Config::get ("wadpaths").toStringList();
+	QList<QVariant> versions = Config::get ("versions").toList();
+
+	for (int i = 0; i < wadpaths.size(); ++i)
+		addWadPath (wadpaths[i]);
+
+	ui.noDemoPrompt->setChecked (Config::get ("noprompt").toBool());
+
+	for (int i = 0; i < versions.size(); ++i)
+	{
+		if (not versions[i].canConvert<ZandronumVersion>())
+			continue;
+
+		addVersion (versions[i].value<ZandronumVersion>());
+	}
+
+	connect (ui.wad_add, SIGNAL (clicked()), this, SLOT (addWadPath()));
+	connect (ui.wad_pathEntry, SIGNAL (returnPressed()), this, SLOT (addWadPath()));
+	connect (ui.wad_findPath, SIGNAL (clicked()), this, SLOT (findWadPath()));
+	connect (ui.wad_del, SIGNAL (clicked()), this, SLOT (removeCurrentWadPath()));
+	connect (ui.buttonBox, SIGNAL (clicked (QAbstractButton*)), this,
+		SLOT (buttonPressed (QAbstractButton*)));
+	connect (ui.addExePath, SIGNAL (clicked()), this, SLOT (newVersion()));
+	connect (ui.editExePath, SIGNAL (clicked()), this, SLOT (editExePressed()));
+	connect (ui.removeExePath, SIGNAL (clicked()), this, SLOT (removeCurrentVersion()));
+	connect (ui.clearExePaths, SIGNAL (clicked()), this, SLOT (clearExePathsClicked()));
+	setWindowTitle (versionSignature());
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+ConfigWindow::~ConfigWindow()
+{
+	delete &ui;
+
+	for (int i = 0; i < m_versionEntries.size(); ++i)
+		delete m_versionEntries[i];
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+VersionGuiEntry* ConfigWindow::addVersion (const ZandronumVersion& version)
+{
+	QTableWidgetItem* labelItem = new QTableWidgetItem (version.name);
+	QTableWidgetItem* pathItem = new QTableWidgetItem (version.binaryPath);
+	int rownum = ui.exePaths->rowCount();
+	ui.exePaths->setSortingEnabled (false);
+	ui.exePaths->insertRow (rownum);
+	ui.exePaths->setItem (rownum, LabelColumn, labelItem);
+	ui.exePaths->setItem (rownum, PathColumn, pathItem);
+	ui.exePaths->setSortingEnabled (true);
+
+	VersionGuiEntry* entry = new VersionGuiEntry;
+	entry->isRelease = version.isRelease;
+	entry->name = version.name;
+	entry->labelItem = labelItem;
+	entry->pathItem = pathItem;
+	m_versionEntries.append (entry);
+	m_versionEntryMap[pathItem] = entry;
+	return entry;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::removeVersion (VersionGuiEntry* entry)
+{
+	for (int i = 0; i < m_versionEntries.size(); ++i)
+	{
+		if (m_versionEntries[i] == entry)
+		{
+			m_versionEntries.removeAt (i);
+			break;
+		}
+	}
+
+	m_versionEntryMap.remove (entry->pathItem);
+	ui.exePaths->removeRow (entry->pathItem->row());
+	delete entry;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::removeCurrentVersion()
+{
+	VersionGuiEntry* entry = currentVersionEntry();
+
+	if (entry)
+		removeVersion (entry);
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::newVersion()
+{
+	VersionGuiEntry* entry = addVersion (ZandronumVersion());
+	AddVersionPrompt* prompt = new AddVersionPrompt (entry, this);
+
+	if (not prompt->exec())
+		removeVersion (entry);
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::editExePressed()
+{
+	VersionGuiEntry* entry = currentVersionEntry();
+	(new AddVersionPrompt (entry, this))->exec();
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::clearExePathsClicked()
+{
+	if (confirm ("Are you sure you want to clear all Zandronum versions?"))
+	{
+		ui.exePaths->clearContents();
+		ui.exePaths->setRowCount (0);
+
+		for (int i = 0; i < m_versionEntries.size(); ++i)
+			delete m_versionEntries[i];
+
+		m_versionEntries.clear();
+		m_versionEntryMap.clear();
+	}
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+ZandronumVersion VersionGuiEntry::toNonGuiVersion() const
+{
+	return ZandronumVersion (name, isRelease, pathItem->text());
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+VersionGuiEntry* ConfigWindow::currentVersionEntry()
+{
+	int row = ui.exePaths->currentRow();
+
+	if (row != -1)
+	{
+		VersionEntryMap::iterator it = m_versionEntryMap.find (ui.exePaths->item (row, PathColumn));
+
+		if (it != m_versionEntryMap.end())
+			return it.value();
+	}
+
+	return NULL;
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::saveSettings()
+{
+	QList<QVariant> wadPathList;
+	QList<QVariant> versions;
+
+	for (int i = 0; i < ui.wad_pathsList->count(); ++i)
+		wadPathList.append (ui.wad_pathsList->item (i)->text());
+
+	for (int i = 0; i < m_versionEntries.size(); ++i)
+	{
+		QVariant var;
+		var.setValue (m_versionEntries[i]->toNonGuiVersion());
+		versions.append (var);
+	}
+
+	Config::set ("wadpaths", wadPathList);
+	Config::set ("noprompt", ui.noDemoPrompt->isChecked());
+	Config::set ("versions", versions);
+	Config::sync();
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::addWadPath()
+{
+	addWadPath (ui.wad_pathEntry->text());
+	ui.wad_pathEntry->clear();
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::addWadPath (QString path)
+{
+	ui.wad_pathsList->addItem (path);
+	QListWidgetItem* item = ui.wad_pathsList->item (ui.wad_pathsList->count() - 1);
+	item->setFlags (item->flags() | Qt::ItemIsEditable);
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::findWadPath()
+{
+	QString path = QFileDialog::getExistingDirectory (this);
+
+	if (path.isEmpty())
+		return;
+
+	ui.wad_pathEntry->setText (path);
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::removeCurrentWadPath()
+{
+	delete ui.wad_pathsList->currentItem();
+}
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+void ConfigWindow::buttonPressed (QAbstractButton* btn)
+{
+	if (btn == ui.buttonBox->button (QDialogButtonBox::Ok))
+	{
+		saveSettings();
+		accept();
+	}
+	else if (btn == ui.buttonBox->button (QDialogButtonBox::Cancel))
+	{
+		reject();
+	}
+	else if (btn == ui.buttonBox->button (QDialogButtonBox::Apply))
+	{
+		saveSettings();
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-config/configwindow.h	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,80 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+#include <QDialog>
+#include "types.h"
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+// A ZandronumVersion represented in the config window.
+//
+
+struct VersionGuiEntry
+{
+	class QTableWidgetItem* labelItem;
+	class QTableWidgetItem* pathItem;
+	QString name;
+	bool isRelease;
+
+	ZandronumVersion toNonGuiVersion() const;
+};
+
+//
+// -------------------------------------------------------------------------------------------------
+//
+
+class ConfigWindow : public QDialog
+{
+	Q_OBJECT
+
+public:
+	enum
+	{
+		LabelColumn,
+		PathColumn,
+	};
+
+	typedef QMap<class QTableWidgetItem*, VersionGuiEntry*> VersionEntryMap;
+
+	ConfigWindow (QWidget* parent = NULL, Qt::WindowFlags f = 0);
+	virtual ~ConfigWindow();
+
+public slots:
+	void addWadPath();
+	void findWadPath();
+	void removeCurrentWadPath();
+	void buttonPressed (class QAbstractButton* btn);
+	void newVersion();
+	void removeCurrentVersion();
+	void editExePressed();
+	void clearExePathsClicked();
+
+private:
+	class Ui_ConfigBox& ui;
+	QList<VersionGuiEntry*> m_versionEntries;
+	VersionEntryMap m_versionEntryMap;
+
+	void addWadPath (QString path);
+	VersionGuiEntry* addVersion (const ZandronumVersion& version);
+	VersionGuiEntry* currentVersionEntry();
+	void initFromSettings();
+	void removeVersion (VersionGuiEntry* entry);
+	void saveSettings();
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-config/main.cpp	Sat Jun 06 23:02:51 2015 +0300
@@ -0,0 +1,32 @@
+/*
+ *  ZCinema: Zandronum demo launcher
+ *  Copyright (C) 2013-2015 Teemu Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <QApplication>
+#include "configwindow.h"
+#include "version.h"
+#include "misc.h"
+
+int main (int argc, char* argv[])
+{
+	QApplication app (argc, argv);
+	app.setApplicationName (UNIXNAME);
+	app.setOrganizationName (UNIXNAME);
+	app.setApplicationVersion (versionString());
+	commonInit();
+	return (new ConfigWindow)->exec();
+}
\ No newline at end of file
--- a/src/config.cpp	Sat Jun 06 22:28:34 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
- *  ZCinema: Zandronum demo launcher
- *  Copyright (C) 2013-2015 Teemu Piippo
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <assert.h>
-#include <QDir>
-#include <QTextStream>
-#include <QSettings>
-#include "main.h"
-
-typedef QMap<QString, QVariant> DefaultsMap;
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-static QSettings* getSettingsObject()
-{
-	return new QSettings;
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-static DefaultsMap& getDefaults()
-{
-	static DefaultsMap defaults;
-
-	if (defaults.isEmpty())
-	{
-		// Initialize defaults here.
-	}
-
-	return defaults;
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void Config::reset()
-{
-	DefaultsMap& defaults = getDefaults();
-
-	for (DefaultsMap::iterator it = defaults.begin(); it != defaults.end(); ++it)
-		set (it.key(), it.value());
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-QVariant Config::get (const QString& name)
-{
-	QSettings* settings = getSettingsObject();
-	DefaultsMap& defaults = getDefaults();
-	DefaultsMap::iterator it = defaults.find (name);
-	QVariant def = it != defaults.end() ? *it : QVariant();
-	QVariant value = settings->value (name, def);
-	settings->deleteLater();
-	return value;
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-bool Config::set (const QString& name, const QVariant& value)
-{
-	QSettings* settings = getSettingsObject();
-	settings->setValue (name, value);
-	settings->deleteLater();
-	return settings->status() == QSettings::NoError;
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void Config::sync()
-{
-	QSettings* settings = getSettingsObject();
-	settings->sync();
-	settings->deleteLater();
-}
--- a/src/config.h	Sat Jun 06 22:28:34 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- *  ZCinema: Zandronum demo launcher
- *  Copyright (C) 2013-2015 Teemu Piippo
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-#include <QVariant>
-
-namespace Config
-{
-	void reset();
-	QVariant get (const QString& name);
-	bool set (const QString& name, const QVariant& value);
-	void sync();
-};
\ No newline at end of file
--- a/src/configwindow.cpp	Sat Jun 06 22:28:34 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,292 +0,0 @@
-/*
- *  ZCinema: Zandronum demo launcher
- *  Copyright (C) 2013-2015 Teemu Piippo
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <QFileDialog>
-#include "configwindow.h"
-#include "ui_configbox.h"
-#include "misc.h"
-#include "demo.h"
-#include "prompts.h"
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-ConfigWindow::ConfigWindow (QWidget* parent, Qt::WindowFlags f) :
-	QDialog (parent, f),
-	ui (*new Ui_ConfigBox)
-{
-	ui.setupUi (this);
-
-	QStringList wadpaths = Config::get ("wadpaths").toStringList();
-	QList<QVariant> versions = Config::get ("versions").toList();
-
-	for (int i = 0; i < wadpaths.size(); ++i)
-		addWadPath (wadpaths[i]);
-
-	ui.noDemoPrompt->setChecked (Config::get ("noprompt").toBool());
-
-	for (int i = 0; i < versions.size(); ++i)
-	{
-		if (not versions[i].canConvert<ZandronumVersion>())
-			continue;
-
-		addVersion (versions[i].value<ZandronumVersion>());
-	}
-
-	connect (ui.wad_add, SIGNAL (clicked()), this, SLOT (addWadPath()));
-	connect (ui.wad_pathEntry, SIGNAL (returnPressed()), this, SLOT (addWadPath()));
-	connect (ui.wad_findPath, SIGNAL (clicked()), this, SLOT (findWadPath()));
-	connect (ui.wad_del, SIGNAL (clicked()), this, SLOT (removeCurrentWadPath()));
-	connect (ui.buttonBox, SIGNAL (clicked (QAbstractButton*)), this,
-		SLOT (buttonPressed (QAbstractButton*)));
-	connect (ui.addExePath, SIGNAL (clicked()), this, SLOT (newVersion()));
-	connect (ui.editExePath, SIGNAL (clicked()), this, SLOT (editExePressed()));
-	connect (ui.removeExePath, SIGNAL (clicked()), this, SLOT (removeCurrentVersion()));
-	connect (ui.clearExePaths, SIGNAL (clicked()), this, SLOT (clearExePathsClicked()));
-	setWindowTitle (versionSignature());
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-ConfigWindow::~ConfigWindow()
-{
-	delete &ui;
-
-	for (int i = 0; i < m_versionEntries.size(); ++i)
-		delete m_versionEntries[i];
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-VersionGuiEntry* ConfigWindow::addVersion (const ZandronumVersion& version)
-{
-	QTableWidgetItem* labelItem = new QTableWidgetItem (version.name);
-	QTableWidgetItem* pathItem = new QTableWidgetItem (version.binaryPath);
-	int rownum = ui.exePaths->rowCount();
-	ui.exePaths->setSortingEnabled (false);
-	ui.exePaths->insertRow (rownum);
-	ui.exePaths->setItem (rownum, LabelColumn, labelItem);
-	ui.exePaths->setItem (rownum, PathColumn, pathItem);
-	ui.exePaths->setSortingEnabled (true);
-
-	VersionGuiEntry* entry = new VersionGuiEntry;
-	entry->isRelease = version.isRelease;
-	entry->name = version.name;
-	entry->labelItem = labelItem;
-	entry->pathItem = pathItem;
-	m_versionEntries.append (entry);
-	m_versionEntryMap[pathItem] = entry;
-	return entry;
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::removeVersion (VersionGuiEntry* entry)
-{
-	for (int i = 0; i < m_versionEntries.size(); ++i)
-	{
-		if (m_versionEntries[i] == entry)
-		{
-			m_versionEntries.removeAt (i);
-			break;
-		}
-	}
-
-	m_versionEntryMap.remove (entry->pathItem);
-	ui.exePaths->removeRow (entry->pathItem->row());
-	delete entry;
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::removeCurrentVersion()
-{
-	VersionGuiEntry* entry = currentVersionEntry();
-
-	if (entry)
-		removeVersion (entry);
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::newVersion()
-{
-	VersionGuiEntry* entry = addVersion (ZandronumVersion());
-	AddVersionPrompt* prompt = new AddVersionPrompt (entry, this);
-
-	if (not prompt->exec())
-		removeVersion (entry);
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::editExePressed()
-{
-	VersionGuiEntry* entry = currentVersionEntry();
-	(new AddVersionPrompt (entry, this))->exec();
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::clearExePathsClicked()
-{
-	if (confirm ("Are you sure you want to clear all Zandronum versions?"))
-	{
-		ui.exePaths->clearContents();
-		ui.exePaths->setRowCount (0);
-
-		for (int i = 0; i < m_versionEntries.size(); ++i)
-			delete m_versionEntries[i];
-
-		m_versionEntries.clear();
-		m_versionEntryMap.clear();
-	}
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-ZandronumVersion VersionGuiEntry::toNonGuiVersion() const
-{
-	return ZandronumVersion (name, isRelease, pathItem->text());
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-VersionGuiEntry* ConfigWindow::currentVersionEntry()
-{
-	int row = ui.exePaths->currentRow();
-
-	if (row != -1)
-	{
-		VersionEntryMap::iterator it = m_versionEntryMap.find (ui.exePaths->item (row, PathColumn));
-
-		if (it != m_versionEntryMap.end())
-			return it.value();
-	}
-
-	return NULL;
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::saveSettings()
-{
-	QList<QVariant> wadPathList;
-	QList<QVariant> versions;
-
-	for (int i = 0; i < ui.wad_pathsList->count(); ++i)
-		wadPathList.append (ui.wad_pathsList->item (i)->text());
-
-	for (int i = 0; i < m_versionEntries.size(); ++i)
-	{
-		QVariant var;
-		var.setValue (m_versionEntries[i]->toNonGuiVersion());
-		versions.append (var);
-	}
-
-	Config::set ("wadpaths", wadPathList);
-	Config::set ("noprompt", ui.noDemoPrompt->isChecked());
-	Config::set ("versions", versions);
-	Config::sync();
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::addWadPath()
-{
-	addWadPath (ui.wad_pathEntry->text());
-	ui.wad_pathEntry->clear();
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::addWadPath (QString path)
-{
-	ui.wad_pathsList->addItem (path);
-	QListWidgetItem* item = ui.wad_pathsList->item (ui.wad_pathsList->count() - 1);
-	item->setFlags (item->flags() | Qt::ItemIsEditable);
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::findWadPath()
-{
-	QString path = QFileDialog::getExistingDirectory (this);
-
-	if (path.isEmpty())
-		return;
-
-	ui.wad_pathEntry->setText (path);
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::removeCurrentWadPath()
-{
-	delete ui.wad_pathsList->currentItem();
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void ConfigWindow::buttonPressed (QAbstractButton* btn)
-{
-	if (btn == ui.buttonBox->button (QDialogButtonBox::Ok))
-	{
-		saveSettings();
-		accept();
-	}
-	else if (btn == ui.buttonBox->button (QDialogButtonBox::Cancel))
-	{
-		reject();
-	}
-	else if (btn == ui.buttonBox->button (QDialogButtonBox::Apply))
-	{
-		saveSettings();
-	}
-}
\ No newline at end of file
--- a/src/configwindow.h	Sat Jun 06 22:28:34 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- *  ZCinema: Zandronum demo launcher
- *  Copyright (C) 2013-2015 Teemu Piippo
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-#include <QDialog>
-#include "main.h"
-#include "types.h"
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-// A ZandronumVersion represented in the config window.
-//
-
-struct VersionGuiEntry
-{
-	class QTableWidgetItem* labelItem;
-	class QTableWidgetItem* pathItem;
-	QString name;
-	bool isRelease;
-
-	ZandronumVersion toNonGuiVersion() const;
-};
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-class ConfigWindow : public QDialog
-{
-	Q_OBJECT
-
-public:
-	enum
-	{
-		LabelColumn,
-		PathColumn,
-	};
-
-	typedef QMap<class QTableWidgetItem*, VersionGuiEntry*> VersionEntryMap;
-
-	ConfigWindow (QWidget* parent = NULL, Qt::WindowFlags f = 0);
-	virtual ~ConfigWindow();
-
-public slots:
-	void addWadPath();
-	void findWadPath();
-	void removeCurrentWadPath();
-	void buttonPressed (class QAbstractButton* btn);
-	void newVersion();
-	void removeCurrentVersion();
-	void editExePressed();
-	void clearExePathsClicked();
-
-private:
-	class Ui_ConfigBox& ui;
-	QList<VersionGuiEntry*> m_versionEntries;
-	VersionEntryMap m_versionEntryMap;
-
-	void addWadPath (QString path);
-	VersionGuiEntry* addVersion (const ZandronumVersion& version);
-	VersionGuiEntry* currentVersionEntry();
-	void initFromSettings();
-	void removeVersion (VersionGuiEntry* entry);
-	void saveSettings();
-};
\ No newline at end of file
--- a/src/main.cpp	Sat Jun 06 22:28:34 2015 +0300
+++ b/src/main.cpp	Sat Jun 06 23:02:51 2015 +0300
@@ -17,11 +17,9 @@
  */
 
 #include <QApplication>
-#include "configwindow.h"
-#include "types.h"
 #include "demo.h"
 #include "prompts.h"
-#include "hginfo.h"
+#include "misc.h"
 
 //
 // -------------------------------------------------------------------------------------------------
@@ -33,19 +31,7 @@
 	app.setApplicationName (UNIXNAME);
 	app.setOrganizationName (UNIXNAME);
 	app.setApplicationVersion (versionString());
-	qRegisterMetaType<ZandronumVersion> ("ZandronumVersion");
-	qRegisterMetaTypeStreamOperators<ZandronumVersion> ("ZandronumVersion");
-
-	for (int i = 1; i < argc; ++i)
-	{
-		QString arg = argv[i];
-
-		if (arg == "--config")
-		{
-			ConfigWindow dlg;
-			return dlg.exec();
-		}
-	}
+	commonInit();
 
 	if (argc > 1)
 	{
@@ -60,39 +46,4 @@
 
 		return launchDemo (dlg->path());
 	}
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-QString versionString()
-{
-#ifndef RELEASE
-# ifdef HG_NODE
-	// non-release with hg info
-	return VERSION_STRING "-" HG_NODE;
-# else
-	// non-release, no hg info
-	return VERSION_STRING "-beta";
-# endif
-#else
-	// release
-	return VERSION_STRING;
-#endif
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-QString versionSignature()
-{
-#ifdef HG_DATE_STRING
-# define DATE_INFO " (" HG_DATE_STRING ")"
-#else
-# define DATE_INFO ""
-#endif
-
-	return QString (APPNAME) + " " + versionString() + DATE_INFO;
 }
\ No newline at end of file
--- a/src/main.h	Sat Jun 06 22:28:34 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- *  ZCinema: Zandronum demo launcher
- *  Copyright (C) 2013-2015 Teemu Piippo
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-#define APPNAME "ZCinema"
-#define UNIXNAME "zcinema"
-#define VERSION_MAJOR 1
-#define VERSION_MINOR 0
-#define VERSION_PATCH 0
-// #define RELEASE
-
-#define MACRO_TO_STRING(A) MACRO_TO_STRING_(A)
-#define MACRO_TO_STRING_(A) #A
-
-#if VERSION_PATCH == 0
-# define VERSION_STRING MACRO_TO_STRING (VERSION_MAJOR) \
-                    "." MACRO_TO_STRING (VERSION_MINOR)
-#else
-# define VERSION_STRING MACRO_TO_STRING (VERSION_MAJOR) \
-                    "." MACRO_TO_STRING (VERSION_MINOR) \
-                    "." MACRO_TO_STRING (VERSION_PATCH)
-#endif
-
-#include "config.h"
-
-QString versionString();
-QString versionSignature();
\ No newline at end of file
--- a/src/misc.cpp	Sat Jun 06 22:28:34 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- *  ZCinema: Zandronum demo launcher
- *  Copyright (C) 2013-2015 Teemu Piippo
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <QFileDialog>
-#include <QMessageBox>
-#include "misc.h"
-
-//
-// -----------------------------------------------------------------------------
-//
-
-uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d)
-{
-	return a | (b << 8) | (c << 16) | (d << 24);
-}
-
-//
-// -----------------------------------------------------------------------------
-//
-
-QList<QVariant> getVersions()
-{
-	return Config::get ("versions").toList();
-}
-
-//
-// -----------------------------------------------------------------------------
-//
-
-QString basename (const QString& path)
-{
-	int lastpos = path.lastIndexOf ("/");
-
-	if (lastpos != -1)
-		return path.mid (lastpos + 1);
-
-	return path;
-}
-
-//
-// -----------------------------------------------------------------------------
-//
-
-bool confirm (const QString& text)
-{
-	return QMessageBox::question (NULL, QObject::tr ("Confirm"), text,
-		QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::No;
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-QString getBinaryPath (QWidget* parent)
-{
-#ifdef _WIN32
-# define ZAN_EXE_NAME "zandronum.exe"
-#else
-# define ZAN_EXE_NAME "zandronum"
-#endif
-
-	return QFileDialog::getOpenFileName (parent, "", "",
-		"Zandronum Binaries (" ZAN_EXE_NAME ")(" ZAN_EXE_NAME ");;All files (*)(*)");
-}
\ No newline at end of file
--- a/src/misc.h	Sat Jun 06 22:28:34 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- *  ZCinema: Zandronum demo launcher
- *  Copyright (C) 2013-2015 Teemu Piippo
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-#include "types.h"
-
-uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d);
-QString basename (const QString& path);
-bool confirm (const QString& text);
-QList<QVariant> getVersions();
-QString getBinaryPath (QWidget* parent);
-
-//
-// -----------------------------------------------------------------------------
-//
-
-template<typename T>
-T clamp (T a, T min, T max)
-{
-	return (a > max) ? max : (a < min) ? min : a;
-}
-
-//
-// -----------------------------------------------------------------------------
-//
-
-template<typename T>
-T min (T a, T b)
-{
-	return (a < b) ? a : b;
-}
-
-//
-// -----------------------------------------------------------------------------
-//
-
-template<typename T>
-T max (T a, T b)
-{
-	return (a > b) ? a : b;
-}
-
-//
-// -----------------------------------------------------------------------------
-//
-
-template<typename T>
-T abs (T a)
-{
-	return (a < 0) ? -a : a;
-}
\ No newline at end of file
--- a/src/prompts.cpp	Sat Jun 06 22:28:34 2015 +0300
+++ b/src/prompts.cpp	Sat Jun 06 23:02:51 2015 +0300
@@ -16,14 +16,11 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <QTableWidgetItem>
 #include <QFileDialog>
 #include "prompts.h"
+#include "misc.h"
 #include "ui_unknownversion.h"
-#include "misc.h"
-#include "configwindow.h"
 #include "ui_findfile.h"
-#include "ui_addversion.h"
 
 //
 // -------------------------------------------------------------------------------------------------
@@ -135,66 +132,4 @@
 QString FindFilePrompt::path() const
 {
 	return m_ui->m_path->text();
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-AddVersionPrompt::AddVersionPrompt (VersionGuiEntry* entry, QWidget* parent, Qt::WindowFlags f)
-	: QDialog (parent, f),
-	ui (*new Ui_AddVersion),
-	m_entry (entry)
-{
-	ui.setupUi (this);
-	connect (ui.buttonBox, SIGNAL (accepted()), this, SLOT (acceptPressed()));
-	connect (ui.buttonBox, SIGNAL (rejected()), this, SLOT (reject()));
-	connect (ui.findExeButton, SIGNAL (clicked()), this, SLOT (findExePath()));
-
-	ui.nameField->setText (entry->name);
-	ui.exePathField->setText (entry->pathItem->text());
-	ui.releaseCheckbox->setChecked (entry->isRelease);
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void AddVersionPrompt::acceptPressed()
-{
-	m_entry->name = ui.nameField->text();
-	m_entry->isRelease = ui.releaseCheckbox->isChecked();
-	m_entry->labelItem->setText (m_entry->name);
-	m_entry->pathItem->setText (ui.exePathField->text());
-	accept();
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-AddVersionPrompt::~AddVersionPrompt()
-{
-	delete &ui;
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-void AddVersionPrompt::findExePath()
-{
-	QString path = getBinaryPath (this);
-
-	if (not path.isEmpty())
-		ui.exePathField->setText (path);
-}
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-VersionGuiEntry* AddVersionPrompt::getVersionInfo()
-{
-	return m_entry;
 }
\ No newline at end of file
--- a/src/prompts.h	Sat Jun 06 22:28:34 2015 +0300
+++ b/src/prompts.h	Sat Jun 06 23:02:51 2015 +0300
@@ -63,26 +63,4 @@
 
 private:
 	class Ui_FindFile* m_ui;
-};
-
-//
-// -------------------------------------------------------------------------------------------------
-//
-
-class AddVersionPrompt : public QDialog
-{
-	Q_OBJECT
-
-public:
-	AddVersionPrompt (struct VersionGuiEntry* entry, QWidget* parent = NULL, Qt::WindowFlags f = 0);
-	virtual ~AddVersionPrompt();
-	VersionGuiEntry* getVersionInfo();
-
-private slots:
-	void acceptPressed();
-	void findExePath();
-
-private:
-	class Ui_AddVersion& ui;
-	struct VersionGuiEntry* m_entry;
-};
+};
\ No newline at end of file
--- a/src/types.h	Sat Jun 06 22:28:34 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- *  ZCinema: Zandronum demo launcher
- *  Copyright (C) 2013-2015 Teemu Piippo
- *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-#include "main.h"
-#include <QString>
-#include <QList>
-#include <QVariant>
-
-template<class T> using list = QList<T>;
-template<class T> using initlist = std::initializer_list<T>;
-using std::size_t;
-
-typedef qint8 int8;
-typedef qint16 int16;
-typedef qint32 int32;
-typedef qint64 int64;
-typedef quint8 uint8;
-typedef quint16 uint16;
-typedef quint32 uint32;
-typedef quint64 uint64;
-
-struct ZandronumVersion
-{
-	ZandronumVersion (QString name, bool isRelease, QString binaryPath) :
-		name (name),
-		binaryPath (binaryPath),
-		isRelease (isRelease) {}
-
-	ZandronumVersion() :
-		isRelease (false) {}
-
-	QString name;
-	QString binaryPath;
-	bool isRelease;
-};
-
-inline QDataStream& operator<< (QDataStream& out, const ZandronumVersion& version)
-{
-	return (out << version.name << version.binaryPath << version.isRelease);
-}
-
-inline QDataStream& operator>> (QDataStream& in, ZandronumVersion& version)
-{
-	return (in >> version.name >> version.binaryPath >> version.isRelease);
-}
-
-Q_DECLARE_METATYPE (ZandronumVersion)
\ No newline at end of file

mercurial