summaryrefslogtreecommitdiffstats
path: root/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mainwindow.cpp')
-rw-r--r--mainwindow.cpp61
1 files changed, 58 insertions, 3 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 5a548db..8bc0a22 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -26,17 +26,17 @@ void MainWindow::on_actionPreferences_triggered()
tmp->setHeight(size().height());
tmp->setWidth(size().width());
- if(tmp->exec())
+ if (tmp->exec())
{
qDebug() << "DlgPreferences okay clicked.";
int width = tmp->Width();
int height = tmp->Height();
- if(width >= 100 && width <= 800 && height >= 100 && height <= 800)
+ if (width >= 100 && width <= 800 && height >= 100 && height <= 800)
{
qDebug() << "Resizing QMainWindow.";
- resize(width,height);
+ resize(width, height);
}
}
@@ -44,7 +44,62 @@ void MainWindow::on_actionPreferences_triggered()
}
+void MainWindow::on_actionLanguage_triggered()
+{
+ LanguageDialog *tmp = new LanguageDialog(this);
+
+ if (QLocale::system().language() == QLocale::German)
+ {
+ tmp->setLanguage(1);
+ }
+ else
+ {
+ tmp->setLanguage(0);
+ }
+
+ if (tmp->exec())
+ {
+ switch (tmp->language())
+ {
+ case 0:
+ qDebug() << "English";
+ loadLanguage(":/english.qm");
+
+ break;
+
+ case 1:
+ qDebug() << "German";
+ loadLanguage(":/german.qm");
+
+ break;
+ }
+ }
+}
+
+
void MainWindow::mouseMoveEvent(QMouseEvent *mouseEvent)
{
qDebug() << "MainWindow:" << mouseEvent->pos();
}
+
+void MainWindow::loadLanguage(const QString& rLanguageFile)
+{
+ // remove the old translator
+ qApp->removeTranslator(&m_translator);
+
+ // load the new translator
+ if (m_translator.load(rLanguageFile))
+ {
+ qApp->installTranslator(&m_translator);
+ }
+}
+
+void MainWindow::changeEvent(QEvent *event)
+{
+ if (event != 0 && event->type() == QEvent::LanguageChange)
+ {
+ ui->retranslateUi(this);
+ }
+
+ QMainWindow::changeEvent(event);
+}