QTfrontend/main.cpp
changeset 6167 728cabee2c9f
parent 6160 863d3edf5690
child 6174 2d5717595471
equal deleted inserted replaced
6166:701c5b8fac56 6167:728cabee2c9f
   404         QList<QPair<QIcon, QIcon> > icons;
   404         QList<QPair<QIcon, QIcon> > icons;
   405 
   405 
   406         themes.sort();
   406         themes.sort();
   407         for(int i = themes.size() - 1; i >= 0; --i)
   407         for(int i = themes.size() - 1; i >= 0; --i)
   408         {
   408         {
   409             QFile * tmpfile =
   409             QString file = HWDataManager::instance().findFileForRead(
   410             HWDataManager::instance().findFileForRead(
   410                 QString("Themes/%1/icon.png").arg(themes.at(i))
   411                                 QString("Themes/%1/icon.png").arg(themes.at(i))
   411             );
   412                             );
   412 
   413 
   413             if(QFile::exists(file))
   414             if(tmpfile->exists())
       
   415             { // load icon
   414             { // load icon
   416                 QPair<QIcon, QIcon> ic;
   415                 QPair<QIcon, QIcon> ic;
   417                 ic.first = QIcon(tmpfile->fileName());
   416                 ic.first = QIcon(file);
   418 
   417 
   419                 QFile * previewIconFile =
   418                 // load preview icon
       
   419                 ic.second = QIcon(
   420                     HWDataManager::instance().findFileForRead(
   420                     HWDataManager::instance().findFileForRead(
   421                             QString("Themes/%1/icon@2x.png").arg(themes.at(i))
   421                         QString("Themes/%1/icon@2x.png").arg(themes.at(i))
   422                         );
   422                     )
   423 
   423                 );
   424                 ic.second = QIcon(previewIconFile->fileName());
       
   425 
       
   426                 // this QFile is not needed any further
       
   427                 delete previewIconFile;
       
   428 
   424 
   429                 icons.prepend(ic);
   425                 icons.prepend(ic);
   430             }
   426             }
   431             else
   427             else
   432             {
   428             {
   433                 themes.removeAt(i);
   429                 themes.removeAt(i);
   434             }
   430             }
   435 
       
   436             // this QFile is not needed any further
       
   437             delete tmpfile;
       
   438         }
   431         }
   439 
   432 
   440         themesModel = new ThemesModel(themes);
   433         themesModel = new ThemesModel(themes);
   441         Q_ASSERT(themes.size() == icons.size());
   434         Q_ASSERT(themes.size() == icons.size());
   442         for(int i = 0; i < icons.size(); ++i)
   435         for(int i = 0; i < icons.size(); ++i)
   463     {
   456     {
   464         QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat);
   457         QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat);
   465         QString cc = settings.value("misc/locale", QString()).toString();
   458         QString cc = settings.value("misc/locale", QString()).toString();
   466         if(cc.isEmpty())
   459         if(cc.isEmpty())
   467             cc = QLocale::system().name();
   460             cc = QLocale::system().name();
   468         QFile * tmpfile = HWDataManager::instance().findFileForRead(
   461 
   469                                             QString("Locale/hedgewars_" + cc));
   462         // load locale file into translator
   470         Translator.load(tmpfile->fileName());
   463         Translator.load(
       
   464             HWDataManager::instance().findFileForRead(
       
   465                 QString("Locale/hedgewars_" + cc)
       
   466             )
       
   467         );
   471         app.installTranslator(&Translator);
   468         app.installTranslator(&Translator);
   472     }
   469     }
   473 
   470 
   474 #ifdef _WIN32
   471 #ifdef _WIN32
   475     // Win32 registry setup (used for xfire detection etc. - don't set it if we're running in "portable" mode with a custom config dir)
   472     // Win32 registry setup (used for xfire detection etc. - don't set it if we're running in "portable" mode with a custom config dir)