src/config.cpp

Sun, 11 Aug 2013 03:02:50 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 11 Aug 2013 03:02:50 +0300
changeset 11
3ddebf76105e
parent 10
bc1414343e19
child 13
9bdddd2ccde6
permissions
-rw-r--r--

made style more consistent

5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
1 #include <QLabel>
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
2 #include <QFileDialog>
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
3 #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
4 #include <QProgressBar>
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
5 #include <QMessageBox>
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
6 #include <QUrl>
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
7 #include <QNetworkAccessManager>
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
8 #include <QNetworkRequest>
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
9 #include <QNetworkReply>
2
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 #include "config.h"
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 #include "ui_configbox.h"
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents: 5
diff changeset
12 #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
13 #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
14 #include "build/moc_config.cpp"
2
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
16 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
17 // -----------------------------------------------------------------------------
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
18 class FindPathButton : public QPushButton {
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
19 public:
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
20 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
21 setText ("...");
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
22 }
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
23
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
24 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
25 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
26 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
27 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
28 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
29 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
30
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
31 private:
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
32 QLineEdit* m_editWidget;
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
33 };
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
34
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
35 // =============================================================================
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
36 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
37 ConfigBox::ConfigBox (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f),
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
38 m_nam (new QNetworkAccessManager (this)) {
2
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 ui = new Ui_ConfigBox;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
40 ui->setupUi (this);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
41 ui->updateProgress->hide();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
42 ui->updateLabel->hide();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
43
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
44 initVersions();
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
45 initFromSettings();
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
46
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
47 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
48 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
49 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
50 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
51 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), this,
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
52 SLOT (buttonPressed (QAbstractButton*)));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
53 setWindowTitle (fmt (APPNAME " %1", versionString()));
2
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 }
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
56 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
57 // -----------------------------------------------------------------------------
2
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 ConfigBox::~ConfigBox() {
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 delete ui;
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
60 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
61
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
62 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
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 void ConfigBox::initVersions() {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
65 QFormLayout* releaseLayout = new QFormLayout (ui->zandronumVersions),
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
66 *testLayout = new QFormLayout (ui->betaVersions);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
67 list<var> versions = getVersionsList(),
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
68 releases = getReleasesList();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
69
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
70 for (const var& ver : versions) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
71 str verstring = ver.toString();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
72
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
73 bool isRelease = false;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
74 for (const var& rel : releases) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
75 if (rel.toString() == verstring) {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
76 isRelease = true;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
77 break;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
78 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
79 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
80
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
81 QLabel* lb = new QLabel (verstring + ":");
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
82 QLineEdit* ledit = new QLineEdit;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
83 FindPathButton* btn = new FindPathButton;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
84 btn->setEditWidget (ledit);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
85
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
86 QWidget* wdg = new QWidget;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
87 QHBoxLayout* leditLayout = new QHBoxLayout (wdg);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
88 leditLayout->addWidget (ledit);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
89 leditLayout->addWidget (btn);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
90
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
91 m_zanBinaries << ledit;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
92 connect (btn, SIGNAL (clicked()), this, SLOT (findZanBinary()));
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
93
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
94 if (isRelease)
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
95 releaseLayout->addRow (lb, wdg);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
96 else
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
97 testLayout->addRow (lb, wdg);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
98 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
99 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
100
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
101 // =============================================================================
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
102 // -----------------------------------------------------------------------------
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
103 void ConfigBox::initFromSettings() {
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
104 QSettings cfg;
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
105 ui->wad_pathsList->clear();
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
106 list<var> paths = cfg.value ("wads/paths", list<var>()).toList();
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
107
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
108 for (const var & it : paths)
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
109 addPath (it.toString());
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
110
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
111 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
112
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
113 list<var> versions = getVersionsList();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
114 for (const var& ver : versions)
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
115 m_zanBinaries[i++]->setText (cfg.value (binaryConfigName (ver.toString()), "").toString());
8
e8f645d9f28f Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents: 6
diff changeset
116
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
117 ui->noDemoPrompt->setChecked (cfg.value ("nodemoprompt", false).toBool());
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
118 }
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
119
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
120 // =============================================================================
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
121 // -----------------------------------------------------------------------------
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
122 void ConfigBox::saveSettings() {
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
123 QSettings cfg;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
124 list<var> wadPathList;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
125
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
126 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
127 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
128
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
129 cfg.setValue ("wads/paths", wadPathList);
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
130 cfg.setValue ("nodemoprompt", ui->noDemoPrompt->isChecked());
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
131
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
132 int i = 0;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
133 list<var> versions = getVersionsList();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
134 for (const var& ver : versions)
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
135 cfg.setValue (binaryConfigName (ver.toString()), m_zanBinaries[i++]->text());
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
136 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
137
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
138 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
139 // -----------------------------------------------------------------------------
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
140 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
141 addPath (ui->wad_pathEntry->text());
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
142 ui->wad_pathEntry->clear();
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
143 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
144
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
145 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
146 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
147 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
148 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
149 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
150 item->setFlags (item->flags() | Qt::ItemIsEditable);
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
151 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
152
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
153 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
154 // -----------------------------------------------------------------------------
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
155 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
156 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
157
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
158 if (path.isEmpty())
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
159 return;
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
160
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
161 ui->wad_pathEntry->setText (path);
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
162 }
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
163
4
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
164 // =============================================================================
3c23aa03190d SEPARATORS
Teemu Piippo <crimsondusk64@gmail.com>
parents: 3
diff changeset
165 // -----------------------------------------------------------------------------
3
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
166 void ConfigBox::delPath() {
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
167 delete ui->wad_pathsList->currentItem();
d0b278fd29d5 Implemented wad path list
Teemu Piippo <crimsondusk64@gmail.com>
parents: 2
diff changeset
168 }
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
169
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
170 // =============================================================================
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
171 // -----------------------------------------------------------------------------
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
172 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
173 FindPathButton* btn = dynamic_cast<FindPathButton*> (sender());
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
174
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
175 if (!btn)
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
176 return;
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
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 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
179 if (path.isEmpty())
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
180 return;
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
181
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
182 btn->editWidget()->setText (path);
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
183 }
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
184
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
185 // =============================================================================
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
186 // -----------------------------------------------------------------------------
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 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
188 str path;
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
189 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
190 #ifdef _WIN32
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
191 "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
192 #else
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
193 "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
194 #endif
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
195
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
196 return QFileDialog::getOpenFileName (parent, QString(), QString(), filter);
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
197 }
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
198
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
199 // =============================================================================
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
200 // -----------------------------------------------------------------------------
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
201 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
202 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
203 saveSettings();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
204 accept();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
205 } 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
206 reject();
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
207 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
208 saveSettings();
5
3c04e05ab24f Added configs for Zandronum binary paths
Teemu Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
209 }

mercurial