add dynamic language change support
add "en" ts
This commit is contained in:
@@ -154,6 +154,7 @@ void AboutWindow::changeEvent(QEvent *e) {
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
setWindowTitle(QApplication::applicationName() + " - " + tr("About"));
|
||||
break;
|
||||
case QEvent::FontChange:
|
||||
case QEvent::Polish:
|
||||
|
||||
@@ -119,6 +119,22 @@ void EMainWindow::timerEvent(QTimerEvent * e) {
|
||||
}
|
||||
|
||||
|
||||
void EMainWindow::changeEvent(QEvent * e) {
|
||||
QMainWindow::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
action_show_all_tools.setText(tr("Show all"));
|
||||
action_show_all_docks.setText(tr("Show all"));
|
||||
action_hide_all_tools.setText(tr("Hide all"));
|
||||
action_hide_all_docks.setText(tr("Hide all"));
|
||||
action_clear_recent->setText(tr("Clear recent list"));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMenu * EMainWindow::createPopupMenu() {
|
||||
QMenu * menuPopup = new QMenu;
|
||||
QWidgetAction * wa;
|
||||
|
||||
@@ -92,6 +92,7 @@ protected:
|
||||
void closeEvent(QCloseEvent * );
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void timerEvent(QTimerEvent * e);
|
||||
void changeEvent(QEvent * e);
|
||||
QMenu * createPopupMenu();
|
||||
void addToRecent(const QString & path);
|
||||
void prepareRecent();
|
||||
|
||||
@@ -91,6 +91,18 @@ bool ETabWidget::eventFilter(QObject * o, QEvent * e) {
|
||||
}
|
||||
|
||||
|
||||
void ETabWidget::changeEvent(QEvent * e) {
|
||||
QTabWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
retranslate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ETabWidget::buttonClicked() {
|
||||
QToolButton * s = qobject_cast<QToolButton * >(sender());
|
||||
if (s == 0) return;
|
||||
|
||||
@@ -49,6 +49,7 @@ private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void tabInserted(int) {emit countChanged();}
|
||||
void tabRemoved(int) {emit countChanged();}
|
||||
void changeEvent(QEvent * e);
|
||||
|
||||
struct TabButton {
|
||||
TabButton(int r, const QIcon & i, const QString & t) {role = r; icon = i; visible = true; srcToolTip = t; toolTip = QApplication::translate("MainWindow", t.toUtf8(), 0/*, QCoreApplication::UnicodeUTF8*/);}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "historyview.h"
|
||||
#include <QEvent>
|
||||
|
||||
|
||||
HistoryView::HistoryView(QWidget* parent): QListWidget(parent) {
|
||||
@@ -89,6 +90,18 @@ void HistoryView::checkLimit() {
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::changeEvent(QEvent * e) {
|
||||
QListWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
actions_[-1].text = tr("History cleared");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HistoryView::itemClicked(QListWidgetItem * item) {
|
||||
if (!active_) return;
|
||||
if (index == row(item) + 1) return;
|
||||
|
||||
@@ -65,6 +65,7 @@ private:
|
||||
};
|
||||
|
||||
void checkLimit();
|
||||
void changeEvent(QEvent * e);
|
||||
QString actionText(int action, int count_);
|
||||
|
||||
QMap<int, Action> actions_;
|
||||
|
||||
105
qad/application/lang/qad_application_en.ts
Normal file
105
qad/application/lang/qad_application_en.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en_US">
|
||||
<context>
|
||||
<name>AboutWindow</name>
|
||||
<message>
|
||||
<location filename="../aboutwindow.ui" line="14"/>
|
||||
<source> - About</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../aboutwindow.ui" line="41"/>
|
||||
<source>Versions</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../aboutwindow.ui" line="56"/>
|
||||
<source>Build</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../aboutwindow.ui" line="71"/>
|
||||
<source>Authors</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../aboutwindow.ui" line="100"/>
|
||||
<source>About Qt...</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../aboutwindow.ui" line="111"/>
|
||||
<source>OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../aboutwindow.cpp" line="33"/>
|
||||
<source>About</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EMainWindow</name>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="12"/>
|
||||
<source>Clear recent list</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="15"/>
|
||||
<location filename="../emainwindow.cpp" line="16"/>
|
||||
<source>Show all</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="17"/>
|
||||
<location filename="../emainwindow.cpp" line="18"/>
|
||||
<source>Hide all</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="136"/>
|
||||
<source>Toolbars</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="161"/>
|
||||
<source>Docks</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="379"/>
|
||||
<source>Select file to open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="388"/>
|
||||
<source>Select files to open</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="398"/>
|
||||
<source>Save changes%1?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="398"/>
|
||||
<source> in</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../emainwindow.cpp" line="411"/>
|
||||
<source>Select file to save</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>HistoryView</name>
|
||||
<message>
|
||||
<location filename="../historyview.cpp" line="16"/>
|
||||
<source>History cleared</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
@@ -31,7 +31,7 @@
|
||||
<message>
|
||||
<location filename="../aboutwindow.ui" line="111"/>
|
||||
<source>OK</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../aboutwindow.cpp" line="33"/>
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
lupdate ../ -ts qad_application_ru.ts
|
||||
lupdate ../ -ts qad_application_en.ts
|
||||
|
||||
@@ -49,6 +49,18 @@ void Ribbon::timerEvent(QTimerEvent * e) {
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::changeEvent(QEvent * e) {
|
||||
QToolBar::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
retranslate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::_resize() {
|
||||
return; // WARNING
|
||||
for (int i = 0; i < tab->count(); ++i) {
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void timerEvent(QTimerEvent * e);
|
||||
void changeEvent(QEvent *e);
|
||||
void _resize();
|
||||
void _setIconsSize();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user