diff options
author | DaMichel <mw.pub@welter-4d.de> | 2016-07-29 16:32:54 +0200 |
---|---|---|
committer | DaMichel <mw.pub@welter-4d.de> | 2016-07-29 16:32:54 +0200 |
commit | 12d2080865958cc07d37dddd28240f40423fb292 (patch) | |
tree | 240a7e71221279206ae1618e86cb66770913547a /opentrack-logic/work.cpp | |
parent | 884b3f013045d60d586c55338a76feb4dfa30c9b (diff) |
logger: it is definitely nicer to not have things all over the place
Diffstat (limited to 'opentrack-logic/work.cpp')
-rw-r--r-- | opentrack-logic/work.cpp | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/opentrack-logic/work.cpp b/opentrack-logic/work.cpp index e5b08c18..8d00270b 100644 --- a/opentrack-logic/work.cpp +++ b/opentrack-logic/work.cpp @@ -1,9 +1,50 @@ #include "work.hpp" +#include <QMessageBox> -Work::Work(Mappings& m, SelectedLibraries& libs, TrackLogger &logger, WId handle) : + +std::shared_ptr<TrackLogger> Work::make_logger(const main_settings &s) +{ + if (s.tracklogging_enabled) + { + if (static_cast<QString>(s.tracklogging_filename).isEmpty()) + { + QMessageBox::warning(nullptr, "Logging Error", + "No filename given for track logging. Proceeding without logging.", + QMessageBox::Ok, + QMessageBox::NoButton); + } + else + { + auto logger = std::make_shared<TrackLoggerCSV>(s.tracklogging_filename); + if (!logger->is_open()) + { + logger = nullptr; + QMessageBox::warning(nullptr, "Logging Error", + "Unable to open file: " + s.tracklogging_filename + ". Proceeding without logging.", + QMessageBox::Ok, + QMessageBox::NoButton); + } + else + { + /* As this function has the potential to fill up the hard drive + of the unwary with junk data, a warning is in order. */ + QMessageBox::warning(nullptr, "Logging Active", + "Just a heads up. You are recoding pose data to " + s.tracklogging_filename + "!", + QMessageBox::Ok, + QMessageBox::NoButton); + return logger; + } + } + } + return std::make_shared<TrackLogger>(); +} + + +Work::Work(Mappings& m, SelectedLibraries& libs, WId handle) : libs(libs), - tracker(std::make_shared<Tracker>(m, libs, logger)), + logger(make_logger(s)), + tracker(std::make_shared<Tracker>(m, libs, *logger)), sc(std::make_shared<Shortcuts>()), handle(handle), keys { |