diff options
Diffstat (limited to 'facetracknoir/ui.cpp')
-rw-r--r-- | facetracknoir/ui.cpp | 72 |
1 files changed, 12 insertions, 60 deletions
diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 984901f6..15fdd308 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -9,6 +9,8 @@ #include "ui.h" #include "opentrack/tracker.h" #include "opentrack/options.hpp" +#include "ftnoir_tracker_pt/ftnoir_tracker_pt.h" +#include "ftnoir_filter_accela/ftnoir_filter_accela.h" #include "facetracknoir/new_file_dialog.h" #include <QFileDialog> #include <QDesktopServices> @@ -33,42 +35,23 @@ MainWindow::MainWindow() : ui.video_frame_label->setPixmap(no_feed_pixmap); connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); + connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); 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())); - - 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); - for (auto x : modules.filters()) - ui.iconcomboFilter->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); - tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); tie_setting(s.protocol_dll, ui.iconcomboProtocol); - tie_setting(s.filter_dll, ui.iconcomboFilter); - - connect(ui.iconcomboTrackerSource, - &QComboBox::currentTextChanged, - [&](QString) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); }); connect(ui.iconcomboProtocol, &QComboBox::currentTextChanged, [&](QString) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); }); - connect(ui.iconcomboFilter, - &QComboBox::currentTextChanged, - [&](QString) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); }); - connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); connect(ui.iconcomboProfile, SIGNAL(currentTextChanged(QString)), this, SLOT(profileSelected(QString))); @@ -246,8 +229,6 @@ void MainWindow::updateButtonState(bool running, bool inertialp) ui.btnStartTracker->setEnabled ( not_running ); ui.btnStopTracker->setEnabled ( running ); ui.iconcomboProtocol->setEnabled ( not_running ); - ui.iconcomboFilter->setEnabled ( not_running ); - ui.iconcomboTrackerSource->setEnabled(not_running); ui.video_frame_label->setVisible(not_running || inertialp); ui.profile_button->setEnabled(not_running); } @@ -263,7 +244,7 @@ void MainWindow::startTracker() { // tracker dtor needs run first work = nullptr; - libs = SelectedLibraries(ui.video_frame, current_tracker(), current_protocol(), current_filter()); + libs = SelectedLibraries(ui.video_frame, std::make_shared<Tracker_PT>(), current_protocol(), std::make_shared<FTNoIR_Filter>()); { double p[6] = {0,0,0, 0,0,0}; @@ -284,12 +265,6 @@ void MainWindow::startTracker() { reload_options(); - if (pTrackerDialog) - pTrackerDialog->register_tracker(libs.pTracker.get()); - - if (pFilterDialog) - pFilterDialog->register_filter(libs.pFilter.get()); - if (pProtocolDialog) pProtocolDialog->register_protocol(libs.pProtocol.get()); @@ -309,17 +284,9 @@ void MainWindow::stopTracker( ) { pose_update_timer.stop(); ui.pose_display->rotateBy(0, 0, 0, 0, 0, 0); - if (pTrackerDialog) - pTrackerDialog->unregister_tracker(); - if (pProtocolDialog) pProtocolDialog->unregister_protocol(); - if (pFilterDialog) - pFilterDialog->unregister_filter(); - - maybe_save(); - work = nullptr; libs = SelectedLibraries(); @@ -374,7 +341,7 @@ void MainWindow::set_title(const QString& game_title_) if (game_title_ != "") game_title = " :: " + game_title_; QString current = group::ini_filename(); - setWindowTitle(const_cast<const char*>(opentrack_version) + QStringLiteral(" :: ") + current + game_title); + setWindowTitle(QStringLiteral("TrackHat ") + const_cast<const char*>(opentrack_version) + QStringLiteral(" :: ") + current + game_title); } void MainWindow::showHeadPose() @@ -387,12 +354,12 @@ void MainWindow::showHeadPose() } template<typename t> -bool mk_dialog(mem<dylib> lib, mem<t>& orig) +bool mk_dialog(mem<dylib> lib, mem<t>* orig) { - if (orig && orig->isVisible()) + if (*orig && (*orig)->isVisible()) { - orig->show(); - orig->raise(); + (*orig)->show(); + (*orig)->raise(); return false; } @@ -402,34 +369,19 @@ bool mk_dialog(mem<dylib> lib, mem<t>& orig) dialog->setWindowFlags(Qt::Dialog); dialog->setFixedSize(dialog->size()); - orig = dialog; + *orig = dialog; dialog->show(); dialog->raise(); - QObject::connect(dialog.get(), &BaseDialog::closing, [&]() -> void { orig = nullptr; }); - return true; } return false; } - -void MainWindow::showTrackerSettings() -{ - if (mk_dialog(current_tracker(), pTrackerDialog) && libs.pTracker) - pTrackerDialog->register_tracker(libs.pTracker.get()); -} - void MainWindow::showProtocolSettings() { - if (mk_dialog(current_protocol(), pProtocolDialog) && libs.pProtocol) + if (mk_dialog(current_protocol(), &pProtocolDialog) && libs.pProtocol) pProtocolDialog->register_protocol(libs.pProtocol.get()); } - -void MainWindow::showFilterSettings() { - if (mk_dialog(current_filter(), pFilterDialog) && libs.pFilter) - pFilterDialog->register_filter(libs.pFilter.get()); -} - template<typename t, typename... Args> bool mk_window(mem<t>* place, Args... params) { @@ -450,7 +402,7 @@ bool mk_window(mem<t>* place, Args... params) } void MainWindow::show_options_dialog() { - if (mk_window(&options_widget)) + if (mk_window<OptionsDialog, State&>(&options_widget, static_cast<State&>(*this))) connect(options_widget.get(), SIGNAL(reload()), this, SLOT(reload_options())); } |