-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
102 lines (86 loc) · 2.4 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "main.h"
#include "mainwindow.h"
#include "iniedit.h"
#include "build/version.h"
#include <QApplication>
#include <QtGui>
#include <QTextStream>
#include <QStandardPaths>
#include <QMessageBox>
QTextStream &qStdout()
{
static QTextStream ts(stdout);
return ts;
}
namespace GpxUiInfo
{
static QDir dirIni;
static QDir dirMachineIni;
void init()
{
#ifdef Q_OS_WIN
dirIni.setPath(QApplication::instance()->applicationDirPath());
dirMachineIni = dirIni;
#else
dirIni.setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
dirMachineIni = dirIni;
const char *sz = ".gpx";
if (!dirMachineIni.cd(sz)) {
dirMachineIni.mkdir(sz);
dirMachineIni.cd(sz);
}
#endif
}
const QDir &iniLocation()
{
return dirIni;
}
const QDir &machineIniLocation()
{
return dirMachineIni;
}
}
int main(int argc, char *argv[])
{
QApplication::setStyle("Fusion");
QApplication a(argc, argv);
a.setOrganizationName("MarkWal");
a.setOrganizationDomain("markwal.github.io");
a.setApplicationName("GpxUi " GPXUI_VERSION);
GpxUiInfo::init();
QCommandLineParser clp;
clp.setApplicationDescription("GpxUi is a graphical user interface for running GPX, a command line utility that converts .gcode to .x3g");
clp.addHelpOption();
clp.addVersionOption();
clp.addPositionalArgument("gcodefile", "Gcode file to translate to x3g");
SetupEvents se;
se.addOptions(clp);
clp.process(a);
const QStringList rgsArgs = clp.positionalArguments();
if (se.handleOptions(clp))
return 0;
/*
QString szPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QDir dir(szPath);
if (!szPath.isEmpty())
{
Slic3r s;
dir.cdUp();
dir.cd("slic3r/print");
QFile file(dir.filePath("medium.ini"));
QSettings settings(file.fileName(), QSettings::IniFormat);
s.append(file.fileName().toLatin1().data());
foreach (const QString &sKey, settings.childKeys()) {
s.append(QString("%1 = %2").arg(sKey, settings.value(sKey).toString()));
qDebug() << sKey;
qDebug() << settings.value(sKey);
}
s.exec();
}
*/
MainWindow w;
w.show();
if (rgsArgs.size() > 0)
w.setInputName(rgsArgs.at(0));
return a.exec();
}