From: Joel Holdsworth Date: Sat, 11 Jan 2014 10:11:53 +0000 (+0000) Subject: Hide the configure device button when the popup would be empty X-Git-Tag: pulseview-0.2.0~154 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=b3e8a5d8e8139278a40508694e0b179170fffa14;p=pulseview.git Hide the configure device button when the popup would be empty This resolves bug #232. --- diff --git a/pv/popups/deviceoptions.cpp b/pv/popups/deviceoptions.cpp index 30d5f579..6f9d7d9f 100644 --- a/pv/popups/deviceoptions.cpp +++ b/pv/popups/deviceoptions.cpp @@ -41,5 +41,10 @@ DeviceOptions::DeviceOptions(sr_dev_inst *sdi, QWidget *parent) : _layout.addWidget(_binding.get_property_form(this, true)); } +pv::prop::binding::DeviceOptions& DeviceOptions::binding() +{ + return _binding; +} + } // namespace popups } // namespace pv diff --git a/pv/popups/deviceoptions.h b/pv/popups/deviceoptions.h index fd9d0348..788f9b5b 100644 --- a/pv/popups/deviceoptions.h +++ b/pv/popups/deviceoptions.h @@ -37,6 +37,8 @@ class DeviceOptions : public pv::widgets::Popup public: DeviceOptions(sr_dev_inst *sdi, QWidget *parent); + pv::prop::binding::DeviceOptions& binding(); + private: sr_dev_inst *const _sdi; diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index ca0450b4..0e3ce623 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -70,6 +70,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : _device_selector(this), _updating_device_selector(false), _configure_button(this), + _configure_button_action(NULL), _probes_button(this), _probes_popup(_session, this), _record_length_selector(this), @@ -112,7 +113,7 @@ SamplingBar::SamplingBar(SigSession &session, QWidget *parent) : _run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon); addWidget(&_device_selector); - addWidget(&_configure_button); + _configure_button_action = addWidget(&_configure_button); addWidget(&_probes_button); addWidget(&_record_length_selector); _sample_rate_list_action = addWidget(&_sample_rate_list); @@ -313,7 +314,11 @@ void SamplingBar::on_device_selected() sr_dev_inst *const sdi = get_selected_device(); _session.set_device(sdi); - _configure_button.set_popup(new DeviceOptions(sdi, this)); + // Update the configure popup + DeviceOptions *const opts = new DeviceOptions(sdi, this); + _configure_button_action->setVisible( + !opts->binding().properties().empty()); + _configure_button.set_popup(opts); } void SamplingBar::on_sample_rate_changed() diff --git a/pv/toolbars/samplingbar.h b/pv/toolbars/samplingbar.h index d2b3ad50..9f6ceb21 100644 --- a/pv/toolbars/samplingbar.h +++ b/pv/toolbars/samplingbar.h @@ -83,6 +83,7 @@ private: bool _updating_device_selector; pv::widgets::PopupToolButton _configure_button; + QAction *_configure_button_action; pv::widgets::PopupToolButton _probes_button; pv::popups::Probes _probes_popup;