From: Soeren Apel Date: Sun, 16 Jul 2017 17:14:16 +0000 (+0200) Subject: Introduce "default div height" setting X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=daa54986010a11879da11e30aafd3a2739ab7a15;p=pulseview.git Introduce "default div height" setting --- diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index ef916f1a..2c2ccfee 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -133,6 +134,7 @@ QCheckBox *Settings::create_checkbox(const QString& key, const char* slot) const QWidget *Settings::get_view_settings_form(QWidget *parent) const { + GlobalSettings settings; QCheckBox *cb; QWidget *form = new QWidget(parent); @@ -169,6 +171,15 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const SLOT(on_view_showAnalogMinorGrid_changed(int))); trace_view_layout->addRow(tr("Show analog minor grid in addition to vdiv grid"), cb); + QSpinBox *default_div_height_sb = new QSpinBox(); + default_div_height_sb->setRange(20, 1000); + default_div_height_sb->setSuffix(tr(" pixels")); + default_div_height_sb->setValue( + settings.value(GlobalSettings::Key_View_DefaultDivHeight).toInt()); + connect(default_div_height_sb, SIGNAL(valueChanged(int)), this, + SLOT(on_view_defaultDivHeight_changed(int))); + trace_view_layout->addRow(tr("Default analog trace div height"), default_div_height_sb); + return form; } @@ -416,6 +427,12 @@ void Settings::on_view_showAnalogMinorGrid_changed(int state) settings.setValue(GlobalSettings::Key_View_ShowAnalogMinorGrid, state ? true : false); } +void Settings::on_view_defaultDivHeight_changed(int value) +{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_View_DefaultDivHeight, value); +} + void Settings::on_dec_initialStateConfigurable_changed(int state) { GlobalSettings settings; diff --git a/pv/dialogs/settings.hpp b/pv/dialogs/settings.hpp index 6477757f..b01b5da9 100644 --- a/pv/dialogs/settings.hpp +++ b/pv/dialogs/settings.hpp @@ -56,6 +56,7 @@ private Q_SLOTS: void on_view_stickyScrolling_changed(int state); void on_view_showSamplingPoints_changed(int state); void on_view_showAnalogMinorGrid_changed(int state); + void on_view_defaultDivHeight_changed(int value); void on_dec_initialStateConfigurable_changed(int state); private: diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 6b13df16..d437c166 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -19,7 +19,9 @@ #include "globalsettings.hpp" +#include #include +#include #include using std::function; @@ -34,6 +36,7 @@ const QString GlobalSettings::Key_View_ColouredBG = "View_ColouredBG"; const QString GlobalSettings::Key_View_StickyScrolling = "View_StickyScrolling"; const QString GlobalSettings::Key_View_ShowSamplingPoints = "View_ShowSamplingPoints"; const QString GlobalSettings::Key_View_ShowAnalogMinorGrid = "View_ShowAnalogMinorGrid"; +const QString GlobalSettings::Key_View_DefaultDivHeight = "View_DefaultDivHeight"; const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable"; multimap< QString, function > GlobalSettings::callbacks_; @@ -59,6 +62,10 @@ void GlobalSettings::set_defaults_where_needed() // Enable showing sampling points by default if (!contains(Key_View_ShowSamplingPoints)) setValue(Key_View_ShowSamplingPoints, true); + + if (!contains(Key_View_DefaultDivHeight)) + setValue(Key_View_DefaultDivHeight, + 3 * QFontMetrics(QApplication::font()).height()); } void GlobalSettings::register_change_handler(const QString key, diff --git a/pv/globalsettings.hpp b/pv/globalsettings.hpp index 05ff126d..317805a7 100644 --- a/pv/globalsettings.hpp +++ b/pv/globalsettings.hpp @@ -46,6 +46,7 @@ public: static const QString Key_View_StickyScrolling; static const QString Key_View_ShowSamplingPoints; static const QString Key_View_ShowAnalogMinorGrid; + static const QString Key_View_DefaultDivHeight; static const QString Key_Dec_InitialStateConfigurable; public: