-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (44 loc) · 1.3 KB
/
Copy pathmain.cpp
File metadata and controls
52 lines (44 loc) · 1.3 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
#include <QApplication>
#include <QProcess>
#include <QThread>
#include <QRegularExpression>
#include <QString>
#include "MudletInstaller.h"
#ifdef Q_OS_WINDOWS
#include "windows.h"
#include <iostream>
void msys2QtMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
Q_UNUSED(context)
switch (type) {
case QtDebugMsg:
case QtInfoMsg:
std::cout << msg.toUtf8().constData() << std::endl;
break;
case QtWarningMsg:
case QtCriticalMsg:
case QtFatalMsg:
std::cerr << msg.toUtf8().constData() << std::endl;
}
}
#endif
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
#ifdef Q_OS_WINDOWS
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
if (qgetenv("MSYSTEM").isNull()) {
// print stdout to console if Mudlet is started in a console in Windows
// credit to https://stackoverflow.com/a/41701133 for the workaround
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
} else {
// simply print qt logs into stdout and stderr if it's MSYS2
qInstallMessageHandler(msys2QtMessageHandler);
}
}
#endif
qDebug() << "Starting MudletDownloader...";
MudletInstaller app;
app.start();
return a.exec();
}