X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fprop%2Fbool.cpp;h=e0e052fc6b2b377c3d580192beda10793d331884;hp=ad9a13e7c0e05bc710fc7d385b6ad7e6b22a04be;hb=5be76b1a8c3b4975c02f685ceaa02cdb69d1dccc;hpb=f459c5400e067c4389c472b84194d760e7bfd585 diff --git a/pv/prop/bool.cpp b/pv/prop/bool.cpp index ad9a13e7..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 { @@ -40,20 +37,23 @@ Bool::~Bool() { } -QWidget* Bool::get_widget(QWidget *parent) +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; + + _check_box = new QCheckBox(name(), parent); + _check_box->setCheckState(g_variant_get_boolean(value) ? + Qt::Checked : Qt::Unchecked); + g_variant_unref(value); - if (value) { - _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; } @@ -74,5 +74,10 @@ void Bool::commit() _check_box->checkState() == Qt::Checked)); } +void Bool::on_state_changed(int) +{ + commit(); +} + } // prop } // pv