X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fprop%2Fbool.cpp;h=6c89741ff6f6657779d74f4a6e30d0c7675d72d4;hb=e170ab6531b39e51dce725f000fddd57b88d8561;hp=e3e0ebd50e86151408b14fe7420167a2e2db054a;hpb=2acdb232d6bb452cfdfaea3ef5218fb4da592329;p=pulseview.git diff --git a/pv/prop/bool.cpp b/pv/prop/bool.cpp index e3e0ebd..6c89741 100644 --- a/pv/prop/bool.cpp +++ b/pv/prop/bool.cpp @@ -14,11 +14,10 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ -#include +#include #include @@ -27,13 +26,9 @@ namespace pv { namespace prop { -Bool::Bool(QString name, Getter getter, Setter setter) : - Property(name, getter, setter), - check_box_(NULL) -{ -} - -Bool::~Bool() +Bool::Bool(QString name, QString desc, Getter getter, Setter setter) : + Property(name, desc, getter, setter), + check_box_(nullptr) { } @@ -43,17 +38,16 @@ QWidget* Bool::get_widget(QWidget *parent, bool auto_commit) return check_box_; if (!getter_) - return NULL; + return nullptr; Glib::VariantBase variant = getter_(); if (!variant.gobj()) - return NULL; - - bool value = Glib::VariantBase::cast_dynamic>( - variant).get(); + return nullptr; check_box_ = new QCheckBox(name(), parent); - check_box_->setCheckState(value ? Qt::Checked : Qt::Unchecked); + check_box_->setToolTip(desc()); + + update_widget(); if (auto_commit) connect(check_box_, SIGNAL(stateChanged(int)), @@ -67,6 +61,20 @@ bool Bool::labeled_widget() const return true; } +void Bool::update_widget() +{ + if (!check_box_) + return; + + Glib::VariantBase variant = getter_(); + assert(variant.gobj()); + + bool value = Glib::VariantBase::cast_dynamic>( + variant).get(); + + check_box_->setCheckState(value ? Qt::Checked : Qt::Unchecked); +} + void Bool::commit() { assert(setter_); @@ -83,5 +91,5 @@ void Bool::on_state_changed(int) commit(); } -} // prop -} // pv +} // namespace prop +} // namespace pv