]> sigrok.org Git - pulseview.git/commitdiff
Hide the configure device button when the popup would be empty
authorJoel Holdsworth <redacted>
Sat, 11 Jan 2014 10:11:53 +0000 (10:11 +0000)
committerJoel Holdsworth <redacted>
Sat, 11 Jan 2014 10:11:53 +0000 (10:11 +0000)
This resolves bug #232.

pv/popups/deviceoptions.cpp
pv/popups/deviceoptions.h
pv/toolbars/samplingbar.cpp
pv/toolbars/samplingbar.h

index 30d5f579422a37517aa689cae30dc1a88fe98262..6f9d7d9f558ebe3e56a2aec7c48db5c2016f1a7d 100644 (file)
@@ -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
index fd9d03488651162f81a37d92d2802f62c3cd80c0..788f9b5b85b407d18f1509f9b94862093f641dc8 100644 (file)
@@ -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;
 
index ca0450b43c2f751aff4b9f93383819ef1dfe2a2e..0e3ce62374bf2c053ebf8a5eb57bd188bfcf11a8 100644 (file)
@@ -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()
index d2b3ad50aa035a57a208c845086120a99603d05d..9f6ceb21fd20cb2b23f3f4b08b74f2a1f32d6a57 100644 (file)
@@ -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;