-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
59 lines (54 loc) · 1.92 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
#include "mainwindow.h"
#include <QApplication>
#include <QTranslator>
// some stuff from stackoverflow
void myMessageOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
if(MainWindow::log == nullptr) {
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtInfoMsg:
fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
abort();
}
}
else {
switch (type) {
case QtDebugMsg:
case QtWarningMsg:
case QtCriticalMsg:
case QtInfoMsg:
if(MainWindow::log != nullptr) {
MainWindow::log->append(msg);
}
break;
case QtFatalMsg:
abort();
}
}
}
int main(int argc, char* argv[])
{
qInstallMessageHandler(myMessageOutput);
QApplication a(argc, argv);
QTranslator myTranslator;
if ( QLocale::system().name().contains("ru_RU") ) {
myTranslator.load("W3ModMerger_ru_RU", ":/translations");
}
a.installTranslator(&myTranslator);
MainWindow w;
w.show();
return a.exec();
}