From: Joel Holdsworth Date: Wed, 25 Dec 2013 18:26:19 +0000 (+0000) Subject: Populate sample rate widget with correct initial value X-Git-Tag: pulseview-0.2.0~188 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=32c81aef875696bdd1b933e20ab91703ad63203d;p=pulseview.git Populate sample rate widget with correct initial value --- diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 2fa2d391..db7e8e0b 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -73,6 +73,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : _probes_button(this), _probes_popup(_session, this), _record_length_selector(this), + _sample_rate_action(NULL), _sample_rate_list(this), _icon_red(":/icons/status-red.svg"), _icon_green(":/icons/status-green.svg"), @@ -184,7 +185,6 @@ void SamplingBar::update_sample_rate_selector() GVariant *gvar_dict, *gvar_list; const uint64_t *elements = NULL; gsize num_elements; - QAction *selector_action = NULL; assert(_sample_rate_value_action); assert(_sample_rate_list_action); @@ -207,7 +207,7 @@ void SamplingBar::update_sample_rate_selector() _sample_rate_value.setSingleStep(elements[2]); g_variant_unref(gvar_list); - selector_action = _sample_rate_value_action; + _sample_rate_action = _sample_rate_value_action; } else if ((gvar_list = g_variant_lookup_value(gvar_dict, "samplerates", G_VARIANT_TYPE("at")))) @@ -227,7 +227,7 @@ void SamplingBar::update_sample_rate_selector() _sample_rate_list.show(); g_variant_unref(gvar_list); - selector_action = _sample_rate_list_action; + _sample_rate_action = _sample_rate_list_action; } g_variant_unref(gvar_dict); @@ -235,8 +235,8 @@ void SamplingBar::update_sample_rate_selector() // We delay showing the action, so that value change events // are ignored. - if (selector_action) - selector_action->setVisible(true); + if (_sample_rate_action) + _sample_rate_action->setVisible(true); } void SamplingBar::update_sample_rate_selector_value() @@ -259,9 +259,9 @@ void SamplingBar::update_sample_rate_selector_value() assert(_sample_rate_value_action); assert(_sample_rate_list_action); - if (_sample_rate_value_action->isVisible()) + if (_sample_rate_action == _sample_rate_value_action) _sample_rate_value.setValue(samplerate); - else if (_sample_rate_list_action->isVisible()) + else if (_sample_rate_action == _sample_rate_list_action) { for (int i = 0; i < _sample_rate_list.count(); i++) if (samplerate == _sample_rate_list.itemData( @@ -280,9 +280,9 @@ void SamplingBar::commit_sample_rate() assert(_sample_rate_value_action); assert(_sample_rate_list_action); - if (_sample_rate_value_action->isVisible()) + if (_sample_rate_action == _sample_rate_value_action) sample_rate = (uint64_t)_sample_rate_value.value(); - else if (_sample_rate_list_action->isVisible()) + else if (_sample_rate_action == _sample_rate_list_action) { const int index = _sample_rate_list.currentIndex(); if (index >= 0) diff --git a/pv/toolbars/samplingbar.h b/pv/toolbars/samplingbar.h index e4aa40d4..d2b3ad50 100644 --- a/pv/toolbars/samplingbar.h +++ b/pv/toolbars/samplingbar.h @@ -89,6 +89,7 @@ private: QComboBox _record_length_selector; + QAction *_sample_rate_action; QComboBox _sample_rate_list; QAction *_sample_rate_list_action; QDoubleSpinBox _sample_rate_value;