Changeset ac4cb71650 in tspsg for src
- Timestamp:
- Jun 25, 2009, 3:02:11 PM (16 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- 993d5af6f6
- Parents:
- 899d1b8e15
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mainwindow.cpp
r899d1b8e15 rac4cb71650 38 38 #endif // Q_OS_WINCE 39 39 groupSettingsLanguageList = new QActionGroup(this); 40 actionSettingsLanguageEnglish->setData("en"); 41 actionSettingsLanguageEnglish->setActionGroup(groupSettingsLanguageList); 40 42 loadLangList(); 41 43 spinCities->setValue(settings->value("NumCities",5).toInt()); … … 83 85 } 84 86 85 bool MainWindow::loadLanguage( )87 bool MainWindow::loadLanguage(QString lang) 86 88 { 87 89 // i18n 88 bool ad = settings->value("Language","").toString().isEmpty(); 89 QString lang = settings->value("Language",QLocale::system().name()).toString(); 90 bool ad = false; 91 if (lang.isEmpty()) { 92 ad = settings->value("Language","").toString().isEmpty(); 93 lang = settings->value("Language",QLocale::system().name()).toString(); 94 } 90 95 static QTranslator *qtTranslator; 91 96 if (qtTranslator) { … … 95 100 } 96 101 qtTranslator = new QTranslator(); 102 static QTranslator *translator; 103 if (translator) { 104 qApp->removeTranslator(translator); 105 delete translator; 106 } 107 translator = new QTranslator(); 97 108 if (lang.compare("en") && !lang.startsWith("en_")) { 98 109 // Trying to load system Qt library translation... … … 107 118 qtTranslator = NULL; 108 119 } 109 } 110 // Now let's load application translation. 111 static QTranslator *translator; 112 if (translator) { 113 qApp->removeTranslator(translator); 114 delete translator; 115 } 116 translator = new QTranslator(); 117 if (lang.compare("en") && !lang.startsWith("en_")) { 120 // Now let's load application translation. 118 121 if (translator->load(lang,"i18n")) 119 122 qApp->installTranslator(translator); … … 203 206 { 204 207 // TODO: Normal about window :-) 205 QString about = QString::fromUtf8("TSPSG - TSP Solver and Generator\n \206 Copyright (C) 2007-%1 Lёppa <contacts[at]oleksii[dot]name>\n\ 207 Qt library versions:\n\ 208 Compile time: %2\n\ 209 Runtime: %3\n\ 210 \n\ 211 TSPSG is licensed under the terms of the GNU General Public License. You should have received a copy of the GNU General Public License along with TSPSG.").arg(QDate().toString("%Y"),QT_VERSION_STR,qVersion());208 QString about = QString::fromUtf8("TSPSG - TSP Solver and Generator\n"); 209 about += QString::fromUtf8(" Copyright (C) 2007-%1 Lёppa <contacts[at]oleksii[dot]name>\n").arg(QDate::currentDate().toString("yyyy")); 210 about += "Qt library versions:\n"; 211 about += QString::fromUtf8(" Compile time: %1\n").arg(QT_VERSION_STR); 212 about += QString::fromUtf8(" Runtime: %1\n").arg(qVersion()); 213 about += "\n"; 214 about += "TSPSG is licensed under the terms of the GNU General Public License. You should have received a copy of the GNU General Public License along with TSPSG."; 212 215 QMessageBox(QMessageBox::Information,"About",about,QMessageBox::Ok,this).exec(); 213 216 } … … 223 226 if (langs.size() <= 0) 224 227 return; 225 menuSettingsLanguage->addSeparator();226 228 QAction *a; 227 229 for (int k = 0; k < langs.size(); k++) { 228 230 QFileInfo lang = langs.at(k); 229 if (!lang.completeBaseName().startsWith("qt_") ) {231 if (!lang.completeBaseName().startsWith("qt_") && lang.completeBaseName().compare("en")) { 230 232 a = menuSettingsLanguage->addAction(langinfo.value(lang.completeBaseName() + "/NativeName",lang.completeBaseName()).toString()); 231 233 a->setData(lang.completeBaseName()); … … 256 258 return; 257 259 } 258 if (loadLanguage( )) {260 if (loadLanguage(action->data().toString())) { 259 261 settings->setValue("Language",action->data().toString()); 260 262 retranslateUi(this); 261 } else {262 263 } 263 264 } -
src/mainwindow.h
r899d1b8e15 rac4cb71650 59 59 CTSPModel *tspmodel; 60 60 QActionGroup *groupSettingsLanguageList; 61 bool loadLanguage( );61 bool loadLanguage(QString lang = ""); 62 62 void loadLangList(); 63 63 };
Note: See TracChangeset
for help on using the changeset viewer.