30 #include "sdlkeys.h" |
31 #include "sdlkeys.h" |
31 #include "SquareLabel.h" |
32 #include "SquareLabel.h" |
32 #include "hats.h" |
33 #include "hats.h" |
33 #include "HWApplication.h" |
34 #include "HWApplication.h" |
34 |
35 |
35 PageEditTeam::PageEditTeam(QWidget* parent, SDLInteraction * sdli) : |
36 QLayout * PageEditTeam::bodyLayoutDefinition() |
36 AbstractPage(parent) |
37 { |
37 { |
38 QGridLayout * pageLayout = new QGridLayout(); |
38 m_playerHash = "0000000000000000000000000000000000000000"; |
39 QTabWidget * tbw = new QTabWidget(); |
39 mySdli = sdli; |
|
40 QGridLayout * pageLayout = new QGridLayout(this); |
|
41 QTabWidget * tbw = new QTabWidget(this); |
|
42 QWidget * page1 = new QWidget(this); |
40 QWidget * page1 = new QWidget(this); |
43 QWidget * page2 = new QWidget(this); |
41 QWidget * page2 = new QWidget(this); |
44 tbw->addTab(page1, tr("General")); |
42 tbw->addTab(page1, tr("General")); |
45 tbw->addTab(page2, tr("Advanced")); |
43 tbw->addTab(page2, tr("Advanced")); |
46 pageLayout->addWidget(tbw, 0, 0, 1, 3); |
44 pageLayout->addWidget(tbw, 0, 0, 1, 3); |
47 |
45 |
48 BtnTeamSave = addButton(":/res/Save.png", pageLayout, 1, 2, true);; |
|
49 BtnTeamSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); |
|
50 connect(BtnTeamSave, SIGNAL(clicked()), this, SLOT(saveTeam())); |
|
51 |
|
52 BtnTeamDiscard = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
|
53 BtnTeamDiscard->setFixedHeight(BtnTeamSave->height()); |
|
54 BtnTeamDiscard->setStyleSheet("QPushButton{margin-top: 31px;}"); |
|
55 connect(BtnTeamDiscard, SIGNAL(clicked()), this, SIGNAL(goBack())); |
|
56 |
|
57 QHBoxLayout * page1Layout = new QHBoxLayout(page1); |
46 QHBoxLayout * page1Layout = new QHBoxLayout(page1); |
58 page1Layout->setAlignment(Qt::AlignTop); |
47 page1Layout->setAlignment(Qt::AlignTop); |
59 QGridLayout * page2Layout = new QGridLayout(page2); |
48 QGridLayout * page2Layout = new QGridLayout(page2); |
60 |
49 |
61 // ====== Page 1 ====== |
50 // ====== Page 1 ====== |
89 HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); |
72 HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); |
90 HHNameEdit[i]->setMaxLength(64); |
73 HHNameEdit[i]->setMaxLength(64); |
91 HHNameEdit[i]->setMinimumWidth(120); |
74 HHNameEdit[i]->setMinimumWidth(120); |
92 GBHLayout->addWidget(HHNameEdit[i], i, 1); |
75 GBHLayout->addWidget(HHNameEdit[i], i, 1); |
93 |
76 |
94 connect(HHNameEdit[i], SIGNAL(editingFinished()), signalMapper1, SLOT(map())); |
77 btnRandomHogName[i] = addButton(":/res/dice.png", GBHLayout, i, 3, true); |
95 signalMapper1->setMapping(HHNameEdit[i], i); |
78 } |
96 |
79 |
97 randButton[i] = addButton(":/res/dice.png", GBHLayout, i, 3, true); |
80 btnRandomTeam = addButton(QPushButton::tr("Random Team"), GBHLayout, 9, false); |
98 |
|
99 connect(randButton[i], SIGNAL(clicked()), signalMapper2, SLOT(map())); |
|
100 signalMapper2->setMapping(randButton[i], i); |
|
101 } |
|
102 |
|
103 randTeamButton = addButton(QPushButton::tr("Random Team"), GBHLayout, 9, false); |
|
104 connect(randTeamButton, SIGNAL(clicked()), this, SLOT(setRandomNames())); |
|
105 |
81 |
106 vbox1->addWidget(GBoxHedgehogs); |
82 vbox1->addWidget(GBoxHedgehogs); |
107 |
|
108 |
83 |
109 GBoxTeam = new QGroupBox(this); |
84 GBoxTeam = new QGroupBox(this); |
110 GBoxTeam->setTitle(QGroupBox::tr("Team Settings")); |
85 GBoxTeam->setTitle(QGroupBox::tr("Team Settings")); |
111 GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
86 GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
112 QGridLayout * GBTLayout = new QGridLayout(GBoxTeam); |
87 QGridLayout * GBTLayout = new QGridLayout(GBoxTeam); |
150 CBFlag = new QComboBox(GBoxTeam); |
124 CBFlag = new QComboBox(GBoxTeam); |
151 CBFlag->setMaxCount(65535); |
125 CBFlag->setMaxCount(65535); |
152 CBFlag->setIconSize(QSize(22, 15)); |
126 CBFlag->setIconSize(QSize(22, 15)); |
153 GBTLayout->addWidget(CBFlag, 3, 1); |
127 GBTLayout->addWidget(CBFlag, 3, 1); |
154 |
128 |
155 { |
129 QHBoxLayout * hbox = new QHBoxLayout(); |
156 QHBoxLayout * hbox = new QHBoxLayout(); |
130 CBVoicepack = new QComboBox(GBoxTeam); |
157 CBVoicepack = new QComboBox(GBoxTeam); |
131 |
158 { |
132 hbox->addWidget(CBVoicepack, 100); |
159 QDir tmpdir; |
133 btnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true); |
160 QStringList list; |
134 hbox->setStretchFactor(btnTestSound, 1); |
161 tmpdir.cd(cfgdir->absolutePath()); |
135 |
162 if (tmpdir.cd("Data/Sounds/voices")) |
136 GBTLayout->addLayout(hbox, 4, 1); |
163 { |
|
164 list = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); |
|
165 CBVoicepack->addItems(list); |
|
166 } |
|
167 |
|
168 tmpdir.cd(datadir->absolutePath()); |
|
169 tmpdir.cd("Sounds/voices"); |
|
170 QStringList tmplist = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); |
|
171 QStringList tmplist2; |
|
172 for (QStringList::Iterator it = tmplist.begin(); it != tmplist.end(); ++it) |
|
173 if (!list.contains(*it,Qt::CaseInsensitive)) tmplist2.append(*it); |
|
174 |
|
175 CBVoicepack->addItems(tmplist2); |
|
176 } |
|
177 hbox->addWidget(CBVoicepack, 100); |
|
178 BtnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true); |
|
179 hbox->setStretchFactor(BtnTestSound, 1); |
|
180 connect(BtnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); |
|
181 GBTLayout->addLayout(hbox, 4, 1); |
|
182 } |
|
183 |
137 |
184 GBoxFort = new QGroupBox(this); |
138 GBoxFort = new QGroupBox(this); |
185 GBoxFort->setTitle(QGroupBox::tr("Fort")); |
139 GBoxFort->setTitle(QGroupBox::tr("Fort")); |
186 QGridLayout * GBFLayout = new QGridLayout(GBoxFort); |
140 QGridLayout * GBFLayout = new QGridLayout(GBoxFort); |
187 CBFort = new QComboBox(GBoxFort); |
141 CBFort = new QComboBox(GBoxFort); |
193 FortPreview->setPixmap(QPixmap()); |
147 FortPreview->setPixmap(QPixmap()); |
194 // perhaps due to handling its own paintevents, SquareLabel doesn't play nice with the stars |
148 // perhaps due to handling its own paintevents, SquareLabel doesn't play nice with the stars |
195 //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true); |
149 //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true); |
196 GBFLayout->addWidget(FortPreview, 1, 0); |
150 GBFLayout->addWidget(FortPreview, 1, 0); |
197 vbox2->addWidget(GBoxFort); |
151 vbox2->addWidget(GBoxFort); |
198 |
|
199 QDir tmpdir; |
|
200 QStringList userforts; |
|
201 tmpdir.cd(cfgdir->absolutePath()); |
|
202 if (tmpdir.cd("Data/Forts")) |
|
203 { |
|
204 tmpdir.setFilter(QDir::Files); |
|
205 userforts = tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1"); |
|
206 CBFort->addItems(userforts); |
|
207 } |
|
208 |
|
209 tmpdir.cd("../Graphics/Graves"); |
|
210 QStringList userlist = tmpdir.entryList(QStringList("*.png")); |
|
211 for (QStringList::Iterator it = userlist.begin(); it != userlist.end(); ++it ) |
|
212 { |
|
213 QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Graves/" + *it); |
|
214 QIcon icon(pix.copy(0, 0, 32, 32)); |
|
215 CBGrave->addItem(icon, QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
|
216 } |
|
217 |
|
218 tmpdir.cd(datadir->absolutePath()); |
|
219 tmpdir.cd("Forts"); |
|
220 tmpdir.setFilter(QDir::Files); |
|
221 |
|
222 QStringList tmplist = tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1"); |
|
223 QStringList dataforts; |
|
224 for (QStringList::Iterator it = tmplist.begin(); it != tmplist.end(); ++it) |
|
225 if (!userforts.contains(*it,Qt::CaseInsensitive)) dataforts.append(*it); |
|
226 |
|
227 CBFort->addItems(dataforts); |
|
228 connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
|
229 |
|
230 tmpdir.cd("../Graphics/Graves"); |
|
231 QStringList datalist = tmpdir.entryList(QStringList("*.png")); |
|
232 for (QStringList::Iterator it = datalist.begin(); it != datalist.end(); ++it ) |
|
233 { |
|
234 if (userlist.contains(*it,Qt::CaseInsensitive)) continue; |
|
235 QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it); |
|
236 QIcon icon(pix.copy(0, 0, 32, 32)); |
|
237 CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
|
238 } |
|
239 |
|
240 // add the default flag |
|
241 CBFlag->addItem(QIcon(QPixmap(datadir->absolutePath() + "/Graphics/Flags/hedgewars.png").copy(0, 0, 22, 15)), "Hedgewars", "hedgewars"); |
|
242 CBFlag->insertSeparator(CBFlag->count()); |
|
243 |
|
244 tmpdir.cd(cfgdir->absolutePath()); |
|
245 tmpdir.cd("Data/Graphics/Flags"); |
|
246 userlist = tmpdir.entryList(QStringList("*.png")); |
|
247 |
|
248 // add all country flags |
|
249 for (QStringList::Iterator it = userlist.begin(); it != userlist.end(); ++it ) |
|
250 { |
|
251 QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Flags/" + *it); |
|
252 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
253 if(it->compare("cpu.png") && it->compare("hedgewars.png") && (it->indexOf("cm_") == -1)) // skip cpu and hedgewars flags as well as all community flags |
|
254 { |
|
255 QString flag = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
256 CBFlag->addItem(icon, QString(flag).replace("_", " "), flag); |
|
257 } |
|
258 } |
|
259 |
|
260 CBFlag->insertSeparator(CBFlag->count()); |
|
261 |
|
262 // add all community flags |
|
263 for (QStringList::Iterator it = userlist.begin(); it != userlist.end(); ++it ) |
|
264 { |
|
265 QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Flags/" + *it); |
|
266 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
267 if(it->indexOf("cm_") > -1) // skip non community flags this time |
|
268 { |
|
269 QString flag = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
270 CBFlag->addItem(icon, QString(flag).replace("cm_", QComboBox::tr("Community") + ": "), flag); |
|
271 } |
|
272 } |
|
273 |
|
274 CBFlag->insertSeparator(CBFlag->count()); |
|
275 |
|
276 tmpdir.cd(datadir->absolutePath()); |
|
277 tmpdir.cd("Graphics/Flags"); |
|
278 datalist = tmpdir.entryList(QStringList("*.png")); |
|
279 |
|
280 // add all country flags |
|
281 for (QStringList::Iterator it = datalist.begin(); it != datalist.end(); ++it ) |
|
282 { |
|
283 if (userlist.contains(*it,Qt::CaseInsensitive)) continue; |
|
284 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
|
285 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
286 if(it->compare("cpu.png") && it->compare("hedgewars.png") && (it->indexOf("cm_") == -1)) // skip cpu and hedgewars flags as well as all community flags |
|
287 { |
|
288 QString flag = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
289 CBFlag->addItem(icon, QString(flag).replace("_", " "), flag); |
|
290 } |
|
291 } |
|
292 |
|
293 CBFlag->insertSeparator(CBFlag->count()); |
|
294 |
|
295 // add all community flags |
|
296 for (QStringList::Iterator it = datalist.begin(); it != datalist.end(); ++it ) |
|
297 { |
|
298 if (userlist.contains(*it,Qt::CaseInsensitive)) continue; |
|
299 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
|
300 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
301 if(it->indexOf("cm_") > -1) // skip non community flags this time |
|
302 { |
|
303 QString flag = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
304 CBFlag->addItem(icon, QString(flag).replace("cm_", QComboBox::tr("Community") + ": "), flag); |
|
305 } |
|
306 } |
|
307 |
152 |
308 vbox1->addStretch(); |
153 vbox1->addStretch(); |
309 vbox2->addStretch(); |
154 vbox2->addStretch(); |
310 |
155 |
311 // ====== Page 2 ====== |
156 // ====== Page 2 ====== |
351 for(int j = 0; sdlkeys[j][1][0] != '\0'; j++) |
196 for(int j = 0; sdlkeys[j][1][0] != '\0'; j++) |
352 CBBind[i]->addItem(HWApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? HWApplication::translate("binds (keys)", sdlkeys[j][1]) : HWApplication::translate("binds (keys)", "Keyboard") + QString(": ") + HWApplication::translate("binds (keys)", sdlkeys[j][1]), sdlkeys[j][0]); |
197 CBBind[i]->addItem(HWApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? HWApplication::translate("binds (keys)", sdlkeys[j][1]) : HWApplication::translate("binds (keys)", "Keyboard") + QString(": ") + HWApplication::translate("binds (keys)", sdlkeys[j][1]), sdlkeys[j][0]); |
353 pagelayout->addWidget(CBBind[i++], num++, 1); |
198 pagelayout->addWidget(CBBind[i++], num++, 1); |
354 } |
199 } |
355 |
200 |
|
201 return pageLayout; |
|
202 } |
|
203 |
|
204 QLayout * PageEditTeam::footerLayoutDefinition() |
|
205 { |
|
206 QHBoxLayout * bottomLayout = new QHBoxLayout(); |
|
207 |
|
208 btnSave = addButton(":/res/Save.png", bottomLayout, 0, true);; |
|
209 btnSave->setStyleSheet("QPushButton{margin: 24px 0 0 0;}"); |
|
210 bottomLayout->setAlignment(btnSave, Qt::AlignRight | Qt::AlignBottom); |
|
211 |
|
212 return bottomLayout; |
|
213 } |
|
214 |
|
215 void PageEditTeam::connectSignals() |
|
216 { |
|
217 connect(btnSave, SIGNAL(clicked()), this, SLOT(saveTeam())); |
|
218 |
|
219 signalMapper1 = new QSignalMapper(this); |
|
220 signalMapper2 = new QSignalMapper(this); |
|
221 |
|
222 connect(signalMapper1, SIGNAL(mapped(int)), this, SLOT(fixHHname(int))); |
|
223 connect(signalMapper2, SIGNAL(mapped(int)), this, SLOT(setRandomName(int))); |
|
224 |
|
225 for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++) |
|
226 { |
|
227 connect(HHNameEdit[i], SIGNAL(editingFinished()), signalMapper1, SLOT(map())); |
|
228 signalMapper1->setMapping(HHNameEdit[i], i); |
|
229 |
|
230 connect(btnRandomHogName[i], SIGNAL(clicked()), signalMapper2, SLOT(map())); |
|
231 signalMapper2->setMapping(btnRandomHogName[i], i); |
|
232 } |
|
233 |
|
234 connect(btnRandomTeam, SIGNAL(clicked()), this, SLOT(setRandomNames())); |
|
235 |
|
236 connect(btnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); |
|
237 |
|
238 connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
|
239 } |
|
240 |
|
241 PageEditTeam::PageEditTeam(QWidget* parent, SDLInteraction * sdli) : |
|
242 AbstractPage(parent) |
|
243 { |
|
244 initPage(); |
|
245 |
|
246 m_playerHash = "0000000000000000000000000000000000000000"; |
|
247 mySdli = sdli; |
|
248 |
|
249 QDir tmpdir; |
|
250 QStringList list; |
|
251 tmpdir.cd(cfgdir->absolutePath()); |
|
252 if (tmpdir.cd("Data/Sounds/voices")) |
|
253 { |
|
254 list = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); |
|
255 CBVoicepack->addItems(list); |
|
256 } |
|
257 |
|
258 tmpdir.cd(datadir->absolutePath()); |
|
259 tmpdir.cd("Sounds/voices"); |
|
260 QStringList tmplist = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); |
|
261 QStringList tmplist2; |
|
262 foreach (const QString & line, tmplist) |
|
263 { |
|
264 if (!list.contains(line,Qt::CaseInsensitive)) |
|
265 tmplist2.append(line); |
|
266 } |
|
267 |
|
268 CBVoicepack->addItems(tmplist2); |
|
269 |
|
270 QStringList userforts; |
|
271 tmpdir.cd(cfgdir->absolutePath()); |
|
272 if (tmpdir.cd("Data/Forts")) |
|
273 { |
|
274 tmpdir.setFilter(QDir::Files); |
|
275 userforts = tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1"); |
|
276 CBFort->addItems(userforts); |
|
277 } |
|
278 |
|
279 tmpdir.cd("../Graphics/Graves"); |
|
280 QStringList userlist = tmpdir.entryList(QStringList("*.png")); |
|
281 for (QStringList::Iterator it = userlist.begin(); it != userlist.end(); ++it ) |
|
282 { |
|
283 QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Graves/" + *it); |
|
284 QIcon icon(pix.copy(0, 0, 32, 32)); |
|
285 CBGrave->addItem(icon, QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
|
286 } |
|
287 |
|
288 tmpdir.cd(datadir->absolutePath()); |
|
289 tmpdir.cd("Forts"); |
|
290 tmpdir.setFilter(QDir::Files); |
|
291 |
|
292 tmplist = tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1"); |
|
293 QStringList dataforts; |
|
294 foreach (const QString & line, tmplist) |
|
295 { |
|
296 if (!userforts.contains(line,Qt::CaseInsensitive)) |
|
297 dataforts.append(line); |
|
298 } |
|
299 |
|
300 CBFort->addItems(dataforts); |
|
301 |
|
302 tmpdir.cd("../Graphics/Graves"); |
|
303 QStringList datalist = tmpdir.entryList(QStringList("*.png")); |
|
304 foreach (const QString & line, datalist) |
|
305 { |
|
306 if (userlist.contains(line,Qt::CaseInsensitive)) continue; |
|
307 QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + line); |
|
308 QIcon icon(pix.copy(0, 0, 32, 32)); |
|
309 QString grave = line; |
|
310 grave = grave.replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
311 CBGrave->addItem(icon, grave); |
|
312 } |
|
313 |
|
314 // add the default flag |
|
315 CBFlag->addItem(QIcon(QPixmap(datadir->absolutePath() + "/Graphics/Flags/hedgewars.png").copy(0, 0, 22, 15)), "Hedgewars", "hedgewars"); |
|
316 CBFlag->insertSeparator(CBFlag->count()); |
|
317 |
|
318 tmpdir.cd(cfgdir->absolutePath()); |
|
319 tmpdir.cd("Data/Graphics/Flags"); |
|
320 userlist = tmpdir.entryList(QStringList("*.png")); |
|
321 |
|
322 // add all country flags |
|
323 foreach (const QString & line, userlist) |
|
324 { |
|
325 QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Flags/" + line); |
|
326 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
327 // TODO improve readablility |
|
328 if(line.compare("cpu.png") && line.compare("hedgewars.png") && (line.indexOf("cm_") == -1)) // skip cpu and hedgewars flags as well as all community flags |
|
329 { |
|
330 QString flag = line; |
|
331 flag = flag.replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
332 CBFlag->addItem(icon, flag.replace("_", " "), flag); |
|
333 } |
|
334 } |
|
335 |
|
336 CBFlag->insertSeparator(CBFlag->count()); |
|
337 |
|
338 // add all community flags |
|
339 for (QStringList::Iterator it = userlist.begin(); it != userlist.end(); ++it ) |
|
340 { |
|
341 QPixmap pix(cfgdir->absolutePath() + "/Data/Graphics/Flags/" + *it); |
|
342 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
343 if(it->indexOf("cm_") > -1) // skip non community flags this time |
|
344 { |
|
345 QString flag = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
346 CBFlag->addItem(icon, QString(flag).replace("cm_", QComboBox::tr("Community") + ": "), flag); |
|
347 } |
|
348 } |
|
349 |
|
350 CBFlag->insertSeparator(CBFlag->count()); |
|
351 |
|
352 tmpdir.cd(datadir->absolutePath()); |
|
353 tmpdir.cd("Graphics/Flags"); |
|
354 datalist = tmpdir.entryList(QStringList("*.png")); |
|
355 |
|
356 // add all country flags |
|
357 for (QStringList::Iterator it = datalist.begin(); it != datalist.end(); ++it ) |
|
358 { |
|
359 if (userlist.contains(*it,Qt::CaseInsensitive)) continue; |
|
360 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
|
361 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
362 if(it->compare("cpu.png") && it->compare("hedgewars.png") && (it->indexOf("cm_") == -1)) // skip cpu and hedgewars flags as well as all community flags |
|
363 { |
|
364 QString flag = QString(*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
365 CBFlag->addItem(icon, QString(flag).replace("_", " "), flag); |
|
366 } |
|
367 } |
|
368 |
|
369 CBFlag->insertSeparator(CBFlag->count()); |
|
370 |
|
371 // add all community flags |
|
372 for (QStringList::Iterator it = datalist.begin(); it != datalist.end(); ++it ) |
|
373 { |
|
374 if (userlist.contains(*it,Qt::CaseInsensitive)) continue; |
|
375 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
|
376 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
377 if(it->indexOf("cm_") > -1) // skip non community flags this time |
|
378 { |
|
379 QString flag = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
380 CBFlag->addItem(icon, QString(flag).replace("cm_", QComboBox::tr("Community") + ": "), flag); |
|
381 } |
|
382 } |
356 } |
383 } |
357 |
384 |
358 void PageEditTeam::fixHHname(int idx) |
385 void PageEditTeam::fixHHname(int idx) |
359 { |
386 { |
360 HHNameEdit[idx]->setText(HHNameEdit[idx]->text().trimmed()); |
387 HHNameEdit[idx]->setText(HHNameEdit[idx]->text().trimmed()); |