-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
61 lines (51 loc) · 1.71 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
/**
* @licence app begin@
* Copyright (C) 2021 Alexander Wenzel
*
* This file is part of the DLT Relais project.
*
* \copyright This code is licensed under GPLv3.
*
* \author Alexander Wenzel <[email protected]>
*
* \file main.h
* @licence end@
*/
#include "dialog.h"
#include "version.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication::setOrganizationName("alexmucde");
QCoreApplication::setOrganizationDomain("github.com");
QCoreApplication::setApplicationName("DLTPower");
QCoreApplication::setApplicationVersion(DLT_POWER_VERSION);
QCommandLineParser parser;
parser.setApplicationDescription("Control Power in a test automation.");
const QCommandLineOption helpOption = parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("configuration", QCoreApplication::translate("main", "Configuration file."));
// Option Autostart
QCommandLineOption autostartOption("a", QCoreApplication::translate("main", "Autostart Communication"));
parser.addOption(autostartOption);
// Parse the Arguments
parser.process(a);
// Stop application if help is called
if(parser.isSet(helpOption))
return 1;
// set command line options
QString configuration;
if(parser.positionalArguments().size()>=1)
configuration = parser.positionalArguments().at(0);
qDebug() << "Option: configuration =" << configuration;
bool autostart= false;
autostart = parser.isSet(autostartOption);
qDebug() << "Option: -a =" << autostart;
// execute dialog
Dialog w(autostart,configuration);
w.show();
return a.exec();
}