--- a/QTfrontend/main.cpp Tue Jun 21 16:55:34 2011 +0200
+++ b/QTfrontend/main.cpp Tue Jun 21 22:43:55 2011 +0400
@@ -384,24 +384,26 @@
return 1;
}
- Themes = new QStringList();
- QFile userthemesfile(cfgdir->absolutePath() + "/Data/Themes/themes.cfg");
- if (userthemesfile.open(QIODevice::ReadOnly)) {
- QTextStream stream(&userthemesfile);
- while (!stream.atEnd()) Themes->append(stream.readLine());
- userthemesfile.close();
- }
- QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg");
- QString str;
- if (themesfile.open(QIODevice::ReadOnly)) {
- QTextStream stream(&themesfile);
- while (!stream.atEnd()) {
- str = stream.readLine();
- if (!Themes->contains(str)) Themes->append(str);
+ {
+ QDir dir;
+ dir.setPath(cfgdir->absolutePath() + "/Data/Themes");
+ Themes = new QStringList();
+ Themes->append(dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot));
+
+ dir.setPath(datadir->absolutePath() + "/Themes");
+ Themes->append(dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot));
+qDebug() << *Themes;
+ for(int i = Themes->size() - 1; i >= 0; --i)
+ {
+ QFile tmpfile;
+ tmpfile.setFileName(QString("%1/Data/Themes/%2/icon.png").arg(cfgdir->absolutePath()).arg(Themes->at(i)));
+ if (!tmpfile.exists())
+ {
+ tmpfile.setFileName(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(Themes->at(i)));
+ if(!tmpfile.exists())
+ Themes->removeAt(i);
+ }
}
- themesfile.close();
- } else {
- QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK");
}
QDir tmpdir;
--- a/share/hedgewars/Data/Themes/themes.cfg Tue Jun 21 16:55:34 2011 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-Art
-Bamboo
-Bath
-Brick
-Castle
-Cheese
-Christmas
-City
-Compost
-Desert
-EarthRise
-Freeway
-Halloween
-Hell
-Island
-Jungle
-Nature
-Olympics
-Sheep
-Snow
-Stage
-Underwater