]> sigrok.org Git - pulseview.git/commitdiff
Binding: Add help icons for entries with descriptions
authorSoeren Apel <redacted>
Tue, 4 Sep 2018 20:39:57 +0000 (22:39 +0200)
committerUwe Hermann <redacted>
Wed, 5 Sep 2018 22:25:00 +0000 (00:25 +0200)
icons/help-browser.png [new file with mode: 0644]
manual/import_export.txt
pulseview.qrc
pv/binding/binding.cpp
pv/binding/binding.hpp
pv/binding/device.hpp
pv/binding/inputoutput.cpp

diff --git a/icons/help-browser.png b/icons/help-browser.png
new file mode 100644 (file)
index 0000000..593ecd5
Binary files /dev/null and b/icons/help-browser.png differ
index b3ba7726ab47ac28e0dfce59d3b0a018b4adde05..2e5c8b226bb978cf18be790ed7bce3f24017312a 100644 (file)
@@ -24,8 +24,9 @@ For example, the VCD import will ask you for these:
 * Number of logic channels: The number of (logic) channels in the data (default 0)
 * Skip samples until timestamp: Skip samples until the specified timestamp; < 0: Skip until first timestamp listed; 0: Don't skip (default -1)
 
 * Number of logic channels: The number of (logic) channels in the data (default 0)
 * Skip samples until timestamp: Skip samples until the specified timestamp; < 0: Skip until first timestamp listed; 0: Don't skip (default -1)
 
-
-A click on _Ok_ then loads the data from the selected file and you can work with it.
+The detailed description of each item can also be seen when clicking on the help icon on the right
+or hovering your mouse over it. A click on _OK_ then loads the data from the selected file and you
+can work with it.
 
 === Export
 
 
 === Export
 
index 4087fad9fc13de22146457bbf0f17cbbffdbecdd..9b7510d2f76b99d35cddb215b503b46740adeba2 100644 (file)
@@ -9,6 +9,7 @@
        <file>icons/document-new.png</file>
        <file>icons/document-open.png</file>
        <file>icons/document-save-as.png</file>
        <file>icons/document-new.png</file>
        <file>icons/document-open.png</file>
        <file>icons/document-save-as.png</file>
+       <file>icons/help-browser.png</file>
        <file>icons/information.svg</file>
        <file>icons/media-playback-pause.png</file>
        <file>icons/media-playback-start.png</file>
        <file>icons/information.svg</file>
        <file>icons/media-playback-pause.png</file>
        <file>icons/media-playback-start.png</file>
index ddf0c19a213580846b974ad36fb90a54aede7f94..9735e14681edaa6d9f1b6bdd642f76ba8db694d8 100644 (file)
 #include <cassert>
 
 #include <QFormLayout>
 #include <cassert>
 
 #include <QFormLayout>
+#include <QHBoxLayout>
+#include <QIcon>
 #include <QLabel>
 #include <QLabel>
+#include <QPushButton>
 
 #include <pv/prop/property.hpp>
 
 
 #include <pv/prop/property.hpp>
 
@@ -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);
 
 {
        assert(layout);
 
+       help_labels_.clear();
+
        for (shared_ptr<pv::prop::Property> p : properties_) {
                assert(p);
 
        for (shared_ptr<pv::prop::Property> 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());
                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);
                }
                        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);
 {
        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;
 }
 
        return s;
 }
 
+void Binding::on_help_clicked()
+{
+       QPushButton *btn = qobject_cast<QPushButton*>(QObject::sender());
+       assert(btn);
+
+       QLabel *lbl = help_labels_.at(btn);
+       lbl->setVisible(!lbl->isVisible());
+}
+
 }  // namespace binding
 }  // namespace pv
 }  // namespace binding
 }  // namespace pv
index 6e92b08393694af4b593f859af7e449021527abb..5580a0b05b48765d74fd9272beafe4e38ddc2ca8 100644 (file)
@@ -26,15 +26,19 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 #include <glibmm.h>
 G_GNUC_END_IGNORE_DEPRECATIONS
 
 #include <glibmm.h>
 G_GNUC_END_IGNORE_DEPRECATIONS
 
+#include <map>
 #include <memory>
 #include <vector>
 
 #include <memory>
 #include <vector>
 
+#include <QObject>
 #include <QString>
 
 #include <QString>
 
+using std::map;
 using std::shared_ptr;
 using std::vector;
 
 class QFormLayout;
 using std::shared_ptr;
 using std::vector;
 
 class QFormLayout;
+class QLabel;
 class QWidget;
 
 namespace pv {
 class QWidget;
 
 namespace pv {
@@ -45,25 +49,29 @@ class Property;
 
 namespace binding {
 
 
 namespace binding {
 
-class Binding
+class Binding: public QObject
 {
 {
+       Q_OBJECT
+
 public:
        const vector< shared_ptr<prop::Property> >& properties();
 
        void commit();
 
 public:
        const vector< shared_ptr<prop::Property> >& properties();
 
        void commit();
 
-       void add_properties_to_form(QFormLayout *layout,
-               bool auto_commit = false) const;
+       void add_properties_to_form(QFormLayout *layout, bool auto_commit = false);
 
 
-       QWidget* get_property_form(QWidget *parent,
-               bool auto_commit = false) const;
+       QWidget* get_property_form(QWidget *parent, bool auto_commit = false);
 
        void update_property_widgets();
 
        static QString print_gvariant(Glib::VariantBase gvar);
 
 
        void update_property_widgets();
 
        static QString print_gvariant(Glib::VariantBase gvar);
 
+protected Q_SLOTS:
+       void on_help_clicked();
+
 protected:
        vector< shared_ptr<prop::Property> > properties_;
 protected:
        vector< shared_ptr<prop::Property> > properties_;
+       map<QWidget*, QLabel*> help_labels_;
 };
 
 }  // namespace binding
 };
 
 }  // namespace binding
index aceac8cc6f2fc3346f1c36de9c58c5b6b58d081b..d4fbf3714ba040236cb055488a5dbc2fd4014a5a 100644 (file)
@@ -42,7 +42,7 @@ namespace pv {
 
 namespace binding {
 
 
 namespace binding {
 
-class Device : public QObject, public Binding
+class Device : public Binding
 {
        Q_OBJECT
 
 {
        Q_OBJECT
 
index 4aa0c0eabd13aac1a99105340d2a7a28fec49af7..0d9b2d0d72298bc66e18c5f0faa40615c36d091e 100644 (file)
@@ -65,6 +65,7 @@ InputOutput::InputOutput(
 
                const QString name = QString::fromStdString(opt->name());
                const QString desc = QString::fromStdString(opt->description());
 
                const QString name = QString::fromStdString(opt->name());
                const QString desc = QString::fromStdString(opt->description());
+
                const VariantBase def_val = opt->default_value();
                const vector<VariantBase> values = opt->values();
 
                const VariantBase def_val = opt->default_value();
                const vector<VariantBase> values = opt->values();