summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/configure.cpp44
-rw-r--r--rbutil/rbutilqt/configure.h1
-rw-r--r--rbutil/rbutilqt/createvoicewindow.cpp10
-rw-r--r--rbutil/rbutilqt/createvoicewindow.h1
-rw-r--r--rbutil/rbutilqt/installtalkwindow.cpp10
-rw-r--r--rbutil/rbutilqt/installtalkwindow.h3
-rw-r--r--rbutil/rbutilqt/installwindow.cpp8
-rw-r--r--rbutil/rbutilqt/installwindow.h1
-rw-r--r--rbutil/rbutilqt/main.cpp6
-rw-r--r--rbutil/rbutilqt/preview.cpp10
-rw-r--r--rbutil/rbutilqt/preview.h1
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp12
-rw-r--r--rbutil/rbutilqt/rbutilqt.h6
-rw-r--r--rbutil/rbutilqt/sysinfo.cpp9
-rw-r--r--rbutil/rbutilqt/sysinfo.h5
-rw-r--r--rbutil/rbutilqt/systrace.cpp10
-rw-r--r--rbutil/rbutilqt/systrace.h3
-rw-r--r--rbutil/rbutilqt/themesinstallwindow.cpp10
-rw-r--r--rbutil/rbutilqt/themesinstallwindow.h1
-rw-r--r--rbutil/rbutilqt/uninstallwindow.cpp10
-rw-r--r--rbutil/rbutilqt/uninstallwindow.h2
21 files changed, 151 insertions, 12 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 @@
#include <tchar.h>
#include <windows.h>
#endif
+#include "rbutilqt.h"
#define DEFAULT_LANG "English (en)"
#define DEFAULT_LANG_CODE "en"
@@ -147,13 +148,6 @@ void Config::accept()
else proxyType = "manual";
RbSettings::setValue(RbSettings::ProxyType, proxyType);
- // language
- if(RbSettings::value(RbSettings::Language).toString() != language
- && !language.isEmpty()) {
- QMessageBox::information(this, tr("Language changed"),
- tr("You need to restart the application for the changed language "
- "to take effect."));
- }
RbSettings::setValue(RbSettings::Language, language);
// mountpoint
@@ -563,10 +557,36 @@ QString Config::languageName(const QString &qmFile)
void Config::updateLanguage()
{
qDebug() << "[Config] update selected language";
+
+ // remove all old translators
+ for(int i = 0; i < RbUtilQt::translators.size(); ++i) {
+ qApp->removeTranslator(RbUtilQt::translators.at(i));
+ // do not delete old translators, this confuses Qt.
+ }
+ RbUtilQt::translators.clear();
QList<QListWidgetItem*> a = ui.listLanguages->selectedItems();
if(a.size() > 0)
language = lang.value(a.at(0)->text());
qDebug() << "[Config] new language:" << language;
+
+ QString applang = QLocale::system().name();
+ QTranslator *translator = new QTranslator(qApp);
+ QTranslator *qttrans = new QTranslator(qApp);
+ QString absolutePath = QCoreApplication::instance()->applicationDirPath();
+
+ if(!translator->load("rbutil_" + language, absolutePath))
+ translator->load("rbutil_" + language, ":/lang");
+ if(!qttrans->load("qt_" + language,
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+ qttrans->load("qt_" + language, ":/lang");
+
+ qApp->installTranslator(translator);
+ qApp->installTranslator(qttrans);
+ RbUtilQt::translators.append(translator);
+ RbUtilQt::translators.append(qttrans);
+
+ QLocale::setDefault(language);
+
}
@@ -878,3 +898,13 @@ void Config::configEnc()
updateEncState();
}
+
+void Config::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QWidget::changeEvent(e);
+ }
+}
+
diff --git a/rbutil/rbutilqt/configure.h b/rbutil/rbutilqt/configure.h
index fcfa9cbe7d..13451952ac 100644
--- a/rbutil/rbutilqt/configure.h
+++ b/rbutil/rbutilqt/configure.h
@@ -52,6 +52,7 @@ class Config : public QDialog
QUrl proxy;
QString mountpoint;
void updateCacheInfo(QString);
+ void changeEvent(QEvent *event);
private slots:
void setNoProxy(bool);
diff --git a/rbutil/rbutilqt/createvoicewindow.cpp b/rbutil/rbutilqt/createvoicewindow.cpp
index 7d51b90805..40f0457cbe 100644
--- a/rbutil/rbutilqt/createvoicewindow.cpp
+++ b/rbutil/rbutilqt/createvoicewindow.cpp
@@ -132,3 +132,13 @@ void CreateVoiceWindow::saveSettings(void)
ui.wavtrimthreshold->value());
RbSettings::sync();
}
+
+void CreateVoiceWindow::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QWidget::changeEvent(e);
+ }
+}
+
diff --git a/rbutil/rbutilqt/createvoicewindow.h b/rbutil/rbutilqt/createvoicewindow.h
index 9294004676..7223fce9aa 100644
--- a/rbutil/rbutilqt/createvoicewindow.h
+++ b/rbutil/rbutilqt/createvoicewindow.h
@@ -46,6 +46,7 @@ class CreateVoiceWindow : public QDialog
void settingsUpdated(void);
private:
+ void changeEvent(QEvent *event);
VoiceFileCreator* voicecreator;
Ui::CreateVoiceFrm ui;
ProgressLoggerGui* logger;
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp
index da4389bb78..19a974ab57 100644
--- a/rbutil/rbutilqt/installtalkwindow.cpp
+++ b/rbutil/rbutilqt/installtalkwindow.cpp
@@ -145,3 +145,13 @@ void InstallTalkWindow::updateSettings(void)
emit settingsUpdated();
}
+
+void InstallTalkWindow::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QWidget::changeEvent(e);
+ }
+}
+
diff --git a/rbutil/rbutilqt/installtalkwindow.h b/rbutil/rbutilqt/installtalkwindow.h
index e723f29af8..030f2553ed 100644
--- a/rbutil/rbutilqt/installtalkwindow.h
+++ b/rbutil/rbutilqt/installtalkwindow.h
@@ -33,7 +33,7 @@ class InstallTalkWindow : public QDialog
Q_OBJECT
public:
InstallTalkWindow(QWidget *parent = 0);
-
+
public slots:
void accept(void);
void change(void);
@@ -46,6 +46,7 @@ class InstallTalkWindow : public QDialog
void settingsUpdated(void);
private:
+ void changeEvent(QEvent *event);
TalkFileCreator* talkcreator;
Ui::InstallTalkFrm ui;
ProgressLoggerGui* logger;
diff --git a/rbutil/rbutilqt/installwindow.cpp b/rbutil/rbutilqt/installwindow.cpp
index c619bb5208..68217aa002 100644
--- a/rbutil/rbutilqt/installwindow.cpp
+++ b/rbutil/rbutilqt/installwindow.cpp
@@ -317,4 +317,12 @@ void InstallWindow::setDetailsArchived(bool show)
}
+void InstallWindow::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QWidget::changeEvent(e);
+ }
+}
diff --git a/rbutil/rbutilqt/installwindow.h b/rbutil/rbutilqt/installwindow.h
index 9fae7b5b4e..a74f47d5f3 100644
--- a/rbutil/rbutilqt/installwindow.h
+++ b/rbutil/rbutilqt/installwindow.h
@@ -46,6 +46,7 @@ class InstallWindow : public QDialog
ZipInstaller* installer;
QString m_backupName;
void resizeEvent(QResizeEvent*);
+ void changeEvent(QEvent *event);
void changeBackupPath(QString);
void updateBackupLocation(void);
diff --git a/rbutil/rbutilqt/main.cpp b/rbutil/rbutilqt/main.cpp
index 02c1e51d32..16767fc481 100644
--- a/rbutil/rbutilqt/main.cpp
+++ b/rbutil/rbutilqt/main.cpp
@@ -71,7 +71,13 @@ int main( int argc, char ** argv ) {
if(QObject::tr("LTR") == "RTL")
app.setLayoutDirection(Qt::RightToLeft);
+ // keep a list of installed translators. Needed to be able uninstalling them
+ // later again (in case of translation changes)
+ QList<QTranslator*> translators;
+ translators.append(&translator);
+ translators.append(&qttrans);
RbUtilQt window(0);
+ RbUtilQt::translators = translators;
window.show();
// app.connect( &app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
diff --git a/rbutil/rbutilqt/preview.cpp b/rbutil/rbutilqt/preview.cpp
index be1430c6a1..57b590966c 100644
--- a/rbutil/rbutilqt/preview.cpp
+++ b/rbutil/rbutilqt/preview.cpp
@@ -54,6 +54,16 @@ void PreviewDlg::leaveEvent(QEvent * event)
this->close();
}
+
+void PreviewDlg::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QWidget::changeEvent(e);
+ }
+}
+
PreviewLabel::PreviewLabel(QWidget * parent, Qt::WindowFlags f)
:QLabel(parent,f)
{
diff --git a/rbutil/rbutilqt/preview.h b/rbutil/rbutilqt/preview.h
index 14714af089..13f74360ee 100644
--- a/rbutil/rbutilqt/preview.h
+++ b/rbutil/rbutilqt/preview.h
@@ -36,6 +36,7 @@ public:
void setText(QString text);
private slots:
+ void changeEvent(QEvent *event);
void mouseMoveEvent(QMouseEvent * event);
void leaveEvent(QEvent * event);
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index b8ae77b91a..8be69287ac 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -57,6 +57,8 @@
#include <windows.h>
#endif
+QList<QTranslator*> RbUtilQt::translators;
+
RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
{
// startup log
@@ -1380,3 +1382,13 @@ void RbUtilQt::downloadUpdateDone(bool error)
}
}
+
+void RbUtilQt::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QMainWindow::changeEvent(e);
+ }
+}
+
diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h
index 42656540e6..869eb98f44 100644
--- a/rbutil/rbutilqt/rbutilqt.h
+++ b/rbutil/rbutilqt/rbutilqt.h
@@ -25,6 +25,8 @@
#include <QSettings>
#include <QTemporaryFile>
+#include <QList>
+#include <QTranslator>
#include "ui_rbutilqtfrm.h"
#include "httpget.h"
@@ -38,10 +40,12 @@ class RbUtilQt : public QMainWindow
public:
RbUtilQt(QWidget *parent = 0);
+ static QList<QTranslator*> translators;
private:
Ui::RbUtilQtFrm ui;
+ void changeEvent(QEvent *e);
void initDeviceNames(void);
QString deviceName(QString);
QString platform;
@@ -110,7 +114,7 @@ class RbUtilQt : public QMainWindow
void installPortable(void);
void updateInfo(void);
void updateTabs(int);
-
+
void checkUpdate(void);
void downloadUpdateDone(bool errror);
};
diff --git a/rbutil/rbutilqt/sysinfo.cpp b/rbutil/rbutilqt/sysinfo.cpp
index 1b2f44923b..864cc5788c 100644
--- a/rbutil/rbutilqt/sysinfo.cpp
+++ b/rbutil/rbutilqt/sysinfo.cpp
@@ -81,3 +81,12 @@ QString Sysinfo::getInfo()
}
+void Sysinfo::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QWidget::changeEvent(e);
+ }
+}
+
diff --git a/rbutil/rbutilqt/sysinfo.h b/rbutil/rbutilqt/sysinfo.h
index 5195113643..e59c98df12 100644
--- a/rbutil/rbutilqt/sysinfo.h
+++ b/rbutil/rbutilqt/sysinfo.h
@@ -31,13 +31,14 @@ class Sysinfo : public QDialog
public:
Sysinfo(QWidget *parent = 0);
-
+
static QString getInfo();
private:
+ void changeEvent(QEvent *event);
Ui::SysinfoFrm ui;
private slots:
- void updateSysinfo(void);
+ void updateSysinfo(void);
};
diff --git a/rbutil/rbutilqt/systrace.cpp b/rbutil/rbutilqt/systrace.cpp
index 5600eb042b..b9bc8ec04f 100644
--- a/rbutil/rbutilqt/systrace.cpp
+++ b/rbutil/rbutilqt/systrace.cpp
@@ -121,3 +121,13 @@ void SysTrace::flush(void)
}
}
+
+void SysTrace::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QWidget::changeEvent(e);
+ }
+}
+
diff --git a/rbutil/rbutilqt/systrace.h b/rbutil/rbutilqt/systrace.h
index f15e33c149..71aed0bd48 100644
--- a/rbutil/rbutilqt/systrace.h
+++ b/rbutil/rbutilqt/systrace.h
@@ -35,6 +35,7 @@ class SysTrace : public QDialog
static void save(QString filename = "");
private:
static void flush(void);
+ void changeEvent(QEvent *event);
Ui::SysTraceFrm ui;
static QString debugbuffer;
static QString lastmessage;
@@ -44,7 +45,7 @@ class SysTrace : public QDialog
void saveCurrentTrace(void);
void savePreviousTrace(void);
void refresh(void);
-
+
};
#endif
diff --git a/rbutil/rbutilqt/themesinstallwindow.cpp b/rbutil/rbutilqt/themesinstallwindow.cpp
index cb06b47b1f..272a7b3dca 100644
--- a/rbutil/rbutilqt/themesinstallwindow.cpp
+++ b/rbutil/rbutilqt/themesinstallwindow.cpp
@@ -359,3 +359,13 @@ void ThemesInstallWindow::accept()
}
+
+void ThemesInstallWindow::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QWidget::changeEvent(e);
+ }
+}
+
diff --git a/rbutil/rbutilqt/themesinstallwindow.h b/rbutil/rbutilqt/themesinstallwindow.h
index 949ffce4d5..e46a14453b 100644
--- a/rbutil/rbutilqt/themesinstallwindow.h
+++ b/rbutil/rbutilqt/themesinstallwindow.h
@@ -49,6 +49,7 @@ class ThemesInstallWindow : public QDialog
HttpGet igetter;
QTemporaryFile themesInfo;
void resizeEvent(QResizeEvent*);
+ void changeEvent(QEvent *event);
QByteArray imgData;
ProgressLoggerGui *logger;
ZipInstaller *installer;
diff --git a/rbutil/rbutilqt/uninstallwindow.cpp b/rbutil/rbutilqt/uninstallwindow.cpp
index fc47840b78..ab25fd2179 100644
--- a/rbutil/rbutilqt/uninstallwindow.cpp
+++ b/rbutil/rbutilqt/uninstallwindow.cpp
@@ -89,3 +89,13 @@ void UninstallWindow::UninstallMethodChanged(bool complete)
ui.smartGroupBox->setEnabled(true);
}
+
+void UninstallWindow::changeEvent(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ ui.retranslateUi(this);
+ } else {
+ QWidget::changeEvent(e);
+ }
+}
+
diff --git a/rbutil/rbutilqt/uninstallwindow.h b/rbutil/rbutilqt/uninstallwindow.h
index 7ac20b4d1e..2bdd4a653e 100644
--- a/rbutil/rbutilqt/uninstallwindow.h
+++ b/rbutil/rbutilqt/uninstallwindow.h
@@ -40,7 +40,9 @@ class UninstallWindow : public QDialog
private slots:
void selectionChanged();
void UninstallMethodChanged(bool complete);
+
private:
+ void changeEvent(QEvent *event);
Uninstaller* uninstaller;
Ui::UninstallFrm ui;
ProgressLoggerGui* logger;