# HG changeset patch # User unc0rr # Date 1308681835 -14400 # Node ID 562070d3f978fe29f8c5ce139410a35bf6cc517e # Parent 91752f716d64a9d8732b1b9c6a726a10a1ca9222 Derive themes list from list of dirs in Themes folder which have icon.png inside diff -r 91752f716d64 -r 562070d3f978 QTfrontend/main.cpp --- 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; diff -r 91752f716d64 -r 562070d3f978 share/hedgewars/Data/Themes/themes.cfg --- 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