equal
deleted
inserted
replaced
209 return 1; |
209 return 1; |
210 } |
210 } |
211 |
211 |
212 DataManager & dataMgr = DataManager::instance(); |
212 DataManager & dataMgr = DataManager::instance(); |
213 |
213 |
214 { |
|
215 QStringList themes; |
|
216 |
|
217 themes.append(dataMgr.entryList( |
|
218 "Themes", |
|
219 QDir::AllDirs | QDir::NoDotAndDotDot) |
|
220 ); |
|
221 |
|
222 QList<QPair<QIcon, QIcon> > icons; |
|
223 |
|
224 themes.sort(); |
|
225 for(int i = themes.size() - 1; i >= 0; --i) |
|
226 { |
|
227 QString file = dataMgr.findFileForRead( |
|
228 QString("Themes/%1/icon.png").arg(themes.at(i)) |
|
229 ); |
|
230 |
|
231 if(QFile::exists(file)) |
|
232 { |
|
233 // load icon |
|
234 QPair<QIcon, QIcon> ic; |
|
235 ic.first = QIcon(file); |
|
236 |
|
237 // load preview icon |
|
238 ic.second = QIcon( |
|
239 dataMgr.findFileForRead( |
|
240 QString("Themes/%1/icon@2x.png").arg(themes.at(i)) |
|
241 ) |
|
242 ); |
|
243 |
|
244 icons.prepend(ic); |
|
245 } |
|
246 else |
|
247 { |
|
248 themes.removeAt(i); |
|
249 } |
|
250 } |
|
251 |
|
252 themesModel = new ThemesModel(themes); |
|
253 Q_ASSERT(themes.size() == icons.size()); |
|
254 for(int i = 0; i < icons.size(); ++i) |
|
255 { |
|
256 themesModel->setData(themesModel->index(i), icons[i].first, Qt::DecorationRole); |
|
257 themesModel->setData(themesModel->index(i), icons[i].second, Qt::UserRole); |
|
258 } |
|
259 } |
|
260 |
|
261 scriptList = new QStringList(dataMgr.entryList( |
214 scriptList = new QStringList(dataMgr.entryList( |
262 QString("Scripts/Multiplayer"), |
215 QString("Scripts/Multiplayer"), |
263 QDir::Files, |
216 QDir::Files, |
264 QStringList("*.lua") |
217 QStringList("*.lua") |
265 ) |
218 ) |