-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.cpp
66 lines (53 loc) · 1.85 KB
/
main.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
#include <QTranslator>
#include <QSettings>
int main(int argc, char *argv[])
{
// Application is scaled based on screen's DPI.
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
QApplication a(argc, argv);
QApplication::setApplicationName("openChecksum");
QApplication::setApplicationVersion("0.7.2");
QApplication::setOrganizationName("D-25");
QApplication::setOrganizationDomain("http://d-25.net");
QApplication::setWindowIcon(QIcon(":/icons/ico_windows"));
/*
* Load a new language.
* To make it happen, the language inside the Resource file MUST BE
* named with an alias (for example: language_en_EN, language_fr_FR).
* It automatically change during startup of the application based off the system settings.
*
* To make a new language, first edit the .pro file, then make a new language using the tools of QT Creator.
*
*/
QSettings settings("D-25" ,"openChecksum");
int languageSelected = settings.value("language", 0).toInt();
QTranslator language;
switch (languageSelected)
{
case 1: // Italian.
{
language.load(":/languages/language_it_IT.qm");
a.installTranslator(&language);
break;
}
case 2: // English.
{
language.load(":/languages/language_en_EN.qm");
a.installTranslator(&language);
break;
}
default: // Detected by system settings or unknown value.
{
language.load(":/languages/language_" + QLocale::system().name() + ".qm");
a.installTranslator(&language);
qDebug() << "Language loaded: qrc://languages/language_" + QLocale::system().name() + ".qm";
break;
}
}
MainWindow w;
w.show();
return a.exec();
}