Merge branch 'hotfix/parse-commandline-platform-independent'
This commit is contained in:
commit
a479fa3581
1 changed files with 15 additions and 2 deletions
|
@ -1,18 +1,31 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QCommandLineParser>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
QCoreApplication::setApplicationName("ESGRAF 4-8");
|
||||||
|
QCoreApplication::setApplicationVersion("0.1");
|
||||||
|
|
||||||
|
QCommandLineParser cmdParser;
|
||||||
|
cmdParser.setApplicationDescription("ESGRAF 4-8");
|
||||||
|
cmdParser.addHelpOption();
|
||||||
|
cmdParser.addVersionOption();
|
||||||
|
cmdParser.addPositionalArgument("filename", "file to open");
|
||||||
|
|
||||||
|
cmdParser.process(app);
|
||||||
|
|
||||||
|
const QStringList args = cmdParser.positionalArguments();
|
||||||
|
|
||||||
std::unique_ptr<MainWindow> mainWindow;
|
std::unique_ptr<MainWindow> mainWindow;
|
||||||
if (argc < 2)
|
if (args.empty())
|
||||||
{
|
{
|
||||||
mainWindow = std::make_unique<MainWindow>(nullptr);
|
mainWindow = std::make_unique<MainWindow>(nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mainWindow = std::make_unique<MainWindow>(nullptr, argv[1]);
|
mainWindow = std::make_unique<MainWindow>(nullptr, args.at(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow->show();
|
mainWindow->show();
|
||||||
|
|
Loading…
Reference in a new issue