summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2017-08-05 17:26:40 +0200
committerXaviDCR92 <xavi.dcr@gmail.com>2017-08-05 17:26:40 +0200
commit1c3712dfa33757b11ff9b3082903e92f038e7b3d (patch)
tree57d703f8962bce0ac7184bc0941ea73d0fd0b33d /main.cpp
parent51119d11fe6e9096861e1aeb7c3a03835710058b (diff)
* Added CLI support for QPSXSerial. Use "--help" information when executing QPSXSerial for further reference.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index 748160a..65b08d7 100644
--- a/main.cpp
+++ b/main.cpp
@@ -4,8 +4,40 @@
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
- QPSXSerial w;
- w.show();
+
+ QStringList param_list;
+
+ for(int i = 1; i < argc; i++)
+ {
+ param_list.append(argv[i]);
+ }
+
+ QPSXSerial* w;
+
+ if(param_list.isEmpty() == true)
+ {
+ w = new QPSXSerial(0, GUI_APP);
+ }
+ else
+ {
+ w = new QPSXSerial(0, CLI_APP);
+ }
+
+ w->setParamList(param_list);
+
+ if(param_list.isEmpty() == true)
+ {
+ w->show();
+ }
+ else
+ {
+ // This will cause the application to exit when
+ // the task signals finished.
+ QObject::connect(w, SIGNAL(finished(void)), &a, SLOT(quit(void)));
+
+ // This will run the task from the application event loop.
+ QTimer::singleShot(0, w, SLOT(cli_run()));
+ }
return a.exec();
}