X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=4ab78d1dc9972b1e2433fd34c830b240a3624c5e;hp=91e38729167d98135b8d9755ecdc315042820217;hb=bf84211be02b096646cf28cf9dc7480029e4f439;hpb=7ea2a4ff0765fdad34b84e4b4631d6f3f5588714 diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 91e38729..4ab78d1d 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -50,10 +50,8 @@ #include -using std::bind; using std::dynamic_pointer_cast; using std::make_shared; -using std::placeholders::_1; using std::shared_ptr; using std::string; @@ -79,14 +77,7 @@ MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) : qRegisterMetaType("util::Timestamp"); qRegisterMetaType("uint64_t"); - GlobalSettings::register_change_handler(GlobalSettings::Key_View_ColouredBG, - bind(&MainWindow::on_settingViewColouredBg_changed, this, _1)); - - GlobalSettings::register_change_handler(GlobalSettings::Key_View_ShowSamplingPoints, - bind(&MainWindow::on_settingViewShowSamplingPoints_changed, this, _1)); - - GlobalSettings::register_change_handler(GlobalSettings::Key_View_ShowAnalogMinorGrid, - bind(&MainWindow::on_settingViewShowAnalogMinorGrid_changed, this, _1)); + GlobalSettings::add_change_handler(this); GlobalSettings settings; settings.set_defaults_where_needed(); @@ -97,6 +88,8 @@ MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) : MainWindow::~MainWindow() { + GlobalSettings::remove_change_handler(this); + while (!sessions_.empty()) remove_session(sessions_.front()); } @@ -400,6 +393,18 @@ void MainWindow::restore_sessions() } } +void MainWindow::on_setting_changed(const QString &key, const QVariant &value) +{ + if (key == GlobalSettings::Key_View_ColouredBG) + on_settingViewColouredBg_changed(value); + + if (key == GlobalSettings::Key_View_ShowSamplingPoints) + on_settingViewShowSamplingPoints_changed(value); + + if (key == GlobalSettings::Key_View_ShowAnalogMinorGrid) + on_settingViewShowAnalogMinorGrid_changed(value); +} + void MainWindow::setup_ui() { setObjectName(QString::fromUtf8("MainWindow"));