Changeset ac4cb71650 in tspsg for src


Ignore:
Timestamp:
Jun 25, 2009, 3:02:11 PM (15 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
993d5af6f6
Parents:
899d1b8e15
Message:

English language should always be in language menu.

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mainwindow.cpp

    r899d1b8e15 rac4cb71650  
    3838#endif // Q_OS_WINCE
    3939        groupSettingsLanguageList = new QActionGroup(this);
     40        actionSettingsLanguageEnglish->setData("en");
     41        actionSettingsLanguageEnglish->setActionGroup(groupSettingsLanguageList);
    4042        loadLangList();
    4143        spinCities->setValue(settings->value("NumCities",5).toInt());
     
    8385}
    8486
    85 bool MainWindow::loadLanguage()
     87bool MainWindow::loadLanguage(QString lang)
    8688{
    8789// i18n
    88 bool ad = settings->value("Language","").toString().isEmpty();
    89 QString lang = settings->value("Language",QLocale::system().name()).toString();
     90bool ad = false;
     91        if (lang.isEmpty()) {
     92                ad = settings->value("Language","").toString().isEmpty();
     93                lang = settings->value("Language",QLocale::system().name()).toString();
     94        }
    9095static QTranslator *qtTranslator;
    9196        if (qtTranslator) {
     
    95100        }
    96101        qtTranslator = new QTranslator();
     102static QTranslator *translator;
     103        if (translator) {
     104                qApp->removeTranslator(translator);
     105                delete translator;
     106        }
     107        translator = new QTranslator();
    97108        if (lang.compare("en") && !lang.startsWith("en_")) {
    98109                // Trying to load system Qt library translation...
     
    107118                                qtTranslator = NULL;
    108119                        }
    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.
    118121                if (translator->load(lang,"i18n"))
    119122                        qApp->installTranslator(translator);
     
    203206{
    204207        // 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());
     208QString about = QString::fromUtf8("TSPSG - TSP Solver and Generator\n");
     209about += 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.";
    212215        QMessageBox(QMessageBox::Information,"About",about,QMessageBox::Ok,this).exec();
    213216}
     
    223226        if (langs.size() <= 0)
    224227                return;
    225         menuSettingsLanguage->addSeparator();
    226228QAction *a;
    227229        for (int k = 0; k < langs.size(); k++) {
    228230                QFileInfo lang = langs.at(k);
    229                 if (!lang.completeBaseName().startsWith("qt_")) {
     231                if (!lang.completeBaseName().startsWith("qt_") && lang.completeBaseName().compare("en")) {
    230232                        a = menuSettingsLanguage->addAction(langinfo.value(lang.completeBaseName() + "/NativeName",lang.completeBaseName()).toString());
    231233                        a->setData(lang.completeBaseName());
     
    256258                        return;
    257259        }
    258         if (loadLanguage()) {
     260        if (loadLanguage(action->data().toString())) {
    259261                settings->setValue("Language",action->data().toString());
    260262                retranslateUi(this);
    261         } else {
    262263        }
    263264}
  • src/mainwindow.h

    r899d1b8e15 rac4cb71650  
    5959        CTSPModel *tspmodel;
    6060        QActionGroup *groupSettingsLanguageList;
    61         bool loadLanguage();
     61        bool loadLanguage(QString lang = "");
    6262        void loadLangList();
    6363};
Note: See TracChangeset for help on using the changeset viewer.