]> sigrok.org Git - pulseview.git/commitdiff
Introduce "default div height" setting
authorSoeren Apel <redacted>
Sun, 16 Jul 2017 17:14:16 +0000 (19:14 +0200)
committerSoeren Apel <redacted>
Sun, 16 Jul 2017 20:37:12 +0000 (22:37 +0200)
pv/dialogs/settings.cpp
pv/dialogs/settings.hpp
pv/globalsettings.cpp
pv/globalsettings.hpp

index ef916f1a57c842c9d34475eb4d7760b077c4dc63..2c2ccfee4504ef5ccb93aeac80e9e089e261dbe8 100644 (file)
@@ -28,6 +28,7 @@
 #include <QGroupBox>
 #include <QHBoxLayout>
 #include <QLabel>
+#include <QSpinBox>
 #include <QString>
 #include <QTextBrowser>
 #include <QTextDocument>
@@ -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;
index 6477757f7f60e58f29ad48fcd791d359f6e4af7b..b01b5da9626b10672f4dfda1dfa54556b0e52dba 100644 (file)
@@ -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:
index 6b13df16e397fc44ab6dd2473b92bba1f316c58f..d437c16681983711b842678b8323e49ec9a034ed 100644 (file)
@@ -19,7 +19,9 @@
 
 #include "globalsettings.hpp"
 
+#include <QApplication>
 #include <QByteArray>
+#include <QFontMetrics>
 #include <QString>
 
 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<void(QVariant)> > 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,
index 05ff126dd092e9070264a8ee55afeb24bc8c2970..317805a72f3ddc1ff5fb4fb5828048ebdaa6bdfd 100644 (file)
@@ -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: