From: Martin Ling Date: Tue, 14 Jan 2014 19:59:49 +0000 (+0000) Subject: Show sample count selector only if setting supported. X-Git-Tag: pulseview-0.2.0~129 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8575601295c4853ae73fa404eb157bd063af0c20;p=pulseview.git Show sample count selector only if setting supported. --- diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index c57779c2..a2ddaae6 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -53,6 +53,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : _sample_count(" samples", this), _sample_rate("Hz", this), _updating_sample_rate(false), + _updating_sample_count(false), _icon_red(":/icons/status-red.svg"), _icon_green(":/icons/status-green.svg"), _icon_grey(":/icons/status-grey.svg"), @@ -68,7 +69,6 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : this, SLOT(on_sample_rate_changed())); _sample_count.show_min_max_step(0, UINT64_MAX, 1); - _sample_count.set_value(DefaultRecordLength); set_capture_state(pv::SigSession::Stopped); @@ -204,6 +204,32 @@ void SamplingBar::update_sample_rate_selector_value() _updating_sample_rate = false; } +void SamplingBar::update_sample_count_selector() +{ + sr_dev_inst *const sdi = get_selected_device(); + GVariant *gvar; + uint64_t samplecount; + + assert(sdi); + + if (sr_config_get(sdi->driver, sdi, NULL, + SR_CONF_LIMIT_SAMPLES, &gvar) != SR_OK) + { + _sample_count.show_none(); + } + else + { + _sample_count.show_min_max_step(0, UINT64_MAX, 1); + + samplecount = g_variant_get_uint64(gvar); + g_variant_unref(gvar); + + _updating_sample_count = true; + _sample_count.set_value(samplecount); + _updating_sample_count = false; + } +} + void SamplingBar::commit_sample_count() { uint64_t sample_count = 0; @@ -247,8 +273,12 @@ void SamplingBar::on_device_selected() if (_updating_device_selector) return; + update_sample_count_selector(); update_sample_rate_selector(); + if (_sample_count.value() == 0) + _sample_count.set_value(DefaultRecordLength); + sr_dev_inst *const sdi = get_selected_device(); _session.set_device(sdi); @@ -265,7 +295,8 @@ void SamplingBar::on_device_selected() void SamplingBar::on_sample_count_changed() { - commit_sample_count(); + if(!_updating_sample_count) + commit_sample_count(); } void SamplingBar::on_sample_rate_changed() diff --git a/pv/toolbars/samplingbar.h b/pv/toolbars/samplingbar.h index f6a2cdd6..cf425775 100644 --- a/pv/toolbars/samplingbar.h +++ b/pv/toolbars/samplingbar.h @@ -68,6 +68,7 @@ signals: private: void update_sample_rate_selector(); void update_sample_rate_selector_value(); + void update_sample_count_selector(); void commit_sample_rate(); void commit_sample_count(); @@ -91,6 +92,7 @@ private: pv::widgets::SweepTimingWidget _sample_count; pv::widgets::SweepTimingWidget _sample_rate; bool _updating_sample_rate; + bool _updating_sample_count; QIcon _icon_red; QIcon _icon_green;