-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.cpp
More file actions
85 lines (66 loc) · 2.44 KB
/
main.cpp
File metadata and controls
85 lines (66 loc) · 2.44 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
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
#include <QtWidgets>
#include <QLoggingCategory>
#include <QMessageLogContext>
#include <QString>
#include <QFile>
#include <QTextStream>
void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
Q_UNUSED(type);
Q_UNUSED(context);
if (msg.contains("QSocketNotifier"))
return;
QByteArray ba = msg.toLocal8Bit();
fprintf(stderr, "%s\n", ba.constData());
}
#include "mainwin.h"
#include "g2m.hpp"
#define APP_VERSION QString("2016")
#define APP_NAME QString("gcoder")
#define APP_NAME_FULL QString("GCoder")
#define APP_ORGANIZATION QString("gcoder.koppi.github.com")
int main(int argv, char **args)
{
qRegisterMetaType<QVector<canonLine*>>("QVector<canonLine*>");
qInstallMessageHandler(customMessageHandler);
QApplication *app;
// workaround for https://forum.qt.io/topic/53298/qcommandlineparser-to-select-gui-or-non-gui-mode
// On Linux: enable printing of version and help without DISPLAY variable set
bool runCore = false;
for (int i = 0; i < argv; i++) {
if (QString(args[i]) == "-h" ||
QString(args[i]) == "--help" ||
QString(args[i]) == "-v" ||
QString(args[i]) == "--version" ) {
runCore = true;
break;
}
}
if (runCore) {
app = static_cast<QApplication*>(new QCoreApplication(argv, args));
} else {
app = new QApplication(argv, args);
}
// end workaround
setlocale(LC_NUMERIC,"C");
//XXX app->setStyleSheet("QPlainTextEdit{ selection-background-color: darkblue } QWidget { font-size: 12pt; font-family: \"Courier\"; background-color: #00003B; color: #FFA700; font: bold }");
QCoreApplication::setOrganizationName(APP_ORGANIZATION);
QCoreApplication::setApplicationName(APP_NAME);
QCoreApplication::setApplicationVersion(APP_VERSION);
QCommandLineParser parser;
parser.setApplicationDescription(QCoreApplication::applicationName());
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("file", "The G-code file to open.");
parser.process(*app);
MainWindow *win;
if (!parser.positionalArguments().isEmpty()) {
win = new MainWindow(NULL, !parser.positionalArguments().isEmpty(), parser.positionalArguments().first());
} else {
win = new MainWindow();
}
win->show();
int ret = app->exec();
delete win;
delete app;
return ret;
}