QTfrontend/main.cpp
changeset 5276 562070d3f978
parent 5257 0bbdd47522b9
child 5289 9d18b61bd3eb
equal deleted inserted replaced
5275:91752f716d64 5276:562070d3f978
   382                     "Please check your installation").
   382                     "Please check your installation").
   383                     arg(datadir->absolutePath()+"/hedgewars/Data"));
   383                     arg(datadir->absolutePath()+"/hedgewars/Data"));
   384         return 1;
   384         return 1;
   385     }
   385     }
   386 
   386 
   387     Themes = new QStringList();
   387     {
   388     QFile userthemesfile(cfgdir->absolutePath() + "/Data/Themes/themes.cfg");
   388         QDir dir;
   389     if (userthemesfile.open(QIODevice::ReadOnly)) {
   389         dir.setPath(cfgdir->absolutePath() + "/Data/Themes");
   390         QTextStream stream(&userthemesfile);
   390         Themes = new QStringList();
   391         while (!stream.atEnd()) Themes->append(stream.readLine());
   391         Themes->append(dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot));
   392         userthemesfile.close();
   392 
   393     }
   393         dir.setPath(datadir->absolutePath() + "/Themes");
   394     QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg");
   394         Themes->append(dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot));
   395     QString str;
   395 qDebug() << *Themes;
   396     if (themesfile.open(QIODevice::ReadOnly)) {
   396         for(int i = Themes->size() - 1; i >= 0; --i)
   397         QTextStream stream(&themesfile);
   397         {
   398         while (!stream.atEnd()) {
   398             QFile tmpfile;
   399             str = stream.readLine();
   399             tmpfile.setFileName(QString("%1/Data/Themes/%2/icon.png").arg(cfgdir->absolutePath()).arg(Themes->at(i)));
   400             if (!Themes->contains(str)) Themes->append(str);
   400             if (!tmpfile.exists())
   401         }
   401             {
   402         themesfile.close();
   402                 tmpfile.setFileName(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(Themes->at(i)));
   403     } else {
   403                 if(!tmpfile.exists())
   404         QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK");
   404                     Themes->removeAt(i);
       
   405             }
       
   406         }
   405     }
   407     }
   406 
   408 
   407     QDir tmpdir;
   409     QDir tmpdir;
   408     tmpdir.cd(cfgdir->absolutePath());
   410     tmpdir.cd(cfgdir->absolutePath());
   409     tmpdir.cd("Data/Maps");
   411     tmpdir.cd("Data/Maps");