# HG changeset patch # User Teemu Piippo # Date 1433617380 -10800 # Node ID 2c368cf5cc191aeb176ed2410ff9ace8250b1291 # Parent db677d321cf47c8635103ab576c9e6e141b20d8d Finally done with the new Zandronum version handling diff -r db677d321cf4 -r 2c368cf5cc19 src/cfg.cpp --- a/src/cfg.cpp Fri Jun 05 19:13:44 2015 +0300 +++ b/src/cfg.cpp Sat Jun 06 22:03:00 2015 +0300 @@ -25,11 +25,19 @@ typedef QMap DefaultsMap; +// +// ------------------------------------------------------------------------------------------------- +// + static QSettings* getSettingsObject() { return new QSettings; } +// +// ------------------------------------------------------------------------------------------------- +// + static DefaultsMap& getDefaults() { static DefaultsMap defaults; @@ -42,6 +50,10 @@ return defaults; } +// +// ------------------------------------------------------------------------------------------------- +// + void Config::reset() { DefaultsMap& defaults = getDefaults(); @@ -50,6 +62,10 @@ set (it.key(), it.value()); } +// +// ------------------------------------------------------------------------------------------------- +// + QVariant Config::get (const QString& name) { QSettings* settings = getSettingsObject(); @@ -61,10 +77,25 @@ 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; -} \ No newline at end of file +} + +// +// ------------------------------------------------------------------------------------------------- +// + +void Config::sync() +{ + QSettings* settings = getSettingsObject(); + settings->sync(); + settings->deleteLater(); +} diff -r db677d321cf4 -r 2c368cf5cc19 src/cfg.h --- a/src/cfg.h Fri Jun 05 19:13:44 2015 +0300 +++ b/src/cfg.h Sat Jun 06 22:03:00 2015 +0300 @@ -24,5 +24,6 @@ { void reset(); QVariant get (const QString& name); - bool set(const QString& name, const QVariant& value); + bool set (const QString& name, const QVariant& value); + void sync(); }; \ No newline at end of file diff -r db677d321cf4 -r 2c368cf5cc19 src/config.cpp --- a/src/config.cpp Fri Jun 05 19:13:44 2015 +0300 +++ b/src/config.cpp Sat Jun 06 22:03:00 2015 +0300 @@ -16,106 +16,160 @@ * along with this program. If not, see . */ -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "config.h" #include "ui_configbox.h" #include "misc.h" #include "demo.h" - -class FindPathButton : public QPushButton -{ -public: - explicit FindPathButton (QWidget* parent = NULL) : - QPushButton (parent) - { - setText ("..."); - } +#include "prompts.h" - QLineEdit* editWidget() const - { - return m_editWidget; - } - - void setEditWidget (QLineEdit* edit) - { - m_editWidget = edit; - } - -private: - QLineEdit* m_editWidget; -}; +// +// ------------------------------------------------------------------------------------------------- +// ConfigWindow::ConfigWindow (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f), - ui (new Ui_ConfigBox), - m_releaseLayout (NULL), - m_testLayout (NULL) -{ - ui->setupUi (this); - - initVersions(); - initFromSettings(); - - connect (ui->wad_add, SIGNAL (clicked()), this, SLOT (addPath())); - connect (ui->wad_pathEntry, SIGNAL (returnPressed()), this, SLOT (addPath())); - connect (ui->wad_findPath, SIGNAL (clicked()), this, SLOT (findPath())); - connect (ui->wad_del, SIGNAL (clicked()), this, SLOT (delPath())); - connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), this, - SLOT (buttonPressed (QAbstractButton*))); - setWindowTitle (versionSignature()); -} - -// -// ----------------------------------------------------------------------------- -// - -ConfigWindow::~ConfigWindow() + ui (*new Ui_ConfigBox) { - delete ui; -} + ui.setupUi (this); -// -// ----------------------------------------------------------------------------- -// + QStringList wadpaths = Config::get ("wadpaths").toStringList(); + QList versions = Config::get ("versions").toList(); -void ConfigWindow::initVersions() -{ - if (m_releaseLayout == NULL) - { - m_releaseLayout = new QVBoxLayout; - m_testLayout = new QVBoxLayout; - ui->releaseVersions->setLayout (m_releaseLayout); - ui->testingVersions->setLayout (m_testLayout); - } - else - { - // Versions are being re-initialized, clear everything - for (QWidget* w : m_binaryLayoutWidgets) - w->deleteLater(); - - m_binaryLayoutWidgets.clear(); - m_pathInputFields.clear(); - } + for (int i = 0; i < wadpaths.size(); ++i) + addWadPath (wadpaths[i]); - QList versions = getVersions(); + ui.noDemoPrompt->setChecked (Config::get ("noprompt").toBool()); for (int i = 0; i < versions.size(); ++i) { if (not versions[i].canConvert()) continue; - ZandronumVersion version = versions[i].value(); - addVersion (version); + addVersion (versions[i].value()); + } + + 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(); } } @@ -123,166 +177,116 @@ // ------------------------------------------------------------------------------------------------- // -void ConfigWindow::addVersion (const ZandronumVersion& version) +ZandronumVersion VersionGuiEntry::toNonGuiVersion() const { - QLabel* label = new QLabel (version.name + ":"); - QLineEdit* pathInput = new QLineEdit; - FindPathButton* pathFindButton = new FindPathButton; - pathFindButton->setEditWidget (pathInput); - connect (pathFindButton, SIGNAL (clicked()), this, SLOT (findZanBinary())); - - QHBoxLayout* pathInputLayout = new QHBoxLayout; - pathInputLayout->addWidget (label); - pathInputLayout->addWidget (pathInput); - pathInputLayout->addWidget (pathFindButton); - pathInput->setText (version.binaryPath); - - m_pathInputFields[version.name] = pathInput; - - if (version.isRelease) - m_releaseLayout->addLayout (pathInputLayout); - else - m_testLayout->addLayout (pathInputLayout); - - m_binaryLayoutWidgets << pathInput << pathFindButton << label; -} - -// ============================================================================= -// ----------------------------------------------------------------------------- -void ConfigWindow::initFromSettings() -{ - ui->wad_pathsList->clear(); - - for (const QVariant& it : Config::get ("wadpaths").toList()) - addPath (it.toString()); - - QList versions = Config::get ("versions").toList(); - - for (int i = 0; i < versions.size(); ++i) - { - ZandronumVersion version = versions[i].value(); - m_pathInputFields[version.name]->setText (version.binaryPath); - } - - ui->noDemoPrompt->setChecked (Config::get ("noprompt").toBool()); + 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 wadPathList; - - for (int i = 0; i < ui->wad_pathsList->count(); ++i) - wadPathList << ui->wad_pathsList->item (i)->text(); - - Config::set ("wadpaths", wadPathList); - Config::set ("noprompt", ui->noDemoPrompt->isChecked()); + QList versions; - QList versions = getVersions(); + for (int i = 0; i < ui.wad_pathsList->count(); ++i) + wadPathList.append (ui.wad_pathsList->item (i)->text()); - for (int i = 0; i < versions.size(); ++i) + for (int i = 0; i < m_versionEntries.size(); ++i) { - if (not versions[i].canConvert()) - continue; - - ZandronumVersion version = versions[i].value(); - version.binaryPath = m_pathInputFields[version.name]->text(); - versions[i].setValue (version); + 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::addPath() +void ConfigWindow::addWadPath() { - addPath (ui->wad_pathEntry->text()); - ui->wad_pathEntry->clear(); + addWadPath (ui.wad_pathEntry->text()); + ui.wad_pathEntry->clear(); } // -// ----------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // -void ConfigWindow::addPath (QString path) +void ConfigWindow::addWadPath (QString path) { - ui->wad_pathsList->addItem (path); - QListWidgetItem* item = ui->wad_pathsList->item (ui->wad_pathsList->count() - 1); + ui.wad_pathsList->addItem (path); + QListWidgetItem* item = ui.wad_pathsList->item (ui.wad_pathsList->count() - 1); item->setFlags (item->flags() | Qt::ItemIsEditable); } // -// ----------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // -void ConfigWindow::findPath() +void ConfigWindow::findWadPath() { QString path = QFileDialog::getExistingDirectory (this); if (path.isEmpty()) return; - ui->wad_pathEntry->setText (path); -} - -// -// ----------------------------------------------------------------------------- -// - -void ConfigWindow::delPath() -{ - delete ui->wad_pathsList->currentItem(); + ui.wad_pathEntry->setText (path); } // -// ----------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // -void ConfigWindow::findZanBinary() +void ConfigWindow::removeCurrentWadPath() { - FindPathButton* button = static_cast (sender()); - QString path = getBinaryPath (this); - - if (path.isEmpty()) - return; - - button->editWidget()->setText (path); + delete ui.wad_pathsList->currentItem(); } // -// ----------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------- // -QString ConfigWindow::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 (*.*)(*.*)"); -} - -// -// ----------------------------------------------------------------------------- -// - -void ConfigWindow::buttonPressed (QAbstractButton* btn) { - if (btn == ui->buttonBox->button (QDialogButtonBox::Ok)) +void ConfigWindow::buttonPressed (QAbstractButton* btn) +{ + if (btn == ui.buttonBox->button (QDialogButtonBox::Ok)) { saveSettings(); accept(); } - else if (btn == ui->buttonBox->button (QDialogButtonBox::Cancel)) + else if (btn == ui.buttonBox->button (QDialogButtonBox::Cancel)) + { reject(); - else if (btn == ui->buttonBox->button (QDialogButtonBox::Apply)) + } + else if (btn == ui.buttonBox->button (QDialogButtonBox::Apply)) + { saveSettings(); + } } \ No newline at end of file diff -r db677d321cf4 -r 2c368cf5cc19 src/config.h --- a/src/config.h Fri Jun 05 19:13:44 2015 +0300 +++ b/src/config.h Sat Jun 06 22:03:00 2015 +0300 @@ -21,35 +21,61 @@ #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: - typedef QMap ZanBinaryMap; + enum + { + LabelColumn, + PathColumn, + }; + + typedef QMap VersionEntryMap; ConfigWindow (QWidget* parent = NULL, Qt::WindowFlags f = 0); virtual ~ConfigWindow(); - void addPath (QString path); - void initFromSettings(); - void saveSettings(); - void initVersions(); - - static QString getBinaryPath (QWidget* parent); - + public slots: - void addPath(); - void findPath(); - void delPath(); - void findZanBinary(); + void addWadPath(); + void findWadPath(); + void removeCurrentWadPath(); void buttonPressed (class QAbstractButton* btn); - + void newVersion(); + void removeCurrentVersion(); + void editExePressed(); + void clearExePathsClicked(); + private: - class Ui_ConfigBox* ui; - ZanBinaryMap m_pathInputFields; - QList m_binaryLayoutWidgets; - class QVBoxLayout* m_releaseLayout; - class QVBoxLayout* m_testLayout; - - void addVersion (const ZandronumVersion& version); + class Ui_ConfigBox& ui; + QList 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 diff -r db677d321cf4 -r 2c368cf5cc19 src/demo.cpp --- a/src/demo.cpp Fri Jun 05 19:13:44 2015 +0300 +++ b/src/demo.cpp Sat Jun 06 22:03:00 2015 +0300 @@ -76,9 +76,14 @@ static ZandronumVersion findVersion (QString versionName) { - for (const QVariant& it : getVersions()) + QList versions = Config::get ("versions").toList(); + + for (int i = 0; i < versions.size(); ++i) { - ZandronumVersion version = it.value(); + if (not versions[i].canConvert()) + continue; + + ZandronumVersion version = versions[i].value(); if (version.name == versionName or version.name + "M" == versionName @@ -87,7 +92,7 @@ return version; } } - + return ZandronumVersion(); } @@ -103,9 +108,9 @@ { error (tr ("No WAD paths configured!")); - // Cannot just return an empty string here since that'd trigger - // another error prompt - skip ahead and exit. - exit (9); + // Cannot just return an empty string here since that'd trigger another error prompt - skip + // ahead and exit. + exit (1); } for (int i = 0; i < wadpaths.size(); ++i) @@ -204,8 +209,8 @@ } } - stream >> headers.length - >> length; + stream >> headers.length; + stream >> length; // The remaining headers are variable and relative to the length header. headers.version = headers.length + 1; diff -r db677d321cf4 -r 2c368cf5cc19 src/demo.h --- a/src/demo.h Fri Jun 05 19:13:44 2015 +0300 +++ b/src/demo.h Sat Jun 06 22:03:00 2015 +0300 @@ -27,11 +27,4 @@ PrivateBuild = 3 }; -struct VersionInfo -{ - QString shortVersion; - QString versionString; - bool release; -}; - int launchDemo (QString path); \ No newline at end of file diff -r db677d321cf4 -r 2c368cf5cc19 src/misc.cpp --- a/src/misc.cpp Fri Jun 05 19:13:44 2015 +0300 +++ b/src/misc.cpp Sat Jun 06 22:03:00 2015 +0300 @@ -16,8 +16,13 @@ * along with this program. If not, see . */ +#include +#include #include "misc.h" -#include + +// +// ----------------------------------------------------------------------------- +// uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d) { @@ -37,19 +42,6 @@ // ----------------------------------------------------------------------------- // -void addVersion (const ZandronumVersion& version) -{ - QList versions = getVersions(); - QVariant var; - var.setValue (version); - versions.append (var); - Config::set ("versions", versions); -} - -// -// ----------------------------------------------------------------------------- -// - QString basename (const QString& path) { int lastpos = path.lastIndexOf ("/"); @@ -68,4 +60,20 @@ { 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 diff -r db677d321cf4 -r 2c368cf5cc19 src/misc.h --- a/src/misc.h Fri Jun 05 19:13:44 2015 +0300 +++ b/src/misc.h Sat Jun 06 22:03:00 2015 +0300 @@ -21,9 +21,9 @@ uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d); QString basename (const QString& path); -void addVersion (const ZandronumVersion& version); bool confirm (const QString& text); QList getVersions(); +QString getBinaryPath (QWidget* parent); // // ----------------------------------------------------------------------------- diff -r db677d321cf4 -r 2c368cf5cc19 src/prompts.cpp --- a/src/prompts.cpp Fri Jun 05 19:13:44 2015 +0300 +++ b/src/prompts.cpp Sat Jun 06 22:03:00 2015 +0300 @@ -16,15 +16,19 @@ * along with this program. If not, see . */ +#include +#include #include "prompts.h" #include "ui_unknownversion.h" #include "misc.h" #include "config.h" #include "ui_findfile.h" -#include +#include "ui_addversion.h" -// ============================================================================= -// ----------------------------------------------------------------------------- +// +// ------------------------------------------------------------------------------------------------- +// + UnknownVersionPrompt::UnknownVersionPrompt ( QString fileName, QString binaryName, @@ -38,73 +42,159 @@ { ui = new Ui_UnknownVersion; ui->setupUi (this); - + // Replace the placeholders QString text = ui->m_description->text(); text.replace ("", basename (fileName)); text.replace ("", binaryName); ui->m_description->setText (text); - - connect (ui->m_addVersion, SIGNAL (clicked(bool)), this, SLOT (addBinary())); - connect (ui->m_findBinary, SIGNAL (clicked(bool)), this, SLOT (findBinary())); + + connect (ui->m_addVersion, SIGNAL (clicked (bool)), this, SLOT (addBinary())); + connect (ui->m_findBinary, SIGNAL (clicked (bool)), this, SLOT (findBinary())); setWindowTitle (versionSignature()); } -// ============================================================================= -// ----------------------------------------------------------------------------- -UnknownVersionPrompt::~UnknownVersionPrompt() { +// +// ------------------------------------------------------------------------------------------------- +// + +UnknownVersionPrompt::~UnknownVersionPrompt() +{ delete ui; } -// ============================================================================= -// ----------------------------------------------------------------------------- +// +// ------------------------------------------------------------------------------------------------- +// + void UnknownVersionPrompt::addBinary() { - addVersion (ZandronumVersion (m_binaryString, m_isRelease, ui->m_binaryPath->text())); + ZandronumVersion version (m_binaryString, m_isRelease, ui->m_binaryPath->text()); + QList versions = Config::get ("versions").toList(); + QVariant var; + var.setValue (version); + versions.append (var); + Config::set ("versions", versions); accept(); } -// ============================================================================= -// ----------------------------------------------------------------------------- -void UnknownVersionPrompt::findBinary() { - QString path = ConfigWindow::getBinaryPath (this); - +// +// ------------------------------------------------------------------------------------------------- +// + +void UnknownVersionPrompt::findBinary() +{ + QString path = getBinaryPath (this); + if (path.isEmpty()) return; - + ui->m_binaryPath->setText (path); } -// ============================================================================= -// ----------------------------------------------------------------------------- +// +// ------------------------------------------------------------------------------------------------- +// + FindFilePrompt::FindFilePrompt (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f), m_ui (new Ui_FindFile) { m_ui->setupUi (this); connect (m_ui->m_find, SIGNAL (clicked()), this, SLOT (findDemo())); - + setWindowTitle (versionSignature()); } -// ============================================================================= -// ----------------------------------------------------------------------------- -FindFilePrompt::~FindFilePrompt() { +// +// ------------------------------------------------------------------------------------------------- +// + +FindFilePrompt::~FindFilePrompt() +{ delete m_ui; } -// ============================================================================= -// ----------------------------------------------------------------------------- -void FindFilePrompt::findDemo() { +// +// ------------------------------------------------------------------------------------------------- +// + +void FindFilePrompt::findDemo() +{ QString path = QFileDialog::getOpenFileName (this, tr ("Open Demo File"), - QDir::homePath(), tr ("Demo files (*.cld);;All files (*.*)")); - - if (!path.isEmpty()) + QDir::homePath(), tr ("Demo files (*.cld);;All files (*.*)")); + + if (not path.isEmpty()) m_ui->m_path->setText (path); } -// ============================================================================= -// ----------------------------------------------------------------------------- -QString FindFilePrompt::path() const { +// +// ------------------------------------------------------------------------------------------------- +// + +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 diff -r db677d321cf4 -r 2c368cf5cc19 src/prompts.h --- a/src/prompts.h Fri Jun 05 19:13:44 2015 +0300 +++ b/src/prompts.h Sat Jun 06 22:03:00 2015 +0300 @@ -16,53 +16,73 @@ * along with this program. If not, see . */ -#ifndef ZCINEMA_PROMPTS_H -#define ZCINEMA_PROMPTS_H - +#pragma once #include #include "main.h" #include "types.h" -class QAbstractButton; -class Ui_UnknownVersion; -class Ui_FindFile; +// +// ------------------------------------------------------------------------------------------------- +// -// ============================================================================= -// ----------------------------------------------------------------------------- -class UnknownVersionPrompt : public QDialog { +class UnknownVersionPrompt : public QDialog +{ Q_OBJECT - + public: - explicit UnknownVersionPrompt (QString fileName, QString binaryName, bool isRelease, - QWidget* parent = NULL, Qt::WindowFlags f = 0); + UnknownVersionPrompt (QString fileName, QString binaryName, bool isRelease, + QWidget* parent = NULL, Qt::WindowFlags f = 0); virtual ~UnknownVersionPrompt(); - + public slots: void findBinary(); void addBinary(); - + private: - Ui_UnknownVersion* ui; - QString m_binaryString; - bool m_isRelease; + class Ui_UnknownVersion* ui; + QString m_binaryString; + bool m_isRelease; }; -// ============================================================================= -// ----------------------------------------------------------------------------- -class FindFilePrompt : public QDialog { +// +// ------------------------------------------------------------------------------------------------- +// + +class FindFilePrompt : public QDialog +{ Q_OBJECT - + public: - explicit FindFilePrompt (QWidget* parent = 0, Qt::WindowFlags f = 0); + FindFilePrompt (QWidget* parent = NULL, Qt::WindowFlags f = 0); virtual ~FindFilePrompt(); - + QString path() const; - + public slots: void findDemo(); - + private: - Ui_FindFile* m_ui; + class Ui_FindFile* m_ui; }; -#endif // ZCINEMA_PROMPTS_H \ No newline at end of file +// +// ------------------------------------------------------------------------------------------------- +// + +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; +}; diff -r db677d321cf4 -r 2c368cf5cc19 src/types.h --- a/src/types.h Fri Jun 05 19:13:44 2015 +0300 +++ b/src/types.h Sat Jun 06 22:03:00 2015 +0300 @@ -35,10 +35,6 @@ typedef quint32 uint32; typedef quint64 uint64; -#ifdef IN_IDE_PARSER // :| -typedef void FILE; -#endif - struct ZandronumVersion { ZandronumVersion (QString name, bool isRelease, QString binaryPath) : diff -r db677d321cf4 -r 2c368cf5cc19 ui/addversion.ui --- a/ui/addversion.ui Fri Jun 05 19:13:44 2015 +0300 +++ b/ui/addversion.ui Sat Jun 06 22:03:00 2015 +0300 @@ -6,8 +6,8 @@ 0 0 - 400 - 149 + 472 + 144 @@ -15,38 +15,31 @@ - - - <b>Add a Zandronum Version</b> - - - - - + - Name: + Name - + - + - Path to Binary: + Path to Executable - + - + ... @@ -55,7 +48,7 @@ - + Release diff -r db677d321cf4 -r 2c368cf5cc19 ui/configbox.ui --- a/ui/configbox.ui Fri Jun 05 19:13:44 2015 +0300 +++ b/ui/configbox.ui Sat Jun 06 22:03:00 2015 +0300 @@ -117,57 +117,88 @@ - + - Binary Paths + Zandronum Paths - + - - - QFrame::NoFrame + + + QAbstractItemView::NoEditTriggers - + + true + + + QAbstractItemView::SelectRows + + true - - - - 0 - 0 - 504 - 207 - + + true + + + false + + + + Version + + + + + Executable Path - - - - - Release versions - - - - - - - - - - - - Testing versions - - - - - - - - - - + + + + + + + Add + + + + + + + Edit + + + + + + + Remove + + + + + + + Clear + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + @@ -181,7 +212,7 @@ If this is not set, a prompt showing demo info is displayed first. - Launch without prompt + Launch demos without info dialog