src/config.cpp

changeset 25
256bb5c6b77f
parent 21
99225eac33ba
child 26
9aab482c9125
equal deleted inserted replaced
24:61e2752dd7cd 25:256bb5c6b77f
24 #include "config.h" 24 #include "config.h"
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 #include "versionEditor.h"
29 30
30 CONFIG (Bool, noprompt, false) 31 CONFIG (Bool, noprompt, false)
31 CONFIG (List, devBuildNames, cfg::List()) 32 CONFIG (List, devBuildNames, cfg::List())
32 CONFIG (List, releaseNames, cfg::List()) 33 CONFIG (List, releaseNames, cfg::List())
33 CONFIG (List, wadpaths, cfg::List()) 34 CONFIG (List, wadpaths, cfg::List())
54 55
55 // ============================================================================= 56 // =============================================================================
56 // ----------------------------------------------------------------------------- 57 // -----------------------------------------------------------------------------
57 ConfigBox::ConfigBox (QWidget* parent, Qt::WindowFlags f) : 58 ConfigBox::ConfigBox (QWidget* parent, Qt::WindowFlags f) :
58 QDialog (parent, f), 59 QDialog (parent, f),
59 ui (new Ui_ConfigBox) 60 ui (new Ui_ConfigBox),
61 m_releaseLayout (null),
62 m_testLayout (null)
60 { 63 {
61 ui->setupUi (this); 64 ui->setupUi (this);
62 65
63 initVersions(); 66 initVersions();
64 initFromSettings(); 67 initFromSettings();
67 connect (ui->wad_pathEntry, SIGNAL (returnPressed()), this, SLOT (addPath())); 70 connect (ui->wad_pathEntry, SIGNAL (returnPressed()), this, SLOT (addPath()));
68 connect (ui->wad_findPath, SIGNAL (clicked()), this, SLOT (findPath())); 71 connect (ui->wad_findPath, SIGNAL (clicked()), this, SLOT (findPath()));
69 connect (ui->wad_del, SIGNAL (clicked()), this, SLOT (delPath())); 72 connect (ui->wad_del, SIGNAL (clicked()), this, SLOT (delPath()));
70 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), this, 73 connect (ui->buttonBox, SIGNAL (clicked (QAbstractButton*)), this,
71 SLOT (buttonPressed (QAbstractButton*))); 74 SLOT (buttonPressed (QAbstractButton*)));
75 connect (ui->m_editVersions, SIGNAL (clicked()), this, SLOT (editBinaries()));
76 connect (ui->m_editVersions_2, SIGNAL (clicked()), this, SLOT (editBinaries()));
72 setWindowTitle (fmt (APPNAME " %1", versionString())); 77 setWindowTitle (fmt (APPNAME " %1", versionString()));
73 } 78 }
74 79
75 // ============================================================================= 80 // =============================================================================
76 // ----------------------------------------------------------------------------- 81 // -----------------------------------------------------------------------------
79 } 84 }
80 85
81 // ============================================================================= 86 // =============================================================================
82 // ----------------------------------------------------------------------------- 87 // -----------------------------------------------------------------------------
83 void ConfigBox::initVersions() { 88 void ConfigBox::initVersions() {
84 m_releaseLayout = new QFormLayout (ui->zandronumVersions); 89 if (m_releaseLayout == null) {
85 m_testLayout = new QFormLayout (ui->betaVersions); 90 m_releaseLayout = new QFormLayout;
91 m_testLayout = new QFormLayout;
92 ui->zandronumVersions->setLayout (m_releaseLayout);
93 ui->betaVersions->setLayout (m_testLayout);
94 } else {
95 // re-init, clear the layouts
96 QLayoutItem* item;
97 for (QWidget* w : m_binaryLayoutWidgets)
98 delete w;
99
100 m_binaryLayoutWidgets.clear();
101 m_zanBinaries.clear();
102 }
86 103
87 for (const QVariant& ver : cfg::devBuildNames) 104 for (const QVariant& ver : cfg::devBuildNames)
88 addVersion (ver.toString(), false); 105 addVersion (ver.toString(), false);
89 106
90 for (const QVariant& rel : cfg::releaseNames) 107 for (const QVariant& rel : cfg::releaseNames)
109 126
110 if (isRelease) 127 if (isRelease)
111 m_releaseLayout->addRow (lb, wdg); 128 m_releaseLayout->addRow (lb, wdg);
112 else 129 else
113 m_testLayout->addRow (lb, wdg); 130 m_testLayout->addRow (lb, wdg);
131
132 m_binaryLayoutWidgets << ledit << btn << wdg << lb;
114 } 133 }
115 134
116 // ============================================================================= 135 // =============================================================================
117 // ----------------------------------------------------------------------------- 136 // -----------------------------------------------------------------------------
118 void ConfigBox::initFromSettings() { 137 void ConfigBox::initFromSettings() {
217 } elif (btn == ui->buttonBox->button (QDialogButtonBox::Cancel)) 236 } elif (btn == ui->buttonBox->button (QDialogButtonBox::Cancel))
218 reject(); 237 reject();
219 elif (btn == ui->buttonBox->button (QDialogButtonBox::Apply)) 238 elif (btn == ui->buttonBox->button (QDialogButtonBox::Apply))
220 saveSettings(); 239 saveSettings();
221 } 240 }
241
242 // =============================================================================
243 // -----------------------------------------------------------------------------
244 void ConfigBox::editBinaries() {
245 VersionEditor* dlg = new VersionEditor (this);
246
247 if (dlg->exec()) {
248 dlg->saveChanges();
249 initVersions();
250 }
251 }

mercurial