summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/options-dialog.cpp26
-rw-r--r--gui/options-dialog.hpp3
-rw-r--r--gui/settings.ui82
-rw-r--r--gui/ui.cpp11
-rw-r--r--gui/ui.h1
5 files changed, 122 insertions, 1 deletions
diff --git a/gui/options-dialog.cpp b/gui/options-dialog.cpp
index 3b54ae9a..9dcb7879 100644
--- a/gui/options-dialog.cpp
+++ b/gui/options-dialog.cpp
@@ -11,6 +11,7 @@
#include <QPushButton>
#include <QLayout>
#include <QDialog>
+#include <QFileDialog>
static QString kopts_to_string(const key_opts& kopts)
{
@@ -72,6 +73,9 @@ OptionsDialog::OptionsDialog(std::function<void(bool)> pause_keybindings) :
tie_setting(main.center_method, ui.center_method);
+ tie_setting(main.tracklogging_enabled, ui.tracklogging_enabled);
+ tie_setting(main.tracklogging_filename, ui.tracklogging_filenameedit);
+
struct tmp
{
key_opts& opt;
@@ -102,6 +106,8 @@ OptionsDialog::OptionsDialog(std::function<void(bool)> pause_keybindings) :
connect(val.button, &QPushButton::pressed, this, [=]() -> void { bind_key(val.opt, val.label); });
}
}
+
+ connect(ui.tracklogging_fileselectbtn, SIGNAL(clicked()), this, SLOT(browse_datalogging_file()));
}
void OptionsDialog::bind_key(key_opts& kopts, QLabel* label)
@@ -163,3 +169,23 @@ void OptionsDialog::doCancel()
close();
}
+void OptionsDialog::browse_datalogging_file()
+{
+ QString filename = ui.tracklogging_filenameedit->text();
+ if (filename.isEmpty())
+ filename = QDir::currentPath();
+ /* 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(this, tr("Select Filename"), filename, tr("CSV File (*.csv)"), nullptr, QFileDialog::DontUseNativeDialog);
+ if (!newfilename.isEmpty())
+ ui.tracklogging_filenameedit->setText(newfilename);
+}
+
+void OptionsDialog::update_widgets_states(bool tracker_is_running)
+{
+ ui.tracklogging_enabled->setEnabled(!tracker_is_running);
+ ui.tracklogging_fileselectbtn->setEnabled(!tracker_is_running);
+} \ No newline at end of file
diff --git a/gui/options-dialog.hpp b/gui/options-dialog.hpp
index 66386a79..f84ee8f6 100644
--- a/gui/options-dialog.hpp
+++ b/gui/options-dialog.hpp
@@ -13,6 +13,8 @@ signals:
void saving();
public:
OptionsDialog(std::function<void(bool)> pause_keybindings);
+public slots:
+ void update_widgets_states(bool tracker_is_running);
private:
main_settings main;
std::function<void(bool)> pause_keybindings;
@@ -22,4 +24,5 @@ private slots:
void doOK();
void doCancel();
void bind_key(key_opts &kopts, QLabel* label);
+ void browse_datalogging_file();
};
diff --git a/gui/settings.ui b/gui/settings.ui
index 4654dd85..9c573da2 100644
--- a/gui/settings.ui
+++ b/gui/settings.ui
@@ -33,7 +33,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -1205,6 +1205,86 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="groupBox_10">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Data Logging</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="tracklogging_label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Record pose data in a csv file. WARNING: overwrites file contents without warning every time the tracker is started.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="tracklogging_enabled">
+ <property name="text">
+ <string>Enable</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="tracklogging_fileselectbtn">
+ <property name="text">
+ <string>Select File ...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="tracklogging_filenameedit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="acceptDrops">
+ <bool>true</bool>
+ </property>
+ <property name="inputMask">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string notr="true"/>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/gui/ui.cpp b/gui/ui.cpp
index 85d5d029..94fd0cbf 100644
--- a/gui/ui.cpp
+++ b/gui/ui.cpp
@@ -285,6 +285,7 @@ void MainWindow::reload_options()
ensure_tray();
}
+
void MainWindow::startTracker()
{
if (work)
@@ -331,6 +332,12 @@ void MainWindow::startTracker()
// trackers take care of layout state updates
const bool is_inertial = ui.video_frame->layout() == nullptr;
updateButtonState(true, is_inertial);
+
+ // Update the state of the options window directly.
+ // Might be better to emit signals and allow the options window
+ // to connect its slots to them (?)
+ if (options_widget)
+ options_widget->update_widgets_states(true);
ui.btnStopTracker->setFocus();
}
@@ -364,6 +371,9 @@ void MainWindow::stopTracker()
display_pose(p, p);
}
updateButtonState(false, false);
+
+ if (options_widget)
+ options_widget->update_widgets_states(false);
set_title();
@@ -495,6 +505,7 @@ void MainWindow::show_options_dialog()
if (mk_window(&options_widget, [&](bool flag) -> void { set_keys_enabled(!flag); }))
{
connect(options_widget.get(), &OptionsDialog::saving, this, &MainWindow::reload_options);
+ options_widget->update_widgets_states(work != nullptr);
}
}
diff --git a/gui/ui.h b/gui/ui.h
index 7415d3d4..d6f5e400 100644
--- a/gui/ui.h
+++ b/gui/ui.h
@@ -102,6 +102,7 @@ private slots:
void startTracker();
void stopTracker();
void reload_options();
+
signals:
void emit_start_tracker();
void emit_stop_tracker();