X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdialogs%2Fsettings.cpp;h=ef916f1a57c842c9d34475eb4d7760b077c4dc63;hp=310b80e2147d6835ded84b10589daa4dbb89a6b8;hb=e91fb166608133382baa1a90cc022bfa47d649de;hpb=1cc1c8dec120ed6d98071f939ea435d85ee853bf diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index 310b80e2..ef916f1a 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -122,10 +121,20 @@ void Settings::create_pages() aboutButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); } -QWidget *Settings::get_view_settings_form(QWidget *parent) const +QCheckBox *Settings::create_checkbox(const QString& key, const char* slot) const { GlobalSettings settings; + QCheckBox *cb = new QCheckBox(); + cb->setChecked(settings.value(key).toBool()); + connect(cb, SIGNAL(stateChanged(int)), this, slot); + return cb; +} + +QWidget *Settings::get_view_settings_form(QWidget *parent) const +{ + QCheckBox *cb; + QWidget *form = new QWidget(parent); QVBoxLayout *form_layout = new QVBoxLayout(form); @@ -136,30 +145,29 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const QFormLayout *trace_view_layout = new QFormLayout(); trace_view_group->setLayout(trace_view_layout); - QCheckBox *coloured_bg_cb = new QCheckBox(); - coloured_bg_cb->setChecked(settings.value(GlobalSettings::Key_View_ColouredBG).toBool()); - connect(coloured_bg_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_colouredBG_changed(int))); - trace_view_layout->addRow(tr("Use coloured trace &background"), coloured_bg_cb); + cb = create_checkbox(GlobalSettings::Key_View_ColouredBG, + SLOT(on_view_colouredBG_changed(int))); + trace_view_layout->addRow(tr("Use coloured trace &background"), cb); - QCheckBox *always_zoom_to_fit_cb = new QCheckBox(); - always_zoom_to_fit_cb->setChecked(settings.value(GlobalSettings::Key_View_AlwaysZoomToFit).toBool()); - connect(always_zoom_to_fit_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_alwaysZoomToFit_changed(int))); - trace_view_layout->addRow(tr("Constantly perform &zoom-to-fit during capture"), always_zoom_to_fit_cb); + cb = create_checkbox(GlobalSettings::Key_View_ZoomToFitDuringAcq, + SLOT(on_view_zoomToFitDuringAcq_changed(int))); + trace_view_layout->addRow(tr("Constantly perform &zoom-to-fit during acquisition"), cb); - QCheckBox *sticky_scrolling_cb = new QCheckBox(); - sticky_scrolling_cb->setChecked(settings.value(GlobalSettings::Key_View_StickyScrolling).toBool()); - connect(sticky_scrolling_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_stickyScrolling_changed(int))); - trace_view_layout->addRow(tr("Always keep &newest samples at the right edge during capture"), sticky_scrolling_cb); + cb = create_checkbox(GlobalSettings::Key_View_ZoomToFitAfterAcq, + SLOT(on_view_zoomToFitAfterAcq_changed(int))); + trace_view_layout->addRow(tr("Perform a zoom-to-&fit when acquisition stops"), cb); - QCheckBox *show_sampling_points_cb = new QCheckBox(); - show_sampling_points_cb->setChecked(settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool()); - connect(show_sampling_points_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_showSamplingPoints_changed(int))); - trace_view_layout->addRow(tr("Show data &sampling points"), show_sampling_points_cb); + cb = create_checkbox(GlobalSettings::Key_View_StickyScrolling, + SLOT(on_view_stickyScrolling_changed(int))); + trace_view_layout->addRow(tr("Always keep &newest samples at the right edge during capture"), cb); - QCheckBox *show_analog_minor_grid_cb = new QCheckBox(); - show_analog_minor_grid_cb->setChecked(settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool()); - connect(show_analog_minor_grid_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_showAnalogMinorGrid_changed(int))); - trace_view_layout->addRow(tr("Show analog minor grid in addition to vdiv grid"), show_analog_minor_grid_cb); + cb = create_checkbox(GlobalSettings::Key_View_ShowSamplingPoints, + SLOT(on_view_showSamplingPoints_changed(int))); + trace_view_layout->addRow(tr("Show data &sampling points"), cb); + + cb = create_checkbox(GlobalSettings::Key_View_ShowAnalogMinorGrid, + SLOT(on_view_showAnalogMinorGrid_changed(int))); + trace_view_layout->addRow(tr("Show analog minor grid in addition to vdiv grid"), cb); return form; } @@ -167,7 +175,7 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const QWidget *Settings::get_decoder_settings_form(QWidget *parent) const { #ifdef ENABLE_DECODE - GlobalSettings settings; + QCheckBox *cb; QWidget *form = new QWidget(parent); QVBoxLayout *form_layout = new QVBoxLayout(form); @@ -179,10 +187,9 @@ QWidget *Settings::get_decoder_settings_form(QWidget *parent) const QFormLayout *decoder_layout = new QFormLayout(); decoder_group->setLayout(decoder_layout); - QCheckBox *initial_state_configurable_cb = new QCheckBox(); - initial_state_configurable_cb->setChecked(settings.value(GlobalSettings::Key_Dec_InitialStateConfigurable).toBool()); - connect(initial_state_configurable_cb, SIGNAL(stateChanged(int)), this, SLOT(on_dec_initialStateConfigurable_changed(int))); - decoder_layout->addRow(tr("Allow configuration of &initial signal state"), initial_state_configurable_cb); + cb = create_checkbox(GlobalSettings::Key_Dec_InitialStateConfigurable, + SLOT(on_dec_initialStateConfigurable_changed(int))); + decoder_layout->addRow(tr("Allow configuration of &initial signal state"), cb); return form; #else @@ -208,7 +215,7 @@ QWidget *Settings::get_about_page(QWidget *parent) const #endif QLabel *icon = new QLabel(); - icon->setPixmap(QPixmap(QString::fromUtf8(":/icons/sigrok-logo-notext.svg"))); + icon->setPixmap(QPixmap(QString::fromUtf8(":/icons/pulseview.svg"))); /* Setup the version field */ QLabel *version_info = new QLabel(); @@ -373,10 +380,16 @@ void Settings::on_page_changed(QListWidgetItem *current, QListWidgetItem *previo pages->setCurrentIndex(page_list->row(current)); } -void Settings::on_view_alwaysZoomToFit_changed(int state) +void Settings::on_view_zoomToFitDuringAcq_changed(int state) +{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_View_ZoomToFitDuringAcq, state ? true : false); +} + +void Settings::on_view_zoomToFitAfterAcq_changed(int state) { GlobalSettings settings; - settings.setValue(GlobalSettings::Key_View_AlwaysZoomToFit, state ? true : false); + settings.setValue(GlobalSettings::Key_View_ZoomToFitAfterAcq, state ? true : false); } void Settings::on_view_colouredBG_changed(int state)