X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fmainwindow.cpp;h=e88d382e87c4d6b84cc594ab36469001b305e099;hp=91e38729167d98135b8d9755ecdc315042820217;hb=37134086132e66d102d465a50536c31a32b2cf0c;hpb=7ea2a4ff0765fdad34b84e4b4631d6f3f5588714 diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 91e38729..e88d382e 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,17 +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 settings; - settings.set_defaults_where_needed(); + GlobalSettings::add_change_handler(this); setup_ui(); restore_ui_settings(); @@ -97,6 +85,8 @@ MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) : MainWindow::~MainWindow() { + GlobalSettings::remove_change_handler(this); + while (!sessions_.empty()) remove_session(sessions_.front()); } @@ -400,6 +390,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"));