X-Git-Url: http://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fbinding%2Fbinding.cpp;fp=pv%2Fbinding%2Fbinding.cpp;h=9735e14681edaa6d9f1b6bdd642f76ba8db694d8;hp=ddf0c19a213580846b974ad36fb90a54aede7f94;hb=4e2195c8d934f7f874b612eaace8c6849e8b475d;hpb=1894027b98640702a5229c4168c586df5f83a3af diff --git a/pv/binding/binding.cpp b/pv/binding/binding.cpp index ddf0c19a..9735e146 100644 --- a/pv/binding/binding.cpp +++ b/pv/binding/binding.cpp @@ -20,7 +20,10 @@ #include #include +#include +#include #include +#include #include @@ -46,27 +49,56 @@ void Binding::commit() } } -void Binding::add_properties_to_form(QFormLayout *layout, - bool auto_commit) const +void Binding::add_properties_to_form(QFormLayout *layout, bool auto_commit) { assert(layout); + help_labels_.clear(); + for (shared_ptr p : properties_) { assert(p); - QWidget *const widget = p->get_widget(layout->parentWidget(), auto_commit); + QWidget *widget; + QLabel *help_lbl = nullptr; + + if (p->desc().isEmpty()) { + widget = p->get_widget(layout->parentWidget(), auto_commit); + } else { + QPushButton *help_btn = new QPushButton(); + help_btn->setFlat(true); + help_btn->setIcon(QIcon(":/icons/help-browser.png")); + help_btn->setToolTip(p->desc()); + connect(help_btn, SIGNAL(clicked(bool)), + this, SLOT(on_help_clicked())); + + QHBoxLayout *layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(p->get_widget(layout->parentWidget(), auto_commit)); + layout->addWidget(help_btn, 0, Qt::AlignRight); + + widget = new QWidget(); + widget->setLayout(layout); + + help_lbl = new QLabel(p->desc()); + help_lbl->setVisible(false); + help_lbl->setWordWrap(true); + help_labels_[help_btn] = help_lbl; + } + if (p->labeled_widget()) { layout->addRow(widget); } else { auto *lbl = new QLabel(p->name()); - lbl->setToolTip(p->desc()); + lbl->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layout->addRow(lbl, widget); } + + if (help_lbl) + layout->addRow(help_lbl); } } -QWidget* Binding::get_property_form(QWidget *parent, - bool auto_commit) const +QWidget* Binding::get_property_form(QWidget *parent, bool auto_commit) { QWidget *const form = new QWidget(parent); QFormLayout *const layout = new QFormLayout(form); @@ -98,5 +130,14 @@ QString Binding::print_gvariant(Glib::VariantBase gvar) return s; } +void Binding::on_help_clicked() +{ + QPushButton *btn = qobject_cast(QObject::sender()); + assert(btn); + + QLabel *lbl = help_labels_.at(btn); + lbl->setVisible(!lbl->isVisible()); +} + } // namespace binding } // namespace pv