diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-17 09:44:50 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-18 01:53:43 +0200 |
commit | be0ae02edeaf8c4320c217844b2c7fd507447335 (patch) | |
tree | fa634ad70976227fc436dd7dae08b41866f515d8 | |
parent | 6e6a432a701e9a57fe0b03ca835a61f4206f2d5e (diff) |
bundles are now reloaded when settings window is closed
This happens even if closed by alt+f4 or cancel button.
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | facetracknoir/ui.cpp | 18 | ||||
-rw-r--r-- | opentrack/plugin-api.hpp | 21 |
3 files changed, 25 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 56e035b3..3a21730e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,7 @@ macro(opentrack_library n dir) opentrack_module(${n} ${dir}) opentrack_qt(${n}) add_library(${n} SHARED ${${n}-all}) - target_link_libraries(${n} ${MY_QT_LIBS}) + target_link_libraries(${n} opentrack-api ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(${n} PROPERTIES LINK_FLAGS "${foolib_LINK} ${foolib_GNU-LINK} -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack/${version-script}-version-script.txt\"" diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 88699810..86996735 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -358,12 +358,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; } @@ -373,10 +373,12 @@ 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; } @@ -385,17 +387,17 @@ bool mk_dialog(mem<dylib> lib, mem<t>* orig) void MainWindow::showTrackerSettings() { - if (mk_dialog(current_tracker(), &pTrackerDialog) && libs.pTracker) + 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) + if (mk_dialog(current_filter(), pFilterDialog) && libs.pFilter) pFilterDialog->register_filter(libs.pFilter.get()); } diff --git a/opentrack/plugin-api.hpp b/opentrack/plugin-api.hpp index 714e69d9..021f5017 100644 --- a/opentrack/plugin-api.hpp +++ b/opentrack/plugin-api.hpp @@ -2,6 +2,7 @@ #include "export.hpp" #include <QString> +#include <QWidget> #include <QFrame> #include <QIcon> @@ -9,6 +10,15 @@ enum Axis { TX = 0, TY, TZ, Yaw, Pitch, Roll }; +class BaseDialog : public QWidget +{ + Q_OBJECT +public: + void closeEvent(QCloseEvent *) override { emit closing(); } +signals: + void closing(); +}; + #define OPENTRACK_DECLARE_PLUGIN_INTERNAL(ctor_class, ctor_ret_class, metadata_class, dialog_class, dialog_ret_class) \ extern "C" OPENTRACK_EXPORT ctor_ret_class* GetConstructor() \ { \ @@ -24,9 +34,9 @@ enum Axis { } // implement this in all plugins +// also you must link against "opentrack-api" in CMakeList.txt to avoid vtable link errors struct Metadata { -public: // plugin name to be displayed in the interface virtual QString name() = 0; // plugin icon, you can return an empty QIcon() @@ -38,7 +48,6 @@ public: // implement this in filters struct IFilter { -public: // optional destructor virtual ~IFilter() {} // perform filtering step. @@ -46,7 +55,7 @@ public: virtual void filter(const double *input, double *output) = 0; }; -struct IFilterDialog : public QWidget +struct IFilterDialog : public BaseDialog { // optional destructor virtual ~IFilterDialog() {} @@ -63,7 +72,6 @@ struct IFilterDialog : public QWidget // implement this in protocols struct IProtocol { -public: // optional destructor virtual ~IProtocol() {} // return true if protocol was properly initialized @@ -75,7 +83,7 @@ public: virtual QString game_name() = 0; }; -struct IProtocolDialog : public QWidget +struct IProtocolDialog : public BaseDialog { // optional destructor virtual ~IProtocolDialog() {} @@ -92,7 +100,6 @@ struct IProtocolDialog : public QWidget // implement this in trackers struct ITracker { -public: // optional destructor virtual ~ITracker() {} // start tracking, and grab a frame to display webcam video in, optionally @@ -101,7 +108,7 @@ public: virtual void data(double *data) = 0; }; -struct ITrackerDialog : public QWidget +struct ITrackerDialog : public BaseDialog { // optional destructor virtual ~ITrackerDialog() {} |