Changeset 8d3682c


Ignore:
Timestamp:
10/18/13 10:18:39 (14 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
688b57d
Parents:
e8cdd4d
Message:

Add the ability for the GUI installer to detect your country and try to
set the default language based upon it. This will work ONLY if the
installer was able to connect to the internet.

Location:
src-qt4/pc-installgui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-installgui/backend.cpp

    r33f5a6d r8d3682c  
    234234    return -1; 
    235235} 
     236 
     237QString Backend::detectCountryCode() 
     238{ 
     239    QString code; 
     240 
     241    Process p(QStringList() << "detect-country"); 
     242 
     243    if (p.waitForFinished()) { 
     244       code = p.readLine().simplified(); 
     245    } 
     246    qDebug() << "Found Country Code:" << code; 
     247    return code; 
     248} 
     249 
    236250 
    237251QStringList Backend::networkDevices() 
  • src-qt4/pc-installgui/backend.h

    r027bbae r8d3682c  
    5757    static QStringList networkDevices(); 
    5858    static QStringList timezones(); 
     59    static QString detectCountryCode(); 
    5960    static void changeKbMap(QString model, QString layout, QString variant); 
    6061    static QList<QStringList> hardDrives(); 
  • src-qt4/pc-installgui/installer.cpp

    r01ffd8dd r8d3682c  
    101101{ 
    102102    // load languages 
     103    QString langCode; 
     104    bool foundLang = false; 
    103105    comboLanguage->clear(); 
    104106    languages = Scripts::Backend::languages(); 
     107    QString curLang = Scripts::Backend::detectCountryCode();  
    105108    for (int i=0; i < languages.count(); ++i) { 
    106109        QString languageStr = languages.at(i); 
    107110        QString language = languageStr.split("-").at(0); 
    108111        comboLanguage->addItem(language.trimmed()); 
     112 
     113        // Grab the language code 
     114        langCode = languageStr; 
     115        langCode.truncate(langCode.lastIndexOf(")")); 
     116        langCode.remove(0, langCode.lastIndexOf("(") + 1); 
     117        if ( curLang == langCode ) { 
     118          comboLanguage->setCurrentIndex(i); 
     119          foundLang = true; 
     120        } 
    109121    } 
    110122    connect(comboLanguage, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeLanguage())); 
     123    // If we found a language from geo-loication, change UI now 
     124    if ( foundLang ) 
     125       slotChangeLanguage(); 
     126     
    111127 
    112128    // Load any package scheme data 
     
    779795    // Change the default keyboard layout 
    780796    if ( langCode == "en" ) { 
    781        Scripts::Backend::changeKbMap(langCode, "pc104", ""); 
     797       Scripts::Backend::changeKbMap("pc104", "us", ""); 
    782798    } else { 
    783799       // TODO - At some point, add additional tests here and set more specific layouts 
    784800       // based upon the language selected 
    785        Scripts::Backend::changeKbMap(langCode, "pc105", "intl"); 
     801       Scripts::Backend::changeKbMap("pc105", langCode, "" ); 
    786802    } 
    787803     
Note: See TracChangeset for help on using the changeset viewer.