X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fprop%2Fbool.cpp;h=e0e052fc6b2b377c3d580192beda10793d331884;hp=95cbb96e0caceea6c82e37367f933b1481ba3762;hb=a28c30252fd32d3185c62062dfad74ae659ae383;hpb=de1d99bbe58f825e30048baa48a9439c01686f10 diff --git a/pv/prop/bool.cpp b/pv/prop/bool.cpp index 95cbb96e..e0e052fc 100644 --- a/pv/prop/bool.cpp +++ b/pv/prop/bool.cpp @@ -24,9 +24,6 @@ #include "bool.h" -using namespace std; -using namespace boost; - namespace pv { namespace prop { @@ -36,20 +33,27 @@ Bool::Bool(QString name, Getter getter, Setter setter) : { } -QWidget* Bool::get_widget(QWidget *parent) +Bool::~Bool() +{ +} + +QWidget* Bool::get_widget(QWidget *parent, bool auto_commit) { if (_check_box) return _check_box; - _check_box = new QCheckBox(name(), parent); - GVariant *const value = _getter ? _getter() : NULL; + if (!value) + return NULL; - if (value) { - _check_box->setCheckState(g_variant_get_boolean(value) ? - Qt::Checked : Qt::Unchecked); - g_variant_unref(value); - } + _check_box = new QCheckBox(name(), parent); + _check_box->setCheckState(g_variant_get_boolean(value) ? + Qt::Checked : Qt::Unchecked); + g_variant_unref(value); + + if (auto_commit) + connect(_check_box, SIGNAL(stateChanged(int)), + this, SLOT(on_state_changed(int))); return _check_box; } @@ -70,5 +74,10 @@ void Bool::commit() _check_box->checkState() == Qt::Checked)); } +void Bool::on_state_changed(int) +{ + commit(); +} + } // prop } // pv