diff options
Diffstat (limited to 'rbutil/rbutilqt/configure.cpp')
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 4a6fb67a43..d1a5faee24 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <tchar.h> | 39 | #include <tchar.h> |
40 | #include <windows.h> | 40 | #include <windows.h> |
41 | #endif | 41 | #endif |
42 | #include "rbutilqt.h" | ||
42 | 43 | ||
43 | #define DEFAULT_LANG "English (en)" | 44 | #define DEFAULT_LANG "English (en)" |
44 | #define DEFAULT_LANG_CODE "en" | 45 | #define DEFAULT_LANG_CODE "en" |
@@ -147,13 +148,6 @@ void Config::accept() | |||
147 | else proxyType = "manual"; | 148 | else proxyType = "manual"; |
148 | RbSettings::setValue(RbSettings::ProxyType, proxyType); | 149 | RbSettings::setValue(RbSettings::ProxyType, proxyType); |
149 | 150 | ||
150 | // language | ||
151 | if(RbSettings::value(RbSettings::Language).toString() != language | ||
152 | && !language.isEmpty()) { | ||
153 | QMessageBox::information(this, tr("Language changed"), | ||
154 | tr("You need to restart the application for the changed language " | ||
155 | "to take effect.")); | ||
156 | } | ||
157 | RbSettings::setValue(RbSettings::Language, language); | 151 | RbSettings::setValue(RbSettings::Language, language); |
158 | 152 | ||
159 | // mountpoint | 153 | // mountpoint |
@@ -563,10 +557,36 @@ QString Config::languageName(const QString &qmFile) | |||
563 | void Config::updateLanguage() | 557 | void Config::updateLanguage() |
564 | { | 558 | { |
565 | qDebug() << "[Config] update selected language"; | 559 | qDebug() << "[Config] update selected language"; |
560 | |||
561 | // remove all old translators | ||
562 | for(int i = 0; i < RbUtilQt::translators.size(); ++i) { | ||
563 | qApp->removeTranslator(RbUtilQt::translators.at(i)); | ||
564 | // do not delete old translators, this confuses Qt. | ||
565 | } | ||
566 | RbUtilQt::translators.clear(); | ||
566 | QList<QListWidgetItem*> a = ui.listLanguages->selectedItems(); | 567 | QList<QListWidgetItem*> a = ui.listLanguages->selectedItems(); |
567 | if(a.size() > 0) | 568 | if(a.size() > 0) |
568 | language = lang.value(a.at(0)->text()); | 569 | language = lang.value(a.at(0)->text()); |
569 | qDebug() << "[Config] new language:" << language; | 570 | qDebug() << "[Config] new language:" << language; |
571 | |||
572 | QString applang = QLocale::system().name(); | ||
573 | QTranslator *translator = new QTranslator(qApp); | ||
574 | QTranslator *qttrans = new QTranslator(qApp); | ||
575 | QString absolutePath = QCoreApplication::instance()->applicationDirPath(); | ||
576 | |||
577 | if(!translator->load("rbutil_" + language, absolutePath)) | ||
578 | translator->load("rbutil_" + language, ":/lang"); | ||
579 | if(!qttrans->load("qt_" + language, | ||
580 | QLibraryInfo::location(QLibraryInfo::TranslationsPath))) | ||
581 | qttrans->load("qt_" + language, ":/lang"); | ||
582 | |||
583 | qApp->installTranslator(translator); | ||
584 | qApp->installTranslator(qttrans); | ||
585 | RbUtilQt::translators.append(translator); | ||
586 | RbUtilQt::translators.append(qttrans); | ||
587 | |||
588 | QLocale::setDefault(language); | ||
589 | |||
570 | } | 590 | } |
571 | 591 | ||
572 | 592 | ||
@@ -878,3 +898,13 @@ void Config::configEnc() | |||
878 | updateEncState(); | 898 | updateEncState(); |
879 | } | 899 | } |
880 | 900 | ||
901 | |||
902 | void Config::changeEvent(QEvent *e) | ||
903 | { | ||
904 | if(e->type() == QEvent::LanguageChange) { | ||
905 | ui.retranslateUi(this); | ||
906 | } else { | ||
907 | QWidget::changeEvent(e); | ||
908 | } | ||
909 | } | ||
910 | |||