From 2bb80e1cc1f7755d44a99d19bf9b15f03f7bbbae Mon Sep 17 00:00:00 2001 From: Fabian Wickborn Date: Wed, 20 May 2015 15:02:47 +0200 Subject: Added command line option for automatic starts --- facetracknoir/main.cpp | 14 ++++++++++++++ facetracknoir/ui.cpp | 13 +++++++++++++ facetracknoir/ui.h | 1 + 3 files changed, 28 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index ae237b61..bbdfbc70 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -1,5 +1,6 @@ #include "ui.h" #include +#include #include #include #include @@ -28,8 +29,21 @@ int main(int argc, char** argv) QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); + QCommandLineParser p; + p.setApplicationDescription("opentrack - Head tracking software for MS Windows, Linux, and Apple OSX"); + p.addHelpOption(); + QCommandLineOption autostartOption(QStringList() << "a" << "autostart", "Load and start tracking", "profile"); + p.addOption(autostartOption); + p.process(app); + MainWindow w; + QString profile = p.value(autostartOption); + if (! profile.isEmpty() ) + { + w.open_and_run(profile); + } + w.show(); app.exec(); diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index c9a0b7b3..071a4126 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -25,6 +25,7 @@ #include "opentrack/tracker.h" #include "opentrack/options.hpp" #include +#include #ifndef _WIN32 # include @@ -211,6 +212,18 @@ void MainWindow::bindKeyboardShortcuts() ensure_tray(); } +void MainWindow::open_and_run(const QString &fileName) { + if (! fileName.isEmpty() && QFileInfo(fileName).exists()) { + { + QSettings settings(group::org); + settings.setValue(group::filename_key, remove_app_path(fileName)); + } + fill_profile_combobox(); + load_settings(); + QTimer::singleShot(0, this, SLOT(startTracker())); + } +} + void MainWindow::startTracker( ) { s.b->save(); load_settings(); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index cc7af1bf..92be8071 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -101,6 +101,7 @@ public slots: void shortcutToggled(); void shortcutZeroed(); void bindKeyboardShortcuts(); + void open_and_run(const QString &profile); private slots: void open(); void save(); -- cgit v1.2.3