-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (41 loc) · 1.62 KB
/
main.cpp
File metadata and controls
53 lines (41 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "viewselectordialog.h"
#include "mainwindow.h"
#include <QApplication>
#include <QTranslator>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//MainWindow w;
//w.show();
//ViewSelectorDialog d;
//d.show();
QDir path(QApplication::applicationDirPath());
QSettings *settings = new QSettings(path.absoluteFilePath("settings.ini"),QSettings::IniFormat);
QString language = settings->value("language").toString();
if(language != "en") {
QTranslator translator;
// :/translations/labtool_de.ts
QDir transDir(":/translations");
QStringList fileNames = transDir.entryList(QStringList("*.qm"), QDir::Files,
QDir::Name);
qDebug() << "Translation: got file names " << fileNames;
QMap<QString,QString> fileMap;
for (QString fileName : fileNames) {
QString path = transDir.filePath(fileName);
QString name = fileName.sliced(8,2);
qDebug() << "Inserting path " << path << " for translation " << name;
fileMap.insert(name,path);
}
qDebug() << "loading language: " << language;
const QString &qmlFile = fileMap.value(language);
qDebug() << "loading qml file: " << qmlFile;
if(translator.load(qmlFile)) {
a.installTranslator(&translator);
//QCoreApplication::installTranslator(&translator);
qDebug() << "installed translator";
}
}
MainWindow main;
main.show();
return a.exec();
}