QTfrontend/main.cpp
changeset 6196 c16e84558f71
parent 6186 255aff92216d
child 6197 4ce7c29799b9
equal deleted inserted replaced
6195:6c9ada03602d 6196:c16e84558f71
   184 
   184 
   185             QFile(srcName).copy(tmpName);
   185             QFile(srcName).copy(tmpName);
   186         }
   186         }
   187     }
   187     }
   188 
   188 
       
   189     HWDataManager & dataMgr = HWDataManager::instance();
       
   190 
   189     {
   191     {
   190         QStringList themes;
   192         QStringList themes;
   191 
   193 
   192         themes.append(HWDataManager::instance().entryList(
   194         themes.append(dataMgr.entryList(
   193                          "Themes",
   195                          "Themes",
   194                          QDir::AllDirs | QDir::NoDotAndDotDot)
   196                          QDir::AllDirs | QDir::NoDotAndDotDot)
   195                      );
   197                      );
   196 
   198 
   197         QList<QPair<QIcon, QIcon> > icons;
   199         QList<QPair<QIcon, QIcon> > icons;
   198 
   200 
   199         themes.sort();
   201         themes.sort();
   200         for(int i = themes.size() - 1; i >= 0; --i)
   202         for(int i = themes.size() - 1; i >= 0; --i)
   201         {
   203         {
   202             QString file = HWDataManager::instance().findFileForRead(
   204             QString file = dataMgr.findFileForRead(
   203                 QString("Themes/%1/icon.png").arg(themes.at(i))
   205                 QString("Themes/%1/icon.png").arg(themes.at(i))
   204             );
   206             );
   205 
   207 
   206             if(QFile::exists(file))
   208             if(QFile::exists(file))
   207             { // load icon
   209             { // load icon
   208                 QPair<QIcon, QIcon> ic;
   210                 QPair<QIcon, QIcon> ic;
   209                 ic.first = QIcon(file);
   211                 ic.first = QIcon(file);
   210 
   212 
   211                 // load preview icon
   213                 // load preview icon
   212                 ic.second = QIcon(
   214                 ic.second = QIcon(
   213                     HWDataManager::instance().findFileForRead(
   215                     dataMgr.findFileForRead(
   214                         QString("Themes/%1/icon@2x.png").arg(themes.at(i))
   216                         QString("Themes/%1/icon@2x.png").arg(themes.at(i))
   215                     )
   217                     )
   216                 );
   218                 );
   217 
   219 
   218                 icons.prepend(ic);
   220                 icons.prepend(ic);
   230             themesModel->setData(themesModel->index(i), icons[i].first, Qt::DecorationRole);
   232             themesModel->setData(themesModel->index(i), icons[i].first, Qt::DecorationRole);
   231             themesModel->setData(themesModel->index(i), icons[i].second, Qt::UserRole);
   233             themesModel->setData(themesModel->index(i), icons[i].second, Qt::UserRole);
   232         }
   234         }
   233     }
   235     }
   234 
   236 
   235     mapList = new QStringList(HWDataManager::instance().entryList(
   237     mapList = new QStringList(dataMgr.entryList(
   236                                  QString("Maps"),
   238                                  QString("Maps"),
   237                                  QDir::Dirs | QDir::NoDotAndDotDot
   239                                  QDir::Dirs | QDir::NoDotAndDotDot
   238                                  )
   240                                  )
   239                              );
   241                              );
   240  
   242  
   241     scriptList = new QStringList(HWDataManager::instance().entryList(
   243     scriptList = new QStringList(dataMgr.entryList(
   242                                      QString("Scripts/Multiplayer"),
   244                                      QString("Scripts/Multiplayer"),
   243                                      QDir::Files,
   245                                      QDir::Files,
   244                                      QStringList("*.lua")
   246                                      QStringList("*.lua")
   245                                      )
   247                                      )
   246                                  );
   248                                  );
   252         if(cc.isEmpty())
   254         if(cc.isEmpty())
   253             cc = QLocale::system().name();
   255             cc = QLocale::system().name();
   254 
   256 
   255         // load locale file into translator
   257         // load locale file into translator
   256         Translator.load(
   258         Translator.load(
   257             HWDataManager::instance().findFileForRead(
   259             dataMgr.findFileForRead(
   258                 QString("Locale/hedgewars_" + cc)
   260                 QString("Locale/hedgewars_" + cc)
   259             )
   261             )
   260         );
   262         );
   261         app.installTranslator(&Translator);
   263         app.installTranslator(&Translator);
   262     }
   264     }
   276 #endif
   278 #endif
   277 
   279 
   278     QString style = "";
   280     QString style = "";
   279 
   281 
   280     // load external stylesheet if there is any
   282     // load external stylesheet if there is any
   281     QFile extFile(HWDataManager::instance().findFileForRead("css/qt.css"));
   283     QFile extFile(dataMgr.findFileForRead("css/qt.css"));
   282 
   284 
   283     QFile resFile(":/res/css/qt.css");
   285     QFile resFile(":/res/css/qt.css");
   284 
   286 
   285     QFile & file = (extFile.exists()?extFile:resFile);
   287     QFile & file = (extFile.exists()?extFile:resFile);
   286 
   288