X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Ftoolbars%2Fsamplingbar.cpp;h=c34373776ca572ca101465a2fc73bfff2ab2cf80;hb=f27ee56d9c2b18158f2a9451b295123288134611;hp=91c4b076ea6346d46102100ec20eec4a0c201756;hpb=e95e8563a1de0d2045cb8f30083889896b6c94df;p=pulseview.git diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 91c4b07..c343737 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -22,22 +22,23 @@ #include -#include - #include #include +#include +#include #include "samplingbar.h" #include #include #include -#include +#include +#include -using boost::shared_ptr; using std::map; using std::max; using std::min; +using std::shared_ptr; using std::string; namespace pv { @@ -54,7 +55,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : _updating_device_selector(false), _configure_button(this), _configure_button_action(NULL), - _probes_button(this), + _channels_button(this), _sample_count(" samples", this), _sample_rate("Hz", this), _updating_sample_rate(false), @@ -65,6 +66,8 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : _icon_grey(":/icons/status-grey.svg"), _run_stop_button(this) { + setObjectName(QString::fromUtf8("SamplingBar")); + connect(&_run_stop_button, SIGNAL(clicked()), this, SLOT(on_run_stop())); connect(&_device_selector, SIGNAL(currentIndexChanged (int)), @@ -81,18 +84,21 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : _configure_button.setIcon(QIcon::fromTheme("configure", QIcon(":/icons/configure.png"))); - _probes_button.setIcon(QIcon::fromTheme("probes", - QIcon(":/icons/probes.svg"))); + _channels_button.setIcon(QIcon::fromTheme("channels", + QIcon(":/icons/channels.svg"))); _run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); addWidget(&_device_selector); _configure_button_action = addWidget(&_configure_button); - addWidget(&_probes_button); + addWidget(&_channels_button); addWidget(&_sample_count); addWidget(&_sample_rate); addWidget(&_run_stop_button); + + _sample_count.installEventFilter(this); + _sample_rate.installEventFilter(this); } void SamplingBar::set_device_list( @@ -108,7 +114,7 @@ void SamplingBar::set_device_list( _device_selector.clear(); _device_selector_map.clear(); - BOOST_FOREACH (shared_ptr dev_inst, devices) { + for (shared_ptr dev_inst : devices) { assert(dev_inst); const string title = dev_inst->format_device_title(); const sr_dev_inst *sdi = dev_inst->dev_inst(); @@ -142,8 +148,7 @@ shared_ptr SamplingBar::get_selected_device() const index).value(); assert(sdi); - map >:: - const_iterator iter = _device_selector_map.find(sdi); + const auto iter = _device_selector_map.find(sdi); if (iter == _device_selector_map.end()) return shared_ptr(); @@ -319,9 +324,9 @@ void SamplingBar::update_device_config_widgets() !opts->binding().properties().empty()); _configure_button.set_popup(opts); - // Update the probes popup - Probes *const probes = new Probes(_session, this); - _probes_button.set_popup(probes); + // Update the channels popup + Channels *const channels = new Channels(_session, this); + _channels_button.set_popup(channels); // Update supported options. _sample_count_supported = false; @@ -334,13 +339,15 @@ void SamplingBar::update_device_config_widgets() gvar, &num_opts, sizeof(int32_t)); for (unsigned int i = 0; i < num_opts; i++) { - switch (options[i]) { + switch (options[i] & SR_CONF_MASK) { case SR_CONF_LIMIT_SAMPLES: - _sample_count_supported = true; + if (options[i] & SR_CONF_SET) + _sample_count_supported = true; break; case SR_CONF_LIMIT_FRAMES: - dev_inst->set_config(NULL, SR_CONF_LIMIT_FRAMES, - g_variant_new_uint64(1)); + if (options[i] & SR_CONF_SET) + dev_inst->set_config(NULL, SR_CONF_LIMIT_FRAMES, + g_variant_new_uint64(1)); break; } } @@ -446,5 +453,21 @@ void SamplingBar::on_config_changed() update_sample_rate_selector(); } +bool SamplingBar::eventFilter(QObject *watched, QEvent *event) +{ + if ((watched == &_sample_count || watched == &_sample_rate) && + (event->type() == QEvent::ToolTip)) { + double sec = (double)_sample_count.value() / _sample_rate.value(); + QHelpEvent *help_event = static_cast(event); + + QString str = tr("Total sampling time: %1").arg(pv::util::format_second(sec)); + QToolTip::showText(help_event->globalPos(), str); + + return true; + } + + return false; +} + } // namespace toolbars } // namespace pv