# HG changeset patch # User Teemu Piippo # Date 1378663330 -10800 # Node ID 9aab482c912560186ad1aa71119675704927a3a0 # Parent 256bb5c6b77fa777fdd357ce1e3e42c0769f136e When launched with no parameters, prompt the user for a demo diff -r 256bb5c6b77f -r 9aab482c9125 src/config.cpp --- 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()); } // ============================================================================= diff -r 256bb5c6b77f -r 9aab482c9125 src/demo.cpp --- 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; diff -r 256bb5c6b77f -r 9aab482c9125 src/main.cpp --- 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 - 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 diff -r 256bb5c6b77f -r 9aab482c9125 src/main.h --- 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 diff -r 256bb5c6b77f -r 9aab482c9125 src/prompts.cpp --- 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 // ============================================================================= // ----------------------------------------------------------------------------- @@ -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 diff -r 256bb5c6b77f -r 9aab482c9125 src/prompts.h --- 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