From: Soeren Apel Date: Fri, 9 Jun 2017 20:06:02 +0000 (+0200) Subject: Settings: Add method to set settings defaults X-Git-Tag: pulseview-0.4.0~14 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c031de4b8b8a62bfec13de3fd91c0031eb222a04;p=pulseview.git Settings: Add method to set settings defaults --- diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 0eff1915..ee974103 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -42,6 +42,13 @@ GlobalSettings::GlobalSettings() : beginGroup("Settings"); } +void GlobalSettings::set_defaults_where_needed() +{ + // Enable coloured trace backgrounds by default + if (!contains(Key_View_ColouredBG)) + setValue(Key_View_ColouredBG, true); +} + void GlobalSettings::register_change_handler(const QString key, function cb) { diff --git a/pv/globalsettings.hpp b/pv/globalsettings.hpp index 930bb5bb..f6a6141f 100644 --- a/pv/globalsettings.hpp +++ b/pv/globalsettings.hpp @@ -48,6 +48,8 @@ public: public: GlobalSettings(); + void set_defaults_where_needed(); + static void register_change_handler(const QString key, function cb); diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 786d07e2..e6686fed 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -89,6 +89,9 @@ MainWindow::MainWindow(DeviceManager &device_manager, QWidget *parent) : GlobalSettings::register_change_handler(GlobalSettings::Key_View_ShowAnalogMinorGrid, bind(&MainWindow::on_settingViewShowAnalogMinorGrid_changed, this, _1)); + GlobalSettings settings; + settings.set_defaults_where_needed(); + setup_ui(); restore_ui_settings(); }