]> sigrok.org Git - pulseview.git/blobdiff - pv/prop/double.cpp
pv::prop::Enum: Do not create a widget if the initial value could not be retrieved
[pulseview.git] / pv / prop / double.cpp
index 39e205ee691f2910dd7899ac958ae5d9c69bde3f..fa5e5688148bc8f07fe089f88ed3be161a1fab11 100644 (file)
@@ -24,8 +24,8 @@
 
 #include "double.h"
 
-using namespace std;
-using namespace boost;
+using boost::optional;
+using std::pair;
 
 namespace pv {
 namespace prop {
@@ -50,7 +50,7 @@ Double::~Double()
 {
 }
 
-QWidget* Double::get_widget(QWidget *parent)
+QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
 {
        if (_spin_box)
                return _spin_box;
@@ -70,6 +70,10 @@ QWidget* Double::get_widget(QWidget *parent)
                g_variant_unref(value);
        }
 
+       if (auto_commit)
+               connect(_spin_box, SIGNAL(valueChanged(double)),
+                       this, SLOT(on_value_changed(double)));
+
        return _spin_box;
 }
 
@@ -83,5 +87,10 @@ void Double::commit()
        _setter(g_variant_new_double(_spin_box->value()));
 }
 
+void Double::on_value_changed(double)
+{
+       commit();
+}
+
 } // prop
 } // pv