25 #include "ui_configbox.h" |
25 #include "ui_configbox.h" |
26 #include "misc.h" |
26 #include "misc.h" |
27 #include "demo.h" |
27 #include "demo.h" |
28 #include "build/moc_config.cpp" |
28 #include "build/moc_config.cpp" |
29 |
29 |
|
30 CONFIG (Bool, noprompt, false) |
|
31 CONFIG (List, devBuildNames, cfg::List()) |
|
32 CONFIG (List, releaseNames, cfg::List()) |
|
33 CONFIG (List, wadpaths, cfg::List()) |
|
34 CONFIG (Map, binaryPaths, cfg::Map()) |
|
35 |
30 // ============================================================================= |
36 // ============================================================================= |
31 // ----------------------------------------------------------------------------- |
37 // ----------------------------------------------------------------------------- |
32 class FindPathButton : public QPushButton { |
38 class FindPathButton : public QPushButton { |
33 public: |
39 public: |
34 explicit FindPathButton (QWidget* parent = null) : QPushButton (parent) { |
40 explicit FindPathButton (QWidget* parent = null) : QPushButton (parent) { |
46 QLineEdit* m_editWidget; |
52 QLineEdit* m_editWidget; |
47 }; |
53 }; |
48 |
54 |
49 // ============================================================================= |
55 // ============================================================================= |
50 // ----------------------------------------------------------------------------- |
56 // ----------------------------------------------------------------------------- |
51 ConfigBox::ConfigBox (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { |
57 ConfigBox::ConfigBox (QWidget* parent, Qt::WindowFlags f) : |
52 ui = new Ui_ConfigBox; |
58 QDialog (parent, f), |
|
59 ui (new Ui_ConfigBox) |
|
60 { |
53 ui->setupUi (this); |
61 ui->setupUi (this); |
54 |
62 |
55 initVersions(); |
63 initVersions(); |
56 initFromSettings(); |
64 initFromSettings(); |
57 |
65 |
58 connect (ui->wad_add, SIGNAL (clicked()), this, SLOT (addPath())); |
66 connect (ui->wad_add, SIGNAL (clicked()), this, SLOT (addPath())); |
59 connect (ui->wad_pathEntry, SIGNAL (returnPressed()), this, SLOT (addPath())); |
67 connect (ui->wad_pathEntry, SIGNAL (returnPressed()), this, SLOT (addPath())); |
60 connect (ui->wad_findPath, SIGNAL (clicked()), this, SLOT (findPath())); |
68 connect (ui->wad_findPath, SIGNAL (clicked()), this, SLOT (findPath())); |
61 connect (ui->wad_del, SIGNAL (clicked()), this, SLOT (delPath())); |
69 connect (ui->wad_del, SIGNAL (clicked()), this, SLOT (delPath())); |
62 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), this, |
70 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), this, |
63 SLOT (buttonPressed (QAbstractButton*))); |
71 SLOT (buttonPressed (QAbstractButton*))); |
64 setWindowTitle (fmt (APPNAME " %1", versionString())); |
72 setWindowTitle (fmt (APPNAME " %1", versionString())); |
65 } |
73 } |
66 |
74 |
67 // ============================================================================= |
75 // ============================================================================= |
68 // ----------------------------------------------------------------------------- |
76 // ----------------------------------------------------------------------------- |
71 } |
79 } |
72 |
80 |
73 // ============================================================================= |
81 // ============================================================================= |
74 // ----------------------------------------------------------------------------- |
82 // ----------------------------------------------------------------------------- |
75 void ConfigBox::initVersions() { |
83 void ConfigBox::initVersions() { |
76 QFormLayout* releaseLayout = new QFormLayout (ui->zandronumVersions), |
84 m_releaseLayout = new QFormLayout (ui->zandronumVersions); |
77 *testLayout = new QFormLayout (ui->betaVersions); |
85 m_testLayout = new QFormLayout (ui->betaVersions); |
78 list<var> versions = getVersionsList(), |
86 |
79 releases = getReleasesList(); |
87 for (const var& ver : cfg::devBuildNames) |
80 |
88 addVersion (ver.toString(), false); |
81 for (const var& ver : versions) { |
89 |
82 str verstring = ver.toString(); |
90 for (const var& rel : cfg::releaseNames) |
83 |
91 addVersion (rel.toString(), true); |
84 bool isRelease = false; |
92 } |
85 for (const var& rel : releases) { |
93 |
86 if (rel.toString() == verstring) { |
94 // ============================================================================= |
87 isRelease = true; |
95 // ----------------------------------------------------------------------------- |
88 break; |
96 void ConfigBox::addVersion (const str& name, bool isRelease) { |
89 } |
97 QLabel* lb = new QLabel (name + ":"); |
90 } |
98 QLineEdit* ledit = new QLineEdit; |
91 |
99 FindPathButton* btn = new FindPathButton; |
92 QLabel* lb = new QLabel (verstring + ":"); |
100 btn->setEditWidget (ledit); |
93 QLineEdit* ledit = new QLineEdit; |
101 |
94 FindPathButton* btn = new FindPathButton; |
102 QWidget* wdg = new QWidget; |
95 btn->setEditWidget (ledit); |
103 QHBoxLayout* leditLayout = new QHBoxLayout (wdg); |
96 |
104 leditLayout->addWidget (ledit); |
97 QWidget* wdg = new QWidget; |
105 leditLayout->addWidget (btn); |
98 QHBoxLayout* leditLayout = new QHBoxLayout (wdg); |
106 |
99 leditLayout->addWidget (ledit); |
107 m_zanBinaries << ledit; |
100 leditLayout->addWidget (btn); |
108 connect (btn, SIGNAL (clicked()), this, SLOT (findZanBinary())); |
101 |
109 |
102 m_zanBinaries << ledit; |
110 if (isRelease) |
103 connect (btn, SIGNAL (clicked()), this, SLOT (findZanBinary())); |
111 m_releaseLayout->addRow (lb, wdg); |
104 |
112 else |
105 if (isRelease) |
113 m_testLayout->addRow (lb, wdg); |
106 releaseLayout->addRow (lb, wdg); |
|
107 else |
|
108 testLayout->addRow (lb, wdg); |
|
109 } |
|
110 } |
114 } |
111 |
115 |
112 // ============================================================================= |
116 // ============================================================================= |
113 // ----------------------------------------------------------------------------- |
117 // ----------------------------------------------------------------------------- |
114 void ConfigBox::initFromSettings() { |
118 void ConfigBox::initFromSettings() { |
115 QSettings cfg; |
|
116 ui->wad_pathsList->clear(); |
119 ui->wad_pathsList->clear(); |
117 list<var> paths = cfg.value ("wads/paths", list<var>()).toList(); |
120 |
118 |
121 for (const var& it : cfg::wadpaths) |
119 for (const var & it : paths) |
|
120 addPath (it.toString()); |
122 addPath (it.toString()); |
121 |
123 |
122 int i = 0; |
124 int i = 0; |
123 |
125 |
124 list<var> versions = getVersionsList(); |
126 for (const var& ver : getVersions()) |
125 for (const var& ver : versions) |
127 m_zanBinaries[i++]->setText (cfg::binaryPaths[ver.toString()].toString()); |
126 m_zanBinaries[i++]->setText (cfg.value (binaryConfigName (ver.toString()), "").toString()); |
128 |
127 |
129 ui->noDemoPrompt->setChecked (cfg::noprompt); |
128 ui->noDemoPrompt->setChecked (cfg.value ("nodemoprompt", false).toBool()); |
|
129 } |
130 } |
130 |
131 |
131 // ============================================================================= |
132 // ============================================================================= |
132 // ----------------------------------------------------------------------------- |
133 // ----------------------------------------------------------------------------- |
133 void ConfigBox::saveSettings() { |
134 void ConfigBox::saveSettings() { |
134 QSettings cfg; |
135 QList<QVariant> wadPathList; |
135 list<var> wadPathList; |
|
136 |
136 |
137 for (int i = 0; i < ui->wad_pathsList->count(); ++i) |
137 for (int i = 0; i < ui->wad_pathsList->count(); ++i) |
138 wadPathList << ui->wad_pathsList->item (i)->text(); |
138 wadPathList << ui->wad_pathsList->item (i)->text(); |
139 |
139 |
140 cfg.setValue ("wads/paths", wadPathList); |
140 cfg::wadpaths = wadPathList; |
141 cfg.setValue ("nodemoprompt", ui->noDemoPrompt->isChecked()); |
141 cfg::noprompt = ui->noDemoPrompt->isChecked(); |
142 |
142 |
143 int i = 0; |
143 int i = 0; |
144 list<var> versions = getVersionsList(); |
144 for (const var& ver : getVersions()) |
145 for (const var& ver : versions) |
145 cfg::binaryPaths[ver.toString()] = m_zanBinaries[i++]->text(); |
146 cfg.setValue (binaryConfigName (ver.toString()), m_zanBinaries[i++]->text()); |
146 |
|
147 cfg::save(); |
147 } |
148 } |
148 |
149 |
149 // ============================================================================= |
150 // ============================================================================= |
150 // ----------------------------------------------------------------------------- |
151 // ----------------------------------------------------------------------------- |
151 void ConfigBox::addPath() { |
152 void ConfigBox::addPath() { |