DecoderSelector: Put body label into a QScrollArea
[pulseview.git] / pv / subwindows / decoder_selector / subwindow.cpp
index 6302e44976fcfad031452d48ef4bc0df2842c691..675e135cefad3f682e4609f71cc1f8eadcd55d60 100644 (file)
@@ -24,6 +24,7 @@
 #include <QLabel>
 #include <QLineEdit>
 #include <QPushButton>
+#include <QScrollArea>
 #include <QVBoxLayout>
 
 #include "pv/session.hpp"
@@ -105,15 +106,29 @@ SubWindow::SubWindow(Session& session, QWidget* parent) :
        // Hide the columns that hold the detailed item information
        tree_view_->hideColumn(2);  // ID
 
+       // Ensure that all decoder tag names are fully visible by default
+       tree_view_->resizeColumnToContents(0);
+
+       tree_view_->setIndentation(10);
+
+       QScrollArea* info_label_body_container = new QScrollArea();
+       info_label_body_container->setWidget(info_label_body_);
+       info_label_body_container->setWidgetResizable(true);
+
        info_box_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        QVBoxLayout* info_box_layout = new QVBoxLayout(info_box_);
        info_box_layout->addWidget(info_label_header_);
-       info_box_layout->addWidget(info_label_body_);
+       info_box_layout->addWidget(info_label_body_container);
        info_box_layout->addWidget(info_label_footer_);
+       info_box_layout->setAlignment(Qt::AlignTop);
+       Qt::TextInteractionFlags flags = Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard;
        info_label_header_->setWordWrap(true);
+       info_label_header_->setTextInteractionFlags(flags);
        info_label_body_->setWordWrap(true);
+       info_label_body_->setTextInteractionFlags(flags);
        info_label_body_->setText(tr("Select a decoder to see its description here."));
        info_label_footer_->setWordWrap(true);
+       info_label_footer_->setTextInteractionFlags(flags);
 
        connect(filter, SIGNAL(textChanged(const QString&)),
                this, SLOT(on_filter_changed(const QString&)));
@@ -184,7 +199,7 @@ void SubWindow::on_item_changed(const QModelIndex& index)
        const QString id = QString::fromUtf8(d->id);
        const QString longname = QString::fromUtf8(d->longname);
        const QString desc = QString::fromUtf8(d->desc);
-       const QString doc = QString::fromUtf8(srd_decoder_doc_get(d));
+       const QString doc = QString::fromUtf8(srd_decoder_doc_get(d)).trimmed();
 
        QString tags;
        for (GSList* li = (GSList*)d->tags; li; li = li->next) {
@@ -194,7 +209,7 @@ void SubWindow::on_item_changed(const QModelIndex& index)
                tags.append(s);
        }
 
-       info_label_header_->setText(QString("<span style='font-size:large;font-weight:bold'>%1 (%2)</span><br>%3")
+       info_label_header_->setText(QString("<span style='font-size:large'><b>%1 (%2)</b></span><br><i>%3</i>")
                .arg(longname, id, desc));
        info_label_body_->setText(doc);
        info_label_footer_->setText(tr("<p align='right'>Tags: %1</p>").arg(tags));