-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
86 lines (71 loc) · 2.11 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "main_window.h"
#include "common-src/log/vs_editor_log.h"
#include <QApplication>
Q_DECLARE_OPAQUE_POINTER(const VSFrameRef *)
Q_DECLARE_OPAQUE_POINTER(VSNodeRef *)
MainWindow * pMainWindow = nullptr;
void handleQtMessage(QtMsgType a_type, const QMessageLogContext & a_context,
const QString & a_message)
{
QString prefix = "Qt debug";
QString style = LOG_STYLE_DEFAULT;
switch(a_type)
{
case QtDebugMsg:
prefix = "Qt debug";
style = LOG_STYLE_QT_DEBUG;
break;
#if(QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
case QtInfoMsg:
prefix = "Qt info";
style = LOG_STYLE_QT_INFO;
break;
#endif
case QtWarningMsg:
prefix = "Qt warning";
style = LOG_STYLE_QT_WARNING;
break;
case QtCriticalMsg:
prefix = "Qt critical";
style = LOG_STYLE_QT_CRITICAL;
break;
case QtFatalMsg:
prefix = "Qt fatal";
style = LOG_STYLE_QT_FATAL;
break;
default:
Q_ASSERT(false);
}
QString fullMessage = QString("%1: %2").arg(prefix).arg(a_message);
QString fileString(a_context.file);
QString lineString = QString::number(a_context.line);
QString functionString(a_context.function);
QString lineInfo = QString("\n(%1:%2").arg(fileString).arg(lineString);
if(!functionString.isEmpty())
lineInfo += QString(", %1").arg(functionString);
lineInfo += QString(")");
if(!fileString.isEmpty())
fullMessage += lineInfo;
pMainWindow->slotWriteLogMessage(fullMessage, style);
if(a_type == QtFatalMsg)
abort();
}
int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
#if (QT_VERSION_MAJOR < 6)
QApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
#endif
QApplication application(argc, argv);
// Make text in message box selectable
application.setStyleSheet(
"QMessageBox { messagebox-text-interaction-flags: 5; }");
qRegisterMetaType<const VSFrameRef *>("const VSFrameRef *");
qRegisterMetaType<VSNodeRef *>("VSNodeRef *");
pMainWindow = new MainWindow();
qInstallMessageHandler(handleQtMessage);
pMainWindow->show();
int exitCode = application.exec();
delete pMainWindow;
return exitCode;
}