summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-17 21:35:31 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-17 21:35:31 +0200
commitfad4b316af2cde1a5988ed1bbdbc4ba5933e88df (patch)
treeb410c6f3233a631be6ef29348265c69b994c4582
parentcb33be1c50b68d6022f344ddac923c7aac3a11d5 (diff)
gui/main-window: reorganize ctor
-rw-r--r--gui/main-window.cpp117
1 files changed, 65 insertions, 52 deletions
diff --git a/gui/main-window.cpp b/gui/main-window.cpp
index 9cad0ef4..be7ddbe3 100644
--- a/gui/main-window.cpp
+++ b/gui/main-window.cpp
@@ -31,64 +31,69 @@ MainWindow::MainWindow() :
kbd_quit(QKeySequence("Ctrl+Q"), this)
{
ui.setupUi(this);
-
setFixedSize(size());
-
updateButtonState(false, false);
+ ui.btnStartTracker->setFocus();
+
+ refresh_config_list();
connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration()));
connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(show_options_dialog()));
connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings()));
connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showProtocolSettings()));
connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterSettings()));
+ connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker()));
+ connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker()));
+ connect(ui.iconcomboProfile, SIGNAL(currentTextChanged(QString)), this, SLOT(profile_selected(QString)));
- modules.filters().push_front(std::make_shared<dylib>("", dylib::Filter));
-
- for (auto x : modules.trackers())
- ui.iconcomboTrackerSource->addItem(x->icon, x->name);
-
- for (auto x : modules.protocols())
- ui.iconcomboProtocol->addItem(x->icon, x->name);
+ // fill dylib comboboxen
+ {
+ modules.filters().push_front(std::make_shared<dylib>("", dylib::Filter));
- for (auto x : modules.filters())
- ui.iconcomboFilter->addItem(x->icon, x->name);
+ for (mem<dylib>& x : modules.trackers())
+ ui.iconcomboTrackerSource->addItem(x->icon, x->name);
- refresh_config_list();
- connect(&config_list_timer, SIGNAL(timeout()), this, SLOT(refresh_config_list()));
- config_list_timer.start(1000 * 3);
+ for (mem<dylib>& x : modules.protocols())
+ ui.iconcomboProtocol->addItem(x->icon, x->name);
- tie_setting(m.tracker_dll, ui.iconcomboTrackerSource);
- tie_setting(m.protocol_dll, ui.iconcomboProtocol);
- tie_setting(m.filter_dll, ui.iconcomboFilter);
+ for (mem<dylib>& x : modules.filters())
+ ui.iconcomboFilter->addItem(x->icon, x->name);
+ }
- connect(ui.iconcomboTrackerSource,
- &QComboBox::currentTextChanged,
- [&](QString) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save_modules(); });
+ // dylibs
+ {
+ tie_setting(m.tracker_dll, ui.iconcomboTrackerSource);
+ tie_setting(m.protocol_dll, ui.iconcomboProtocol);
+ tie_setting(m.filter_dll, ui.iconcomboFilter);
- connect(ui.iconcomboProtocol,
- &QComboBox::currentTextChanged,
- [&](QString) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save_modules(); });
+ connect(ui.iconcomboTrackerSource,
+ &QComboBox::currentTextChanged,
+ [&](QString) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save_modules(); });
- connect(ui.iconcomboFilter,
- &QComboBox::currentTextChanged,
- [&](QString) -> void { if (pFilterDialog) pFilterDialog = nullptr; save_modules(); });
+ connect(ui.iconcomboProtocol,
+ &QComboBox::currentTextChanged,
+ [&](QString) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save_modules(); });
- connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker()));
- connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker()));
- connect(ui.iconcomboProfile, SIGNAL(currentTextChanged(QString)), this, SLOT(profile_selected(QString)));
+ connect(ui.iconcomboFilter,
+ &QComboBox::currentTextChanged,
+ [&](QString) -> void { if (pFilterDialog) pFilterDialog = nullptr; save_modules(); });
+ }
+ // timers
+ connect(&config_list_timer, SIGNAL(timeout()), this, SLOT(refresh_config_list()));
connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose()));
- connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit()));
-
- profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config()));
- profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config()));
- profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory()));
- ui.profile_button->setMenu(&profile_menu);
+ connect(&det_timer, SIGNAL(timeout()), this, SLOT(maybe_start_profile_from_executable()));
- kbd_quit.setEnabled(true);
+ // ctrl+q exits
+ connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit()));
- connect(&det_timer, SIGNAL(timeout()), this, SLOT(maybe_start_profile_from_executable()));
- det_timer.start(1000);
+ // profile menu
+ {
+ profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config()));
+ profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config()));
+ profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory()));
+ ui.profile_button->setMenu(&profile_menu);
+ }
if (!QFile(group::ini_pathname()).exists())
{
@@ -101,12 +106,6 @@ MainWindow::MainWindow() :
}
}
- if (group::ini_directory() == "")
- QMessageBox::warning(this,
- "Configuration not saved.",
- "Can't create configuration directory! Expect major malfunction.",
- QMessageBox::Ok, QMessageBox::NoButton);
-
connect(this, &MainWindow::emit_start_tracker,
this, [&]() -> void { qDebug() << "start tracker"; startTracker(); },
Qt::QueuedConnection);
@@ -123,17 +122,31 @@ MainWindow::MainWindow() :
this, [&]() -> void { qDebug() << "restart tracker"; stopTracker(); startTracker(); },
Qt::QueuedConnection);
- register_shortcuts();
+ // this sort of makes sense since the cancel button on the mapping window
+ // emits this signal.
+ connect(s.b_map.get(), &bundle_type::reloading, this, &MainWindow::reload_splines);
- ui.btnStartTracker->setFocus();
+ // tray
+ {
+ init_tray_menu();
- init_tray_menu();
+ connect(&s.tray_enabled,
+ static_cast<void (base_value::*)(bool)>(&base_value::valueChanged),
+ this,
+ [&](bool) { ensure_tray(); });
+ ensure_tray();
+ }
- connect(&s.tray_enabled,
- static_cast<void (base_value::*)(bool)>(&base_value::valueChanged),
- this,
- [&](bool) { ensure_tray(); });
- ensure_tray();
+ if (group::ini_directory() == "")
+ QMessageBox::warning(this,
+ "Configuration not saved.",
+ "Can't create configuration directory! Expect major malfunction.",
+ QMessageBox::Ok, QMessageBox::NoButton);
+
+ register_shortcuts();
+ det_timer.start(1000);
+ config_list_timer.start(1000 * 5);
+ kbd_quit.setEnabled(true);
}
void MainWindow::init_tray_menu()