src/config.cpp

Sun, 08 Sep 2013 21:58:54 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 08 Sep 2013 21:58:54 +0300
changeset 29
251b121ab6c0
parent 26
9aab482c9125
child 30
6b82f6a3ad53
permissions
-rw-r--r--

added missing UI file

13
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
1 /*
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
2 * ZanDemo: Zandronum demo launcher
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
4 *
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
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: 10
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: 10
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: 10
diff changeset
8 * (at your option) any later version.
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
9 *
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
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: 10
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: 10
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
13 * GNU General Public License for more details.
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
14 *
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
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: 10
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: 10
diff changeset
17 */
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
18
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
19 #include <QLabel>
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
20 #include <QFileDialog>
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
21 #include <QFormLayout>
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
22 #include <QProgressBar>
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
23 #include <QMessageBox>
2
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "config.h"
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "ui_configbox.h"
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
26 #include "misc.h"
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
27 #include "demo.h"
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
28 #include "build/moc_config.cpp"
25
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
29 #include "versionEditor.h"
2
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30
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: 19
diff changeset
31 CONFIG (Bool, noprompt, false)
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: 19
diff changeset
32 CONFIG (List, devBuildNames, cfg::List())
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: 19
diff changeset
33 CONFIG (List, releaseNames, cfg::List())
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: 19
diff changeset
34 CONFIG (List, wadpaths, cfg::List())
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: 19
diff changeset
35 CONFIG (Map, binaryPaths, cfg::Map())
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: 19
diff changeset
36
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
37 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
38 // -----------------------------------------------------------------------------
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
39 class FindPathButton : public QPushButton {
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
40 public:
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
41 explicit FindPathButton (QWidget* parent = null) : QPushButton (parent) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
42 setText ("...");
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
43 }
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
44
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
45 QLineEdit* editWidget() const {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
46 return m_editWidget;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
47 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
48 void setEditWidget (QLineEdit* edit) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
49 m_editWidget = edit;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
50 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
51
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
52 private:
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
53 QLineEdit* m_editWidget;
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
54 };
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
55
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
56 // =============================================================================
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
57 // -----------------------------------------------------------------------------
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: 19
diff changeset
58 ConfigBox::ConfigBox (QWidget* parent, Qt::WindowFlags f) :
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: 19
diff changeset
59 QDialog (parent, f),
25
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
60 ui (new Ui_ConfigBox),
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
61 m_releaseLayout (null),
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
62 m_testLayout (null)
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: 19
diff changeset
63 {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
64 ui->setupUi (this);
19
c9b6dd9dd4cd Added infurnus' application icon
Teemu Piippo <crimsondusk64@gmail.com>
parents: 15
diff changeset
65
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
66 initVersions();
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
67 initFromSettings();
19
c9b6dd9dd4cd Added infurnus' application icon
Teemu Piippo <crimsondusk64@gmail.com>
parents: 15
diff changeset
68
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
69 connect (ui->wad_add, SIGNAL (clicked()), this, SLOT (addPath()));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
70 connect (ui->wad_pathEntry, SIGNAL (returnPressed()), this, SLOT (addPath()));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
71 connect (ui->wad_findPath, SIGNAL (clicked()), this, SLOT (findPath()));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
72 connect (ui->wad_del, SIGNAL (clicked()), this, SLOT (delPath()));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
73 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), this,
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: 19
diff changeset
74 SLOT (buttonPressed (QAbstractButton*)));
25
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
75 connect (ui->m_editVersions, SIGNAL (clicked()), this, SLOT (editBinaries()));
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
76 connect (ui->m_editVersions_2, SIGNAL (clicked()), this, SLOT (editBinaries()));
26
9aab482c9125 When launched with no parameters, prompt the user for a demo
Teemu Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
77 setWindowTitle (versionSignature());
2
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 }
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
80 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
81 // -----------------------------------------------------------------------------
2
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 ConfigBox::~ConfigBox() {
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 delete ui;
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
84 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
85
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
86 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
87 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
88 void ConfigBox::initVersions() {
25
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
89 if (m_releaseLayout == null) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
90 m_releaseLayout = new QFormLayout;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
91 m_testLayout = new QFormLayout;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
92 ui->zandronumVersions->setLayout (m_releaseLayout);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
93 ui->betaVersions->setLayout (m_testLayout);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
94 } else {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
95 // re-init, clear the layouts
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
96 QLayoutItem* item;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
97 for (QWidget* w : m_binaryLayoutWidgets)
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
98 delete w;
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
99
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
100 m_binaryLayoutWidgets.clear();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
101 m_zanBinaries.clear();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
102 }
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: 19
diff changeset
103
21
99225eac33ba use proper names QVariant and QChar instead of ambigous/dumb "var" and "qchar"
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
104 for (const QVariant& ver : cfg::devBuildNames)
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: 19
diff changeset
105 addVersion (ver.toString(), false);
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
106
21
99225eac33ba use proper names QVariant and QChar instead of ambigous/dumb "var" and "qchar"
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
107 for (const QVariant& rel : cfg::releaseNames)
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: 19
diff changeset
108 addVersion (rel.toString(), true);
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: 19
diff changeset
109 }
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
110
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: 19
diff changeset
111 // =============================================================================
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: 19
diff changeset
112 // -----------------------------------------------------------------------------
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: 19
diff changeset
113 void ConfigBox::addVersion (const str& name, bool isRelease) {
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: 19
diff changeset
114 QLabel* lb = new QLabel (name + ":");
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: 19
diff changeset
115 QLineEdit* ledit = new QLineEdit;
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: 19
diff changeset
116 FindPathButton* btn = new FindPathButton;
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: 19
diff changeset
117 btn->setEditWidget (ledit);
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: 19
diff changeset
118
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: 19
diff changeset
119 QWidget* wdg = new QWidget;
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: 19
diff changeset
120 QHBoxLayout* leditLayout = new QHBoxLayout (wdg);
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: 19
diff changeset
121 leditLayout->addWidget (ledit);
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: 19
diff changeset
122 leditLayout->addWidget (btn);
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: 19
diff changeset
123
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: 19
diff changeset
124 m_zanBinaries << ledit;
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: 19
diff changeset
125 connect (btn, SIGNAL (clicked()), this, SLOT (findZanBinary()));
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: 19
diff changeset
126
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: 19
diff changeset
127 if (isRelease)
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: 19
diff changeset
128 m_releaseLayout->addRow (lb, wdg);
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: 19
diff changeset
129 else
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: 19
diff changeset
130 m_testLayout->addRow (lb, wdg);
25
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
131
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
132 m_binaryLayoutWidgets << ledit << btn << wdg << lb;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
133 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
134
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
135 // =============================================================================
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
136 // -----------------------------------------------------------------------------
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
137 void ConfigBox::initFromSettings() {
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
138 ui->wad_pathsList->clear();
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
139
21
99225eac33ba use proper names QVariant and QChar instead of ambigous/dumb "var" and "qchar"
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
140 for (const QVariant& it : cfg::wadpaths)
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
141 addPath (it.toString());
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
142
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
143 int i = 0;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
144
21
99225eac33ba use proper names QVariant and QChar instead of ambigous/dumb "var" and "qchar"
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
145 for (const QVariant& ver : getVersions())
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: 19
diff changeset
146 m_zanBinaries[i++]->setText (cfg::binaryPaths[ver.toString()].toString());
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
147
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: 19
diff changeset
148 ui->noDemoPrompt->setChecked (cfg::noprompt);
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
149 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
150
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
151 // =============================================================================
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
152 // -----------------------------------------------------------------------------
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
153 void ConfigBox::saveSettings() {
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: 19
diff changeset
154 QList<QVariant> wadPathList;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
155
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
156 for (int i = 0; i < ui->wad_pathsList->count(); ++i)
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
157 wadPathList << ui->wad_pathsList->item (i)->text();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
158
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: 19
diff changeset
159 cfg::wadpaths = wadPathList;
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: 19
diff changeset
160 cfg::noprompt = ui->noDemoPrompt->isChecked();
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
161
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
162 int i = 0;
21
99225eac33ba use proper names QVariant and QChar instead of ambigous/dumb "var" and "qchar"
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
163 for (const QVariant& ver : getVersions())
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: 19
diff changeset
164 cfg::binaryPaths[ver.toString()] = m_zanBinaries[i++]->text();
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: 19
diff changeset
165
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: 19
diff changeset
166 cfg::save();
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
167 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
168
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
169 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
170 // -----------------------------------------------------------------------------
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
171 void ConfigBox::addPath() {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
172 addPath (ui->wad_pathEntry->text());
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
173 ui->wad_pathEntry->clear();
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
174 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
175
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
176 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
177 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
178 void ConfigBox::addPath (str path) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
179 ui->wad_pathsList->addItem (path);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
180 QListWidgetItem* item = ui->wad_pathsList->item (ui->wad_pathsList->count() - 1);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
181 item->setFlags (item->flags() | Qt::ItemIsEditable);
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
182 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
183
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
184 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
185 // -----------------------------------------------------------------------------
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
186 void ConfigBox::findPath() {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
187 str path = QFileDialog::getExistingDirectory (this);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
188
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
189 if (path.isEmpty())
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
190 return;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
191
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
192 ui->wad_pathEntry->setText (path);
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
193 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
194
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
195 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
196 // -----------------------------------------------------------------------------
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
197 void ConfigBox::delPath() {
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
198 delete ui->wad_pathsList->currentItem();
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
199 }
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
200
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
201 // =============================================================================
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
202 // -----------------------------------------------------------------------------
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
203 void ConfigBox::findZanBinary() {
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
204 FindPathButton* btn = dynamic_cast<FindPathButton*> (sender());
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
205
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
206 if (!btn)
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
207 return;
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
208
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
209 str path = getBinaryPath (this);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
210 if (path.isEmpty())
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
211 return;
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
212
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
213 btn->editWidget()->setText (path);
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
214 }
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
215
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
216 // =============================================================================
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
217 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
218 str ConfigBox::getBinaryPath (QWidget* parent) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
219 str path;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
220 const str filter =
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
221 #ifdef _WIN32
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
222 "Zandronum Binaries (zandronum.exe)(zandronum.exe);;All files (*.*)(*.*)";
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
223 #else
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
224 "Zandronum Binaries (zandronum)(zandronum);;All files (*.*)(*.*)";
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
225 #endif
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
226
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
227 return QFileDialog::getOpenFileName (parent, QString(), QString(), filter);
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
228 }
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
229
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
230 // =============================================================================
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
231 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
232 void ConfigBox::buttonPressed (QAbstractButton* btn) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
233 if (btn == ui->buttonBox->button (QDialogButtonBox::Ok)) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
234 saveSettings();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
235 accept();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
236 } elif (btn == ui->buttonBox->button (QDialogButtonBox::Cancel))
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
237 reject();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
238 elif (btn == ui->buttonBox->button (QDialogButtonBox::Apply))
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
239 saveSettings();
25
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
240 }
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
241
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
242 // =============================================================================
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
243 // -----------------------------------------------------------------------------
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
244 void ConfigBox::editBinaries() {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
245 VersionEditor* dlg = new VersionEditor (this);
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
246
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
247 if (dlg->exec()) {
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
248 dlg->saveChanges();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
249 initVersions();
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 21
diff changeset
250 }
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
251 }

mercurial