-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
55 lines (47 loc) · 1.91 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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtQml>
#include <QWindow>
#include <QFile>
#include <ircclient.h>
QFile logFile("derpy.log");
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QString logMessage;
switch (type) {
case QtDebugMsg:
logMessage = QStringLiteral("Debug: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function);
break;
case QtInfoMsg:
logMessage = QStringLiteral("Info: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function);
break;
case QtWarningMsg:
logMessage = QStringLiteral("Warning: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function);
break;
case QtCriticalMsg:
logMessage = QStringLiteral("Critical: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function);
break;
case QtFatalMsg:
logMessage = QStringLiteral("Fatal: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function);
logFile.write(logMessage.toUtf8());
logFile.flush();
abort();
}
logFile.write(logMessage.toUtf8());
logFile.flush();
}
int main(int argc, char *argv[])
{
logFile.open(QIODevice::WriteOnly | QIODevice:: Truncate);
qInstallMessageHandler(myMessageOutput);
QGuiApplication app(argc, argv);
qmlRegisterType<IrcClient>("IrcClient", 1, 0, "IrcClient");
QQmlApplicationEngine engine;
// engine.addImportPath("qrc:/plugins/qml"); // Why doesn't it work with dynamic build?
engine.load(QUrl(QStringLiteral("qrc:/qml/welcome.qml")));
// if(engine.rootObjects().first()->isWindowType()) {
// QWindow *window = qobject_cast<QWindow *>( engine.rootObjects().first() );
// window->setFlags(Qt::FramelessWindowHint);
// }
return app.exec();
}