summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorDaMichel <mw.pub@welter-4d.de>2016-09-08 16:43:12 +0200
committerDaMichel <mw.pub@welter-4d.de>2016-09-08 16:43:12 +0200
commit77cf67d61c8f6ae7ec00fd069b0e6586927069a3 (patch)
tree5cdb392bca39cdb48725d3dae45120f38c626fa8 /logic
parent6c72e89a8b3be6d453d03d74b9de4208d155a93f (diff)
tracklogging: begone file selector gui. Now a file select dialog will pop up when the tracker starts.
Diffstat (limited to 'logic')
-rw-r--r--logic/work.cpp36
-rw-r--r--logic/work.hpp2
2 files changed, 26 insertions, 12 deletions
diff --git a/logic/work.cpp b/logic/work.cpp
index c369921c..c5fcad9a 100644
--- a/logic/work.cpp
+++ b/logic/work.cpp
@@ -1,18 +1,38 @@
#include "work.hpp"
+#include "opentrack-library-path.h"
#include <QMessageBox>
+#include <QFileDialog>
-std::shared_ptr<TrackLogger> Work::make_logger(const main_settings &s)
+static QString browse_datalogging_file(main_settings &s)
+{
+ QString filename = s.tracklogging_filename;
+ if (filename.isEmpty())
+ filename = OPENTRACK_BASE_PATH;
+ /* Sometimes this function freezes the app before opening the dialog.
+ Might be related to https://forum.qt.io/topic/49209/qfiledialog-getopenfilename-hangs-in-windows-when-using-the-native-dialog/8
+ and be a known problem. Possible solution is to use the QFileDialog::DontUseNativeDialog flag.
+ Since the freeze is apparently random, I'm not sure it helped.
+ */
+ QString newfilename = QFileDialog::getSaveFileName(nullptr, QFileDialog::tr("Select Filename"), filename, QFileDialog::tr("CSV File (*.csv)"), nullptr); //, QFileDialog::DontUseNativeDialog);
+ if (!newfilename.isEmpty())
+ {
+ s.tracklogging_filename = newfilename;
+ }
+ // dialog likes to mess with current directory
+ QDir::setCurrent(OPENTRACK_BASE_PATH);
+ return newfilename;
+}
+
+std::shared_ptr<TrackLogger> Work::make_logger(main_settings &s)
{
if (s.tracklogging_enabled)
{
+ QString filename = browse_datalogging_file(s);
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);
+ // The user probably canceled the file dialog. In this case we don't want to do anything.
}
else
{
@@ -27,12 +47,6 @@ std::shared_ptr<TrackLogger> Work::make_logger(const main_settings &s)
}
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;
}
}
diff --git a/logic/work.hpp b/logic/work.hpp
index bf5b5b15..c29a53b0 100644
--- a/logic/work.hpp
+++ b/logic/work.hpp
@@ -39,5 +39,5 @@ struct OPENTRACK_LOGIC_EXPORT Work
void reload_shortcuts();
private:
- static std::shared_ptr<TrackLogger> make_logger(const main_settings &s);
+ static std::shared_ptr<TrackLogger> make_logger(main_settings &s);
};