src/prompts.cpp

Fri, 05 Jun 2015 18:33:51 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Fri, 05 Jun 2015 18:33:51 +0300
changeset 37
c82a86ea87be
parent 36
b8fa9171be6e
child 39
2c368cf5cc19
permissions
-rw-r--r--

Major rework, lots of internal maintenance, version editor removed

13
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
1 /*
30
6b82f6a3ad53 renamed the project to ZCinema
Teemu Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
2 * ZCinema: Zandronum demo launcher
37
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
3 * Copyright (C) 2013-2015 Teemu Piippo
13
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
4 *
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
5 * This program is free software: you can redistribute it and/or modify
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
6 * it under the terms of the GNU General Public License as published by
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
8 * (at your option) any later version.
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
9 *
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
10 * This program is distributed in the hope that it will be useful,
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
13 * GNU General Public License for more details.
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
14 *
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
15 * You should have received a copy of the GNU General Public License
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
17 */
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 12
diff changeset
18
12
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include "prompts.h"
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "ui_unknownversion.h"
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "misc.h"
20
a5457405cc9b Use the cfg:: namespace system I made up a while ago instead of using QSettings directly, it's unsafe
Teemu Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
22 #include "config.h"
26
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
23 #include "ui_findfile.h"
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
24 #include <QFileDialog>
12
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 // =============================================================================
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 // -----------------------------------------------------------------------------
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 UnknownVersionPrompt::UnknownVersionPrompt (
37
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
29 QString fileName,
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
30 QString binaryName,
12
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 bool isRelease,
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 QWidget* parent,
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 Qt::WindowFlags f
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 ) :
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 QDialog (parent, f),
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36 m_binaryString (binaryName),
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 m_isRelease (isRelease)
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 {
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 ui = new Ui_UnknownVersion;
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 ui->setupUi (this);
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 // Replace the placeholders
37
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
43 QString text = ui->m_description->text();
12
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 text.replace ("<DEMO>", basename (fileName));
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 text.replace ("<VERSION>", binaryName);
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 ui->m_description->setText (text);
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 connect (ui->m_addVersion, SIGNAL (clicked(bool)), this, SLOT (addBinary()));
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 connect (ui->m_findBinary, SIGNAL (clicked(bool)), this, SLOT (findBinary()));
26
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
50 setWindowTitle (versionSignature());
12
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 }
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 // =============================================================================
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 // -----------------------------------------------------------------------------
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 UnknownVersionPrompt::~UnknownVersionPrompt() {
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 delete ui;
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 }
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 // =============================================================================
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 // -----------------------------------------------------------------------------
37
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
61 void UnknownVersionPrompt::addBinary()
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
62 {
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
63 addVersion (ZandronumVersion (m_binaryString, m_isRelease, ui->m_binaryPath->text()));
12
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64 accept();
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 }
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 // =============================================================================
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 // -----------------------------------------------------------------------------
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 void UnknownVersionPrompt::findBinary() {
37
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
70 QString path = ConfigWindow::getBinaryPath (this);
12
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 if (path.isEmpty())
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 return;
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74
755bd43b2f9b added missing files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 ui->m_binaryPath->setText (path);
26
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
76 }
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
77
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
78 // =============================================================================
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
79 // -----------------------------------------------------------------------------
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
80 FindFilePrompt::FindFilePrompt (QWidget* parent, Qt::WindowFlags f) :
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
81 QDialog (parent, f),
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
82 m_ui (new Ui_FindFile)
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
83 {
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
84 m_ui->setupUi (this);
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
85 connect (m_ui->m_find, SIGNAL (clicked()), this, SLOT (findDemo()));
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
86
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
87 setWindowTitle (versionSignature());
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
88 }
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
89
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
90 // =============================================================================
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
91 // -----------------------------------------------------------------------------
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
92 FindFilePrompt::~FindFilePrompt() {
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
93 delete m_ui;
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
94 }
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
95
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
96 // =============================================================================
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
97 // -----------------------------------------------------------------------------
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
98 void FindFilePrompt::findDemo() {
37
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
99 QString path = QFileDialog::getOpenFileName (this, tr ("Open Demo File"),
26
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
100 QDir::homePath(), tr ("Demo files (*.cld);;All files (*.*)"));
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
101
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
102 if (!path.isEmpty())
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
103 m_ui->m_path->setText (path);
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
104 }
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
105
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
106 // =============================================================================
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
107 // -----------------------------------------------------------------------------
37
c82a86ea87be Major rework, lots of internal maintenance, version editor removed
Teemu Piippo <crimsondusk64@gmail.com>
parents: 36
diff changeset
108 QString FindFilePrompt::path() const {
26
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
109 return m_ui->m_path->text();
36
b8fa9171be6e Converted to CMake
Teemu Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
110 }

mercurial