-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
64 lines (58 loc) · 1.81 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
// ******************************************************
// * copyright (C) 2017 by Reinhardt Behm/[email protected]
// * All Rights reserved
// * created 1/24/2017 by behm
// ******************************************************
#include "mainwindow.h"
#include "config.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setApplicationName("Tachyon-4th-IDE");
app.setApplicationVersion("V1.9");
app.setOrganizationName("ibb-aviotec.com");
app.setWindowIcon(QIcon(":/logo/pics/useforthlogo-s.png"));
app.quitOnLastWindowClosed();
QString device;
QString filename;
uint baud;
// put this into a block to not have it during program lifetime.
{
QCommandLineParser parser;
parser.setApplicationDescription(app.applicationName());
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("filename", "initial file to load");
QCommandLineOption devOption(QStringList() << "d" << "device", "Serial device.", "port", Config::stringValue("hw/port", "prop.board"));
parser.addOption(devOption);
QCommandLineOption baudOption(QStringList() << "b" << "baudrate", "Serial baudrate.", "baud", Config::stringValue("hw/baud", "115200"));
parser.addOption(baudOption);
parser.process(app);
device = parser.value(devOption);
baud = parser.value(baudOption).toUInt();
if (! parser.positionalArguments().isEmpty())
{
filename = parser.positionalArguments().first();
}
QString dsn(":/style/styles.css");
QFile fcss(dsn);
if (fcss.open(QFile::ReadOnly))
{
QTextStream scss(&fcss);
app.setStyleSheet(scss.readAll());
}
else
{
qWarning() << Q_FUNC_INFO << fcss.fileName() << "not found";
}
}
MainWindow mw(device, baud);
if (! filename.isEmpty())
{
mw.loadFile(filename);
}
mw.show();
int rc = app.exec();
// qApp->closeAllWindows();
return rc;
}