36 m_binaryString (binaryName), |
40 m_binaryString (binaryName), |
37 m_isRelease (isRelease) |
41 m_isRelease (isRelease) |
38 { |
42 { |
39 ui = new Ui_UnknownVersion; |
43 ui = new Ui_UnknownVersion; |
40 ui->setupUi (this); |
44 ui->setupUi (this); |
41 |
45 |
42 // Replace the placeholders |
46 // Replace the placeholders |
43 QString text = ui->m_description->text(); |
47 QString text = ui->m_description->text(); |
44 text.replace ("<DEMO>", basename (fileName)); |
48 text.replace ("<DEMO>", basename (fileName)); |
45 text.replace ("<VERSION>", binaryName); |
49 text.replace ("<VERSION>", binaryName); |
46 ui->m_description->setText (text); |
50 ui->m_description->setText (text); |
47 |
51 |
48 connect (ui->m_addVersion, SIGNAL (clicked(bool)), this, SLOT (addBinary())); |
52 connect (ui->m_addVersion, SIGNAL (clicked (bool)), this, SLOT (addBinary())); |
49 connect (ui->m_findBinary, SIGNAL (clicked(bool)), this, SLOT (findBinary())); |
53 connect (ui->m_findBinary, SIGNAL (clicked (bool)), this, SLOT (findBinary())); |
50 setWindowTitle (versionSignature()); |
54 setWindowTitle (versionSignature()); |
51 } |
55 } |
52 |
56 |
53 // ============================================================================= |
57 // |
54 // ----------------------------------------------------------------------------- |
58 // ------------------------------------------------------------------------------------------------- |
55 UnknownVersionPrompt::~UnknownVersionPrompt() { |
59 // |
|
60 |
|
61 UnknownVersionPrompt::~UnknownVersionPrompt() |
|
62 { |
56 delete ui; |
63 delete ui; |
57 } |
64 } |
58 |
65 |
59 // ============================================================================= |
66 // |
60 // ----------------------------------------------------------------------------- |
67 // ------------------------------------------------------------------------------------------------- |
|
68 // |
|
69 |
61 void UnknownVersionPrompt::addBinary() |
70 void UnknownVersionPrompt::addBinary() |
62 { |
71 { |
63 addVersion (ZandronumVersion (m_binaryString, m_isRelease, ui->m_binaryPath->text())); |
72 ZandronumVersion version (m_binaryString, m_isRelease, ui->m_binaryPath->text()); |
|
73 QList<QVariant> versions = Config::get ("versions").toList(); |
|
74 QVariant var; |
|
75 var.setValue (version); |
|
76 versions.append (var); |
|
77 Config::set ("versions", versions); |
64 accept(); |
78 accept(); |
65 } |
79 } |
66 |
80 |
67 // ============================================================================= |
81 // |
68 // ----------------------------------------------------------------------------- |
82 // ------------------------------------------------------------------------------------------------- |
69 void UnknownVersionPrompt::findBinary() { |
83 // |
70 QString path = ConfigWindow::getBinaryPath (this); |
84 |
71 |
85 void UnknownVersionPrompt::findBinary() |
|
86 { |
|
87 QString path = getBinaryPath (this); |
|
88 |
72 if (path.isEmpty()) |
89 if (path.isEmpty()) |
73 return; |
90 return; |
74 |
91 |
75 ui->m_binaryPath->setText (path); |
92 ui->m_binaryPath->setText (path); |
76 } |
93 } |
77 |
94 |
78 // ============================================================================= |
95 // |
79 // ----------------------------------------------------------------------------- |
96 // ------------------------------------------------------------------------------------------------- |
|
97 // |
|
98 |
80 FindFilePrompt::FindFilePrompt (QWidget* parent, Qt::WindowFlags f) : |
99 FindFilePrompt::FindFilePrompt (QWidget* parent, Qt::WindowFlags f) : |
81 QDialog (parent, f), |
100 QDialog (parent, f), |
82 m_ui (new Ui_FindFile) |
101 m_ui (new Ui_FindFile) |
83 { |
102 { |
84 m_ui->setupUi (this); |
103 m_ui->setupUi (this); |
85 connect (m_ui->m_find, SIGNAL (clicked()), this, SLOT (findDemo())); |
104 connect (m_ui->m_find, SIGNAL (clicked()), this, SLOT (findDemo())); |
86 |
105 |
87 setWindowTitle (versionSignature()); |
106 setWindowTitle (versionSignature()); |
88 } |
107 } |
89 |
108 |
90 // ============================================================================= |
109 // |
91 // ----------------------------------------------------------------------------- |
110 // ------------------------------------------------------------------------------------------------- |
92 FindFilePrompt::~FindFilePrompt() { |
111 // |
|
112 |
|
113 FindFilePrompt::~FindFilePrompt() |
|
114 { |
93 delete m_ui; |
115 delete m_ui; |
94 } |
116 } |
95 |
117 |
96 // ============================================================================= |
118 // |
97 // ----------------------------------------------------------------------------- |
119 // ------------------------------------------------------------------------------------------------- |
98 void FindFilePrompt::findDemo() { |
120 // |
|
121 |
|
122 void FindFilePrompt::findDemo() |
|
123 { |
99 QString path = QFileDialog::getOpenFileName (this, tr ("Open Demo File"), |
124 QString path = QFileDialog::getOpenFileName (this, tr ("Open Demo File"), |
100 QDir::homePath(), tr ("Demo files (*.cld);;All files (*.*)")); |
125 QDir::homePath(), tr ("Demo files (*.cld);;All files (*.*)")); |
101 |
126 |
102 if (!path.isEmpty()) |
127 if (not path.isEmpty()) |
103 m_ui->m_path->setText (path); |
128 m_ui->m_path->setText (path); |
104 } |
129 } |
105 |
130 |
106 // ============================================================================= |
131 // |
107 // ----------------------------------------------------------------------------- |
132 // ------------------------------------------------------------------------------------------------- |
108 QString FindFilePrompt::path() const { |
133 // |
|
134 |
|
135 QString FindFilePrompt::path() const |
|
136 { |
109 return m_ui->m_path->text(); |
137 return m_ui->m_path->text(); |
110 } |
138 } |
|
139 |
|
140 // |
|
141 // ------------------------------------------------------------------------------------------------- |
|
142 // |
|
143 |
|
144 AddVersionPrompt::AddVersionPrompt (VersionGuiEntry* entry, QWidget* parent, Qt::WindowFlags f) |
|
145 : QDialog (parent, f), |
|
146 ui (*new Ui_AddVersion), |
|
147 m_entry (entry) |
|
148 { |
|
149 ui.setupUi (this); |
|
150 connect (ui.buttonBox, SIGNAL (accepted()), this, SLOT (acceptPressed())); |
|
151 connect (ui.buttonBox, SIGNAL (rejected()), this, SLOT (reject())); |
|
152 connect (ui.findExeButton, SIGNAL (clicked()), this, SLOT (findExePath())); |
|
153 |
|
154 ui.nameField->setText (entry->name); |
|
155 ui.exePathField->setText (entry->pathItem->text()); |
|
156 ui.releaseCheckbox->setChecked (entry->isRelease); |
|
157 } |
|
158 |
|
159 // |
|
160 // ------------------------------------------------------------------------------------------------- |
|
161 // |
|
162 |
|
163 void AddVersionPrompt::acceptPressed() |
|
164 { |
|
165 m_entry->name = ui.nameField->text(); |
|
166 m_entry->isRelease = ui.releaseCheckbox->isChecked(); |
|
167 m_entry->labelItem->setText (m_entry->name); |
|
168 m_entry->pathItem->setText (ui.exePathField->text()); |
|
169 accept(); |
|
170 } |
|
171 |
|
172 // |
|
173 // ------------------------------------------------------------------------------------------------- |
|
174 // |
|
175 |
|
176 AddVersionPrompt::~AddVersionPrompt() |
|
177 { |
|
178 delete &ui; |
|
179 } |
|
180 |
|
181 // |
|
182 // ------------------------------------------------------------------------------------------------- |
|
183 // |
|
184 |
|
185 void AddVersionPrompt::findExePath() |
|
186 { |
|
187 QString path = getBinaryPath (this); |
|
188 |
|
189 if (not path.isEmpty()) |
|
190 ui.exePathField->setText (path); |
|
191 } |
|
192 |
|
193 // |
|
194 // ------------------------------------------------------------------------------------------------- |
|
195 // |
|
196 |
|
197 VersionGuiEntry* AddVersionPrompt::getVersionInfo() |
|
198 { |
|
199 return m_entry; |
|
200 } |