diff options
39 files changed, 106 insertions, 115 deletions
diff --git a/compat/macros.hpp b/compat/macros.hpp index 564dcc8d..abe89c73 100644 --- a/compat/macros.hpp +++ b/compat/macros.hpp @@ -64,5 +64,10 @@ constexpr force_inline void static_warn<true>() {} #define static_warning(cond) \ static_warn<(cond)>(); \ +#define progn(...) (([&] { __VA_ARGS__ })()) +#define prog1(x, ...) (([&] { auto _ret1324 = (x); do { __VA_ARGS__; } while (0); return _ret1324; })()) + // end c++-only macros #endif + +#define once_only(...) do { static bool once__ = false; if (!once__) { once__ = true; __VA_ARGS__; } } while(false) diff --git a/compat/math.hpp b/compat/math.hpp index 5d80dace..014604e6 100644 --- a/compat/math.hpp +++ b/compat/math.hpp @@ -54,15 +54,15 @@ inline auto clamp(const t& val, const u& min, const w& max) } template<typename t> -inline int iround(const t& val) +inline auto iround(t val) -> std::enable_if_t<!std::is_integral_v<std::decay_t<t>>, t> { - return int(std::round(val)); + return (int) std::round(val); } template<typename t> -inline unsigned uround(const t& val) +inline auto uround(const t& val) -> std::enable_if_t<!std::is_integral_v<std::decay_t<t>>, t> { - return std::round(std::fmax(t(0), val)); + return (unsigned) std::fmax(0, std::round(val)); } #include "macros.hpp" diff --git a/compat/run-in-thread.hpp b/compat/run-in-thread.hpp index b425532e..4631fb0c 100644 --- a/compat/run-in-thread.hpp +++ b/compat/run-in-thread.hpp @@ -93,7 +93,7 @@ run_in_thread_sync(QObject* obj, F&& fun) QObject::connect(&src, &QObject::destroyed, obj, - [&]() { + [&] { traits::assign(ret, traits::call(fun)); sem.notify(); }, diff --git a/compat/time.hpp b/compat/time.hpp index c246a9e5..bc422abe 100644 --- a/compat/time.hpp +++ b/compat/time.hpp @@ -14,7 +14,6 @@ static inline constexpr auto time_cast(u&& in) } using secs = duration<double>; -using secs_ = duration<long>; using ms = duration<double, std::milli>; using us = duration<double, std::micro>; using ns = duration<double, std::nano>; diff --git a/csv/csv.cpp b/csv/csv.cpp index 8a5f5784..31f361a8 100644 --- a/csv/csv.cpp +++ b/csv/csv.cpp @@ -132,8 +132,8 @@ bool CSV::getGameData(int id, unsigned char* table, QString& gamename) { if (gameLine.at(6).compare(id_str, Qt::CaseInsensitive) == 0) { - const QString proto(std::move(gameLine.at(3))); - const QString name(std::move(gameLine.at(1))); + const QString& proto = gameLine.at(3); + const QString& name = gameLine.at(1); const QByteArray id_cstr = gameLine.at(7).toLatin1(); diff --git a/cv/video-property-page.cpp b/cv/video-property-page.cpp index 0d2b7458..7d94bbc2 100644 --- a/cv/video-property-page.cpp +++ b/cv/video-property-page.cpp @@ -51,7 +51,7 @@ prop_settings_worker::prop_settings_worker(int idx) int ret = cap.get(cv::CAP_PROP_SETTINGS); if (ret != 0) - run_in_thread_async(qApp, []() { + run_in_thread_async(qApp, [] { QMessageBox::warning(nullptr, "Camera properties", "Camera dialog already opened", @@ -98,7 +98,7 @@ ok: if (!cap.set(cv::CAP_PROP_SETTINGS, 0)) { - run_in_thread_async(qApp, []() { + run_in_thread_async(qApp, [] { QMessageBox::warning(nullptr, "Camera properties", "Can't open camera dialog", @@ -137,7 +137,7 @@ bool video_property_page::show(int idx) // XXX is this a race condition? thread->moveToThread(qApp->thread()); - QObject::connect(thread, &QThread::finished, qApp, [thread]() { thread->deleteLater(); }, Qt::DirectConnection); + QObject::connect(thread, &QThread::finished, qApp, [thread] { thread->deleteLater(); }, Qt::DirectConnection); thread->start(); diff --git a/cv/video-widget.hpp b/cv/video-widget.hpp index 15430e2f..8ad62a3c 100644 --- a/cv/video-widget.hpp +++ b/cv/video-widget.hpp @@ -16,7 +16,7 @@ #include <QObject> #include <QWidget> #include <QPainter> -#include <QPaintEvent> +#include <QtEvents> #include <QTimer> #include <QMutex> #include <QMutexLocker> diff --git a/filter-accela/accela-settings.hpp b/filter-accela/accela-settings.hpp index 63173aa8..ce27f800 100644 --- a/filter-accela/accela-settings.hpp +++ b/filter-accela/accela-settings.hpp @@ -47,10 +47,10 @@ struct settings_accela : opts static void make_splines(spline& rot, spline& pos); - value<slider_value> rot_smoothing { b, "rotation-sensitivity", slider_value(1.5, .05, 2.5) }, - pos_smoothing { b, "translation-sensitivity", slider_value(1., .05, 1.5) }, - rot_deadzone { b, "rotation-deadzone", slider_value(.03, 0, .2) }, - pos_deadzone { b, "translation-deadzone", slider_value(.1, 0, 1) }; + value<slider_value> rot_smoothing { b, "rotation-sensitivity", { 1.5, .05, 2.5 } }, + pos_smoothing { b, "translation-sensitivity", { 1., .05, 1.5 } }, + rot_deadzone { b, "rotation-deadzone", { .03, 0, .2 } }, + pos_deadzone { b, "translation-deadzone", { .1, 0, 1 } }; settings_accela() : opts("accela-sliders") {} }; diff --git a/filter-ewma2/ftnoir_filter_ewma2.h b/filter-ewma2/ftnoir_filter_ewma2.h index ea2d6e41..fd7047e1 100644 --- a/filter-ewma2/ftnoir_filter_ewma2.h +++ b/filter-ewma2/ftnoir_filter_ewma2.h @@ -13,9 +13,9 @@ struct settings : opts { value<slider_value> kMinSmoothing, kMaxSmoothing, kSmoothingScaleCurve; settings() : opts("ewma-filter"), - kMinSmoothing(b, "min-smoothing", slider_value(.02, .01, 1)), - kMaxSmoothing(b, "max-smoothing", slider_value(.7, .01, 1)), - kSmoothingScaleCurve(b, "smoothing-scale-curve", slider_value(.8, .1, 5)) + kMinSmoothing(b, "min-smoothing", { .02, .01, 1 }), + kMaxSmoothing(b, "max-smoothing", { .7, .01, 1 }), + kSmoothingScaleCurve(b, "smoothing-scale-curve", { .8, .1, 5 }) {} }; diff --git a/filter-kalman/kalman.h b/filter-kalman/kalman.h index decd540d..094e106c 100644 --- a/filter-kalman/kalman.h +++ b/filter-kalman/kalman.h @@ -125,8 +125,8 @@ struct settings : opts { settings() : opts("kalman-filter"), - noise_rot_slider_value(b, "noise-rotation-slider", slider_value(0.5, 0., 1.)), - noise_pos_slider_value(b, "noise-position-slider", slider_value(0.5, 0., 1.)) + noise_rot_slider_value(b, "noise-rotation-slider", { .5, 0., 1. }), + noise_pos_slider_value(b, "noise-position-slider", { .5, 0., 1. }) {} }; diff --git a/gui/keyboard.h b/gui/keyboard.h index c17a7bad..19d29e75 100644 --- a/gui/keyboard.h +++ b/gui/keyboard.h @@ -17,7 +17,7 @@ #include "ui_keyboard_listener.h" #include <QDialog> -#include <QKeyEvent> +#include <QtEvents> class OTR_GUI_EXPORT keyboard_listener : public QDialog { diff --git a/gui/mapping-dialog.cpp b/gui/mapping-dialog.cpp index d4f8a1d4..43130a92 100644 --- a/gui/mapping-dialog.cpp +++ b/gui/mapping-dialog.cpp @@ -10,6 +10,8 @@ #include "logic/main-settings.hpp" #include "spline/spline-widget.hpp" +#include <QtEvents> + mapping_dialog::mapping_dialog(Mappings& m) : m(m), widgets{} { ui.setupUi(this); diff --git a/gui/mapping-dialog.hpp b/gui/mapping-dialog.hpp index 23edb696..09170c62 100644 --- a/gui/mapping-dialog.hpp +++ b/gui/mapping-dialog.hpp @@ -8,9 +8,7 @@ #include <QWidget> #include <QDialog> -#include <QShowEvent> -#include <QCloseEvent> -#include <QCheckBox> +#include <QtEvents> class OTR_GUI_EXPORT mapping_dialog final : public QDialog { diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp index b29df7fb..7563d521 100644 --- a/gui/process_detector.cpp +++ b/gui/process_detector.cpp @@ -18,6 +18,7 @@ #include <QHash> #include <QPushButton> #include <QSettings> +#include <QtEvents> static constexpr inline auto RECORD_SEPARATOR = QChar(char(0x1e)); // RS ^] static constexpr inline auto UNIT_SEPARATOR = QChar(char(0x1f)); // US ^_ diff --git a/gui/process_detector.h b/gui/process_detector.h index 393dafb3..c3ff078a 100644 --- a/gui/process_detector.h +++ b/gui/process_detector.h @@ -13,7 +13,6 @@ #include <QObject> #include <QWidget> #include <QTableWidget> -#include <QResizeEvent> #include "gui/ui_process_widget.h" #include "process-detector-fancy-table.hpp" diff --git a/gui/settings.cpp b/gui/settings.cpp index fc7cde19..ee0e9959 100644 --- a/gui/settings.cpp +++ b/gui/settings.cpp @@ -151,7 +151,7 @@ options_dialog::options_dialog(std::function<void(bool)> pause_keybindings) : val.label, [=](const QString&) { val.label->setText(kopts_to_string(val.opt)); }); { - connect(val.button, &QPushButton::clicked, this, [=]() { bind_key(val.opt, val.label); }); + connect(val.button, &QPushButton::clicked, this, [=] { bind_key(val.opt, val.label); }); } } } diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index c36d1781..6c00acb0 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -638,29 +638,25 @@ void pipeline::set_zero(bool value) { set(f_zero, value); } void pipeline::toggle_zero() { negate(f_zero); } void pipeline::toggle_enabled() { negate(f_enabled_p); } -void bits::set(flags flag_, bool val_) +void bits::set(flags flag, bool val) { - const unsigned flag = unsigned(flag_); - const unsigned val = unsigned(val_); + const unsigned flag_ = unsigned(flag); + const unsigned val_ = unsigned(val); unsigned b_ = 0; for (;;) - { - if (b.compare_exchange_strong(b_, unsigned((b_ & ~flag) | (flag * val)))) + if (b.compare_exchange_weak(b_, unsigned((b_ & ~flag_) | (flag_ * val_)))) break; - } } -void bits::negate(flags flag_) +void bits::negate(flags flag) { - const unsigned flag = unsigned(flag_); + const unsigned flag_= flag; unsigned b_ = 0; for (;;) - { - if (b.compare_exchange_strong(b_, b_ ^ flag)) + if (b.compare_exchange_weak(b_, b_ ^ flag_)) break; - } } bool bits::get(flags flag) diff --git a/logic/pipeline.hpp b/logic/pipeline.hpp index 606a7bf6..5db2a753 100644 --- a/logic/pipeline.hpp +++ b/logic/pipeline.hpp @@ -74,8 +74,8 @@ struct OTR_LOGIC_EXPORT bits std::atomic<unsigned> b; - void set(flags flag_, bool val); - void negate(flags flag_); + void set(flags flag, bool val); + void negate(flags flag); bool get(flags flag); bits(); }; diff --git a/migration/20171013_00-tracker-pt-threshold.cpp b/migration/20171013_00-tracker-pt-threshold.cpp index aab64de7..c9c070fa 100644 --- a/migration/20171013_00-tracker-pt-threshold.cpp +++ b/migration/20171013_00-tracker-pt-threshold.cpp @@ -24,7 +24,6 @@ struct move_int_to_slider : migration return "20171013_00"; } - QString name() const override { return "tracker/pt threshold slider (int -> slider_value)"; @@ -32,19 +31,19 @@ struct move_int_to_slider : migration bool should_run() const override { - bundle b = make_bundle("tracker-pt"); + bundle b = make_bundle(bundle_name); return b->contains(old_name) && !b->contains(new_name); } void run() override { - bundle b = make_bundle("tracker-pt"); + bundle b = make_bundle(bundle_name); value<int> old_val(b, old_name, 128); - value<slider_value> new_val(b, new_name, slider_value(128, 0, 255)); + value<slider_value> new_val(b, new_name, { 128, 0, 255 }); - new_val = slider_value(old_val.to<int>(), 0, 255); + new_val = { old_val.to<int>(), 0, 255 }; b->save(); } diff --git a/migration/migration.hpp b/migration/migration.hpp index fc370a15..48689fc6 100644 --- a/migration/migration.hpp +++ b/migration/migration.hpp @@ -50,7 +50,7 @@ namespace detail { { registrator() { - mfun f { []() { return std::shared_ptr<migration>(new t); } }; + mfun f { [] { return std::shared_ptr<migration>(new t); } }; migrator::add_migration_thunk(f); } diff --git a/options/tie.cpp b/options/tie.cpp index baa8bb82..0042a0fb 100644 --- a/options/tie.cpp +++ b/options/tie.cpp @@ -59,7 +59,7 @@ OTR_OPTIONS_EXPORT void tie_setting(value<QVariant>& v, QComboBox* cb) base_value::connect(&v, base_value::value_changed<QVariant>(), cb, [cb, set_idx](const QVariant& var) { - run_in_thread_sync(cb, [&]() { + run_in_thread_sync(cb, [&] { set_idx(var); }); }, v.DIRECT_CONNTYPE); diff --git a/options/tie.hpp b/options/tie.hpp index ca5eae5e..ff82142e 100644 --- a/options/tie.hpp +++ b/options/tie.hpp @@ -40,7 +40,7 @@ std::enable_if_t<std::is_enum_v<t>> tie_setting(value<t>& v, QComboBox* cb) base_value::connect(cb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), &v, [&v, cb](int idx) { - run_in_thread_sync(cb, [&]() { + run_in_thread_sync(cb, [&] { v = static_cast<t>(cb->itemData(idx).toInt()); }); }, @@ -48,7 +48,7 @@ std::enable_if_t<std::is_enum_v<t>> tie_setting(value<t>& v, QComboBox* cb) base_value::connect(&v, base_value::value_changed<int>(), cb, [cb](int x) { - run_in_thread_sync(cb, [=]() { cb->setCurrentIndex(cb->findData(x)); }); + run_in_thread_sync(cb, [=] { cb->setCurrentIndex(cb->findData(x)); }); }, v.DIRECT_CONNTYPE); } @@ -61,13 +61,13 @@ void tie_setting(value<t>& v, QComboBox* cb, From&& fn_to_index, To&& fn_to_valu base_value::connect(cb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), &v, [&v, cb, fn_to_value](int idx) { - run_in_thread_sync(cb, [&]() { + run_in_thread_sync(cb, [&] { v = fn_to_value(idx, cb->currentData()); }); }, v.DIRECT_CONNTYPE); base_value::connect(&v, base_value::value_changed<t>(), cb, [&v, cb, fn_to_index](cv_qualified<t>& v) { - run_in_thread_sync(cb, [&]() { + run_in_thread_sync(cb, [&] { cb->setCurrentIndex(fn_to_index(v)); }); }); diff --git a/options/value-traits.hpp b/options/value-traits.hpp index 8a04b46d..0b30248e 100644 --- a/options/value-traits.hpp +++ b/options/value-traits.hpp @@ -34,7 +34,7 @@ struct value_traits<slider_value> : default_value_traits<slider_value> { static inline slider_value from_value(const slider_value& val, const slider_value& def) { - return slider_value(val.cur(), def.min(), def.max()); + return { val.cur(), def.min(), def.max() }; } }; diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp index 60d41aa5..16788b4b 100644 --- a/pose-widget/pose-widget.cpp +++ b/pose-widget/pose-widget.cpp @@ -15,7 +15,7 @@ #include <algorithm> #include <QPainter> -#include <QPaintEvent> +#include <QtEvents> #include <QDebug> @@ -130,12 +130,12 @@ void pose_widget::rotate_sync(double xAngle, double yAngle, double zAngle, doubl void pose_transform::rotate_async(double xAngle, double yAngle, double zAngle, double x, double y, double z) { - with_rotate([this]() {}, xAngle, yAngle, zAngle, x, y, z); + with_rotate([] {}, xAngle, yAngle, zAngle, x, y, z); } void pose_transform::rotate_sync(double xAngle, double yAngle, double zAngle, double x, double y, double z) { - with_rotate([this]() { + with_rotate([this] { rotation = rotation_; translation = translation_; project_quad_texture(); diff --git a/proto-flightgear/ftnoir_protocol_fg_dialog.cpp b/proto-flightgear/ftnoir_protocol_fg_dialog.cpp index f6f8e00d..d2098577 100644 --- a/proto-flightgear/ftnoir_protocol_fg_dialog.cpp +++ b/proto-flightgear/ftnoir_protocol_fg_dialog.cpp @@ -37,10 +37,10 @@ FGControls::FGControls() connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.buttonBox, &QDialogButtonBox::helpRequested, - ui.buttonBox, []() - { - static const QString contrib_dir = "file:///" + QDir::toNativeSeparators(QStringLiteral("%1/%2/%3"). - arg(OPENTRACK_BASE_PATH, OPENTRACK_CONTRIB_PATH, "FlightGear")); + ui.buttonBox, [] { + static const QString contrib_dir = + "file:///" + QDir::toNativeSeparators(QStringLiteral("%1/%2/%3"). + arg(OPENTRACK_BASE_PATH, OPENTRACK_CONTRIB_PATH, "FlightGear")); QDesktopServices::openUrl(contrib_dir); }); } diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp index d25199ba..57787093 100644 --- a/proto-ft/ftnoir_protocol_ft.cpp +++ b/proto-ft/ftnoir_protocol_ft.cpp @@ -30,7 +30,7 @@ never_inline void store(float volatile& place, const float value) union { float f32; - LONG i32 alignas(alignof(float)); + LONG i32; } value_; value_.f32 = value; diff --git a/proto-mouse/ftnoir_protocol_mouse.cpp b/proto-mouse/ftnoir_protocol_mouse.cpp index 9e782384..2bf91a84 100644 --- a/proto-mouse/ftnoir_protocol_mouse.cpp +++ b/proto-mouse/ftnoir_protocol_mouse.cpp @@ -23,7 +23,7 @@ static const double invert[] = 1., -1., 1. }; -void mouse::pose(const double *headpose) +void mouse::pose(const double* headpose) { const int axis_x = s.Mouse_X - 1; const int axis_y = s.Mouse_Y - 1; @@ -82,6 +82,4 @@ int mouse::get_value(double val, double sensitivity, bool is_rotation) return iround(val * c * sensitivity * sgn[unsigned(is_rotation)]); } -mouse::mouse() : last_x(0), last_y(0) {} - OPENTRACK_DECLARE_PROTOCOL(mouse, MOUSEControls, mouseDll) diff --git a/proto-mouse/ftnoir_protocol_mouse.h b/proto-mouse/ftnoir_protocol_mouse.h index 22e78b69..2b88ae1d 100644 --- a/proto-mouse/ftnoir_protocol_mouse.h +++ b/proto-mouse/ftnoir_protocol_mouse.h @@ -21,12 +21,12 @@ class mouse : public TR, public IProtocol Q_OBJECT public: - mouse(); + mouse() = default; module_status initialize() override { return status_ok(); } - void pose( const double *headpose) override; + void pose(const double* headpose) override; QString game_name() override; - int last_x, last_y; + int last_x = 0, last_y = 0; private: static int get_delta(int val, int prev); static int get_value(double val, double sensitivity, bool is_rotation); diff --git a/proto-mouse/mouse-settings.hpp b/proto-mouse/mouse-settings.hpp index c29024ac..71726588 100644 --- a/proto-mouse/mouse-settings.hpp +++ b/proto-mouse/mouse-settings.hpp @@ -13,8 +13,8 @@ struct mouse_settings : opts { opts("mouse-proto"), Mouse_X(b, "mouse-x", 0), Mouse_Y(b, "mouse-y", 0), - sensitivity_x(b, "mouse-sensitivity-x", slider_value(200, 25, 500)), - sensitivity_y(b, "mouse-sensitivity-y", slider_value(200, 25, 500)) + sensitivity_x(b, "mouse-sensitivity-x", { 200, 25, 500 }), + sensitivity_y(b, "mouse-sensitivity-y", { 200, 25, 500 }) {} }; diff --git a/proto-wine/ftnoir_protocol_wine.h b/proto-wine/ftnoir_protocol_wine.h index 20ed6045..19b905e7 100644 --- a/proto-wine/ftnoir_protocol_wine.h +++ b/proto-wine/ftnoir_protocol_wine.h @@ -2,7 +2,6 @@ #include "ui_ftnoir_winecontrols.h" #include <QMessageBox> -#include <QLibrary> #include <QProcess> #include <QDebug> #include <QMutex> diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index 243fbd60..e6cbb6ba 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -7,6 +7,7 @@ */ #include "ftnoir_tracker_pt.h" +#include "cv/video-widget.hpp" #include "compat/camera-names.hpp" #include "compat/math-imports.hpp" @@ -14,8 +15,6 @@ #include <cmath> -#include <opencv2/imgproc.hpp> - #include <QHBoxLayout> #include <QDebug> #include <QFile> @@ -23,7 +22,7 @@ using namespace types; -Tracker_PT::Tracker_PT(pointer<pt_runtime_traits> traits) : +Tracker_PT::Tracker_PT(pointer<pt_runtime_traits> const& traits) : traits { traits }, s { traits->get_module_name() }, point_extractor { traits->make_point_extractor() }, diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h index 489175e4..31bdc6bb 100644 --- a/tracker-pt/ftnoir_tracker_pt.h +++ b/tracker-pt/ftnoir_tracker_pt.h @@ -9,12 +9,9 @@ #pragma once #include "api/plugin-api.hpp" - -#include "cv/numeric.hpp" - #include "pt-api.hpp" #include "point_tracker.h" -#include "cv/video-widget.hpp" +#include "cv/numeric.hpp" #include <atomic> #include <memory> @@ -25,9 +22,9 @@ #include <QThread> #include <QMutex> #include <QLayout> -#include <QTimer> class TrackerDialog_PT; +class cv_video_widget; namespace pt_module { @@ -40,10 +37,9 @@ class Tracker_PT : public QThread, public ITracker friend class ::TrackerDialog_PT; public: - template<typename t> - using pointer = typename pt_runtime_traits::pointer<t>; + template<typename t> using pointer = pt_pointer<t>; - Tracker_PT(pointer<pt_runtime_traits> pt_runtime_traits); + Tracker_PT(pointer<pt_runtime_traits> const& pt_runtime_traits); ~Tracker_PT() override; module_status start_tracker(QFrame* parent_window) override; void data(double* data) override; diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index 9073907d..ce1b9eb0 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -165,18 +165,16 @@ void TrackerDialog_PT::startstop_trans_calib(bool start) // Don't bother counting roll samples. Roll calibration is hard enough // that it's a hidden unsupported feature anyway. - const QString sample_feedback = progn( - if (nsamples[0] < min_yaw_samples) - return tr("%1 yaw samples. Yaw more to %2 samples for stable calibration.") - .arg(nsamples[0]).arg(min_yaw_samples); - if (nsamples[1] < min_pitch_samples) - return tr("%1 pitch samples. Pitch more to %2 samples for stable calibration.") - .arg(nsamples[1]).arg(min_pitch_samples); - + QString sample_feedback; + if (nsamples[0] < min_yaw_samples) + sample_feedback = tr("%1 yaw samples. Yaw more to %2 samples for stable calibration.").arg(nsamples[0]).arg(min_yaw_samples); + else if (nsamples[1] < min_pitch_samples) + sample_feedback = tr("%1 pitch samples. Pitch more to %2 samples for stable calibration.").arg(nsamples[1]).arg(min_pitch_samples); + else + { const int nsamples_total = nsamples[0] + nsamples[1]; - - return tr("%1 samples. Over %2, good!").arg(nsamples_total).arg(min_samples); - ); + sample_feedback = tr("%1 samples. Over %2, good!").arg(nsamples_total).arg(min_samples); + } ui.sample_count_display->setText(sample_feedback); } @@ -184,12 +182,11 @@ void TrackerDialog_PT::startstop_trans_calib(bool start) ui.tx_spin->setEnabled(!start); ui.ty_spin->setEnabled(!start); ui.tz_spin->setEnabled(!start); - ui.tcalib_button->setText(progn( - if (start) - return tr("Stop calibration"); - else - return tr("Start calibration"); - )); + + if (start) + ui.tcalib_button->setText(tr("Stop calibration")); + else + ui.tcalib_button->setText(tr("Start calibration")); } void TrackerDialog_PT::poll_tracker_info_impl() diff --git a/tracker-pt/pt-api.hpp b/tracker-pt/pt-api.hpp index 621d9160..7ddddaf5 100644 --- a/tracker-pt/pt-api.hpp +++ b/tracker-pt/pt-api.hpp @@ -107,3 +107,6 @@ struct pt_runtime_traits virtual pointer<pt_preview> make_preview(int w, int h) const = 0; virtual QString get_module_name() const = 0; }; + +template<typename t> +using pt_pointer = typename pt_runtime_traits::pointer<t>; diff --git a/tracker-pt/pt-settings.hpp b/tracker-pt/pt-settings.hpp index a1b9d4f6..a8e3497a 100644 --- a/tracker-pt/pt-settings.hpp +++ b/tracker-pt/pt-settings.hpp @@ -52,5 +52,5 @@ struct pt_settings final : options::opts value<bool> auto_threshold { b, "automatic-threshold", true }; value<pt_color_type> blob_color { b, "blob-color", pt_color_natural }; - value<slider_value> threshold_slider { b, "threshold-slider", slider_value(128, 0, 255) }; + value<slider_value> threshold_slider { b, "threshold-slider", { 128, 0, 255 } }; }; diff --git a/tracker-s2bot/ftnoir_tracker_s2bot.cpp b/tracker-s2bot/ftnoir_tracker_s2bot.cpp index 44ae6132..8748e0f3 100644 --- a/tracker-s2bot/ftnoir_tracker_s2bot.cpp +++ b/tracker-s2bot/ftnoir_tracker_s2bot.cpp @@ -31,9 +31,9 @@ void tracker_s2bot::run() { if (s.freq == 0) s.freq = 10; timer.setInterval(1000.0/s.freq); timer.setSingleShot(false); - connect(&timer, &QTimer::timeout, [this]() { + connect(&timer, &QTimer::timeout, [this] { auto reply = m_nam->get(QNetworkRequest(QUrl("http://localhost:17317/poll"))); - connect(reply, &QNetworkReply::finished, [this, reply]() { + connect(reply, &QNetworkReply::finished, [this, reply] { if (reply->error() == QNetworkReply::NoError) { //qDebug() << "Request submitted OK"; } diff --git a/tracker-tobii-eyex/tobii-settings.hpp b/tracker-tobii-eyex/tobii-settings.hpp index a486306d..49b9cae8 100644 --- a/tracker-tobii-eyex/tobii-settings.hpp +++ b/tracker-tobii-eyex/tobii-settings.hpp @@ -23,10 +23,10 @@ struct settings final : public opts { value<tobii_mode> mode { b, "mode", tobii_snap }; - value<slider_value> snap_speed {b, "snap-speed", slider_value(.1, .05, 1)}, - snap_inv_dz {b, "snap-screen-edge-length", slider_value(.35, .1, .5)}; - value<slider_value> acc_speed {b, "acc-speed", slider_value(.1, .05, 1)}, - acc_dz_len {b, "acc-screen-edge-length", slider_value(.1, .1, 1)}; + value<slider_value> snap_speed {b, "snap-speed", { .1, .05, 1 }}, + snap_inv_dz {b, "snap-screen-edge-length", { .35, .1, .5 }}; + value<slider_value> acc_speed {b, "acc-speed", { .1, .05, 1 }}, + acc_dz_len {b, "acc-screen-edge-length", { .1, .1, 1 }}; value<max_yaw> snap_yaw {b, "snap-max-yaw", y20}, acc_yaw {b, "acc-max-yaw", y20}; value<max_pitch> snap_pitch {b, "snap-max-pitch", p15}, diff --git a/variant/default/main-window.cpp b/variant/default/main-window.cpp index 24a6feb3..5fd52830 100644 --- a/variant/default/main-window.cpp +++ b/variant/default/main-window.cpp @@ -130,7 +130,7 @@ main_window::main_window() : } // timers - connect(&config_list_timer, &QTimer::timeout, this, [this]() { refresh_config_list(); }); + connect(&config_list_timer, &QTimer::timeout, this, [this] { refresh_config_list(); }); connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(show_pose()), Qt::DirectConnection); connect(&det_timer, SIGNAL(timeout()), this, SLOT(maybe_start_profile_from_executable())); @@ -220,19 +220,19 @@ main_window::main_window() : } connect(this, &main_window::start_tracker, - this, [&]() { qDebug() << "start tracker"; start_tracker_(); }, + this, [&] { qDebug() << "start tracker"; start_tracker_(); }, Qt::QueuedConnection); connect(this, &main_window::stop_tracker, - this, [&]() { qDebug() << "stop tracker"; stop_tracker_(); }, + this, [&] { qDebug() << "stop tracker"; stop_tracker_(); }, Qt::QueuedConnection); connect(this, &main_window::toggle_tracker, - this, [&]() { qDebug() << "toggle tracker"; if (work) stop_tracker_(); else start_tracker_(); }, + this, [&] { qDebug() << "toggle tracker"; if (work) stop_tracker_(); else start_tracker_(); }, Qt::QueuedConnection); connect(this, &main_window::restart_tracker, - this, [&]() { qDebug() << "restart tracker"; stop_tracker_(); start_tracker_(); }, + this, [&] { qDebug() << "restart tracker"; stop_tracker_(); start_tracker_(); }, Qt::QueuedConnection); init_tray(); @@ -276,7 +276,7 @@ void main_window::init_tray() menu_action_show.setIconVisibleInMenu(true); menu_action_show.setText(isHidden() ? tr("Show the Octopus") : tr("Hide the Octopus")); menu_action_show.setIcon(QIcon(":/images/opentrack.png")); - QObject::connect(&menu_action_show, &QAction::triggered, this, [&]() { toggle_restore_from_tray(QSystemTrayIcon::Trigger); }); + QObject::connect(&menu_action_show, &QAction::triggered, this, [&] { toggle_restore_from_tray(QSystemTrayIcon::Trigger); }); tray_menu.addAction(&menu_action_show); tray_menu.addSeparator(); @@ -721,7 +721,7 @@ bool main_window::mk_window_common(std::unique_ptr<t>& d, F&& ctor) template<typename t, typename... Args> inline bool main_window::mk_window(std::unique_ptr<t>& place, Args&&... params) { - return mk_window_common(place, [&]() { return new t(params...); }); + return mk_window_common(place, [&] { return new t(params...); }); } template<typename t> @@ -742,7 +742,7 @@ void main_window::show_tracker_settings() pTrackerDialog->register_tracker(work->libs.pTracker.get()); if (pTrackerDialog) QObject::connect(pTrackerDialog.get(), &ITrackerDialog::closing, - this, [this]() { pTrackerDialog = nullptr; }); + this, [this] { pTrackerDialog = nullptr; }); } void main_window::show_proto_settings() @@ -751,7 +751,7 @@ void main_window::show_proto_settings() pProtocolDialog->register_protocol(work->libs.pProtocol.get()); if (pProtocolDialog) QObject::connect(pProtocolDialog.get(), &IProtocolDialog::closing, - this, [this]() { pProtocolDialog = nullptr; }); + this, [this] { pProtocolDialog = nullptr; }); } void main_window::show_filter_settings() @@ -760,7 +760,7 @@ void main_window::show_filter_settings() pFilterDialog->register_filter(work->libs.pFilter.get()); if (pFilterDialog) QObject::connect(pFilterDialog.get(), &IFilterDialog::closing, - this, [this]() { pFilterDialog = nullptr; }); + this, [this] { pFilterDialog = nullptr; }); } void main_window::show_options_dialog() diff --git a/variant/default/main.cpp b/variant/default/main.cpp index 4c41e33c..09bb5e2a 100644 --- a/variant/default/main.cpp +++ b/variant/default/main.cpp @@ -11,7 +11,7 @@ int main(int argc, char** argv) { - return run_application(argc, argv, []() { return new main_window; }); + return run_application(argc, argv, [] { return new main_window; }); } #if defined _MSC_VER |