diff options
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 17 | ||||
-rw-r--r-- | rbutil/rbutilqt/main.cpp | 10 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbsettings.cpp | 8 |
3 files changed, 25 insertions, 10 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 364068f61a..4406e4aba2 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp @@ -37,7 +37,7 @@ #include <windows.h> #endif -#define DEFAULT_LANG "English (C)" +#define DEFAULT_LANG "English (en)" Config::Config(QWidget *parent,int index) : QDialog(parent) { @@ -56,14 +56,13 @@ Config::Config(QWidget *parent,int index) : QDialog(parent) QStringList langs = findLanguageFiles(); for(int i = 0; i < langs.size(); ++i) lang.insert(languageName(langs.at(i)) + tr(" (%1)").arg(langs.at(i)), langs.at(i)); - lang.insert(DEFAULT_LANG, ""); + lang.insert(DEFAULT_LANG, "en"); QMap<QString, QString>::const_iterator i = lang.constBegin(); while (i != lang.constEnd()) { ui.listLanguages->addItem(i.key()); i++; } ui.listLanguages->setSelectionMode(QAbstractItemView::SingleSelection); - connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage())); ui.proxyPass->setEchoMode(QLineEdit::Password); ui.treeDevices->setAlternatingRowColors(true); ui.listLanguages->setAlternatingRowColors(true); @@ -109,7 +108,7 @@ void Config::accept() settings->setProxyType(proxyType); // language - if(settings->curLang() != language) + if(settings->curLang() != language && !language.isEmpty()) QMessageBox::information(this, tr("Language changed"), tr("You need to restart the application for the changed language to take effect.")); settings->setLang(language); @@ -188,13 +187,19 @@ void Config::setUserSettings() b = i.key(); break; } + else if(settings->curLang().startsWith(i.value(), Qt::CaseInsensitive)) { + // check if there is a base language (en -> en_US, etc.) + b = i.key(); + break; + } i++; } a = ui.listLanguages->findItems(b, Qt::MatchExactly); - if(a.size() <= 0) - a = ui.listLanguages->findItems(DEFAULT_LANG, Qt::MatchExactly); if(a.size() > 0) ui.listLanguages->setCurrentItem(a.at(0)); + // don't connect before language list has been set up to prevent + // triggering the signal by selecting the saved language. + connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage())); // devices tab ui.mountPoint->setText(QDir::toNativeSeparators(settings->mountpoint())); diff --git a/rbutil/rbutilqt/main.cpp b/rbutil/rbutilqt/main.cpp index b8419c00a3..f1b4c8d5fd 100644 --- a/rbutil/rbutilqt/main.cpp +++ b/rbutil/rbutilqt/main.cpp @@ -37,12 +37,16 @@ int main( int argc, char ** argv ) { user = new QSettings(absolutePath + "/RockboxUtility.ini", QSettings::IniFormat, 0); else user = new QSettings(QSettings::IniFormat, QSettings::UserScope, "rockbox.org", "RockboxUtility"); + QString applang = QLocale::system().name(); QTranslator translator; // install translator if(!user->value("lang", "").toString().isEmpty()) { - if(!translator.load("rbutil_" + user->value("lang").toString(), absolutePath)) - translator.load("rbutil_" + user->value("lang").toString(), ":/lang"); - QLocale::setDefault(user->value("lang").toString()); + applang = user->value("lang", "").toString(); + } + if(!applang.isEmpty()) { + if(!translator.load("rbutil_" + applang, absolutePath)) + translator.load("rbutil_" + applang, ":/lang"); + QLocale::setDefault(applang); } delete user; app.installTranslator(&translator); diff --git a/rbutil/rbutilqt/rbsettings.cpp b/rbutil/rbutilqt/rbsettings.cpp index 38ed542ee7..d1f90ea7f6 100644 --- a/rbutil/rbutilqt/rbsettings.cpp +++ b/rbutil/rbutilqt/rbsettings.cpp @@ -252,7 +252,13 @@ QString RbSettings::curVoiceName() QString RbSettings::curLang() { - return userSettings->value("lang").toString(); + // QSettings::value only returns the default when the setting + // doesn't exist. Make sure to return the system language if + // the language in the configuration is present but empty too. + QString lang = userSettings->value("lang").toString(); + if(lang.isEmpty()) + lang = QLocale::system().name(); + return lang; } QString RbSettings::curEncoder() |