Sun, 08 Sep 2013 21:02:10 +0300
When launched with no parameters, prompt the user for a demo
src/config.cpp | file | annotate | diff | comparison | revisions | |
src/demo.cpp | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions | |
src/main.h | file | annotate | diff | comparison | revisions | |
src/prompts.cpp | file | annotate | diff | comparison | revisions | |
src/prompts.h | file | annotate | diff | comparison | revisions |
--- a/src/config.cpp Sun Sep 08 19:56:11 2013 +0300 +++ b/src/config.cpp Sun Sep 08 21:02:10 2013 +0300 @@ -74,7 +74,7 @@ SLOT (buttonPressed (QAbstractButton*))); connect (ui->m_editVersions, SIGNAL (clicked()), this, SLOT (editBinaries())); connect (ui->m_editVersions_2, SIGNAL (clicked()), this, SLOT (editBinaries())); - setWindowTitle (fmt (APPNAME " %1", versionString())); + setWindowTitle (versionSignature()); } // =============================================================================
--- a/src/demo.cpp Sun Sep 08 19:56:11 2013 +0300 +++ b/src/demo.cpp Sun Sep 08 21:02:10 2013 +0300 @@ -277,7 +277,7 @@ ui.versionLabel->setText (zanversion); ui.iwadLabel->setText (wads[0]); ui.pwadsLabel->setText (pwadtext); - dlg->setWindowTitle (str (APPNAME) + " " + versionString()); + dlg->setWindowTitle (versionSignature()); if (!dlg->exec()) return 1;
--- a/src/main.cpp Sun Sep 08 19:56:11 2013 +0300 +++ b/src/main.cpp Sun Sep 08 21:02:10 2013 +0300 @@ -20,6 +20,7 @@ #include "config.h" #include "types.h" #include "demo.h" +#include "prompts.h" // ============================================================================= // ----------------------------------------------------------------------------- @@ -41,9 +42,11 @@ } if (argc != 2) { - fprint (stderr, "Usage: %1 <demo> - Launch a demo file\n", argv[0]); - fprint (stderr, " %1 --config - Configure " APPNAME "\n", argv[0]); - return 255; + FindFilePrompt* dlg = new FindFilePrompt (null); + if (!dlg->exec()) + return 255; + + return launchDemo (dlg->path()); } return launchDemo (argv[1]); @@ -73,3 +76,7 @@ return text; } + +QString versionSignature() { + return QString (APPNAME) + " " + versionString(); +} \ No newline at end of file
--- a/src/main.h Sun Sep 08 19:56:11 2013 +0300 +++ b/src/main.h Sun Sep 08 21:02:10 2013 +0300 @@ -43,5 +43,6 @@ static const std::nullptr_t null = nullptr; QString versionString(); +QString versionSignature(); #endif // ZANDEMO_MAIN_H \ No newline at end of file
--- a/src/prompts.cpp Sun Sep 08 19:56:11 2013 +0300 +++ b/src/prompts.cpp Sun Sep 08 21:02:10 2013 +0300 @@ -21,6 +21,8 @@ #include "misc.h" #include "config.h" #include "build/moc_prompts.cpp" +#include "ui_findfile.h" +#include <QFileDialog> // ============================================================================= // ----------------------------------------------------------------------------- @@ -46,6 +48,7 @@ connect (ui->m_addVersion, SIGNAL (clicked(bool)), this, SLOT (addBinary())); connect (ui->m_findBinary, SIGNAL (clicked(bool)), this, SLOT (findBinary())); + setWindowTitle (versionSignature()); } // ============================================================================= @@ -70,4 +73,38 @@ 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() { + delete m_ui; +} + +// ============================================================================= +// ----------------------------------------------------------------------------- +void FindFilePrompt::findDemo() { + str path = QFileDialog::getOpenFileName (this, tr ("Open Demo File"), + QDir::homePath(), tr ("Demo files (*.cld);;All files (*.*)")); + + if (!path.isEmpty()) + m_ui->m_path->setText (path); +} + +// ============================================================================= +// ----------------------------------------------------------------------------- +str FindFilePrompt::path() const { + return m_ui->m_path->text(); } \ No newline at end of file
--- a/src/prompts.h Sun Sep 08 19:56:11 2013 +0300 +++ b/src/prompts.h Sun Sep 08 21:02:10 2013 +0300 @@ -25,7 +25,10 @@ class QAbstractButton; class Ui_UnknownVersion; +class Ui_FindFile; +// ============================================================================= +// ----------------------------------------------------------------------------- class UnknownVersionPrompt : public QDialog { Q_OBJECT @@ -39,9 +42,27 @@ void addBinary(); private: - Ui_UnknownVersion* ui; - QString m_binaryString; - bool m_isRelease; + Ui_UnknownVersion* ui; + QString m_binaryString; + bool m_isRelease; +}; + +// ============================================================================= +// ----------------------------------------------------------------------------- +class FindFilePrompt : public QDialog { + Q_OBJECT + +public: + explicit FindFilePrompt (QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~FindFilePrompt(); + + str path() const; + +public slots: + void findDemo(); + +private: + Ui_FindFile* m_ui; }; #endif // ZANDEMO_PROMPTS_H \ No newline at end of file