]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/decodetrace.cpp
Fix #1451 by only using decoder tags if they're available
[pulseview.git] / pv / views / trace / decodetrace.cpp
index f7f60a28b49d9586c539bf4c4c8875fe7a9a46db..e14b4ecbf433469467c5b820eabf534aac04e1c7 100644 (file)
@@ -70,7 +70,7 @@ using std::vector;
 
 using pv::data::decode::Annotation;
 using pv::data::decode::Row;
-using pv::data::DecodeChannel;
+using pv::data::decode::DecodeChannel;
 using pv::data::DecodeSignal;
 
 namespace pv {
@@ -198,9 +198,11 @@ void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp)
        for (const Row& row : rows) {
                // Cache the row title widths
                int row_title_width;
-               try {
-                       row_title_width = row_title_widths_.at(row);
-               } catch (out_of_range&) {
+               auto cached_width = row_title_widths_.find(row);
+
+               if (cached_width != row_title_widths_.end())
+                       row_title_width = cached_width->second;
+               else {
                        const int w = p.boundingRect(QRectF(), 0, row.title()).width() +
                                RowTitleMargin;
                        row_title_widths_[row] = w;
@@ -288,6 +290,8 @@ void DecodeTrace::update_stack_button()
                        connect(decoder_menu, SIGNAL(decoder_selected(srd_decoder*)),
                                this, SLOT(on_stack_decoder(srd_decoder*)));
 
+                       decoder_menu->setStyleSheet("QMenu { menu-scrollable: 1; }");
+
                        stack_button_->setMenu(decoder_menu);
                        stack_button_->show();
                        return;
@@ -408,7 +412,7 @@ QMenu* DecodeTrace::create_view_context_menu(QWidget *parent, QPoint &click_pos)
        QAction *const copy_annotation_to_clipboard =
                new QAction(tr("Copy annotation text to clipboard"), this);
        copy_annotation_to_clipboard->setIcon(QIcon::fromTheme("edit-paste",
-               QIcon(":/icons/edit-paste.png")));
+               QIcon(":/icons/edit-paste.svg")));
        connect(copy_annotation_to_clipboard, SIGNAL(triggered()), this, SLOT(on_copy_annotation_to_clipboard()));
        menu->addAction(copy_annotation_to_clipboard);
 
@@ -1215,8 +1219,11 @@ void DecodeTrace::on_copy_annotation_to_clipboard()
        if (annotations->empty())
                return;
 
-       QClipboard *clipboard = QGuiApplication::clipboard();
-       clipboard->setText(annotations->front().annotations().front());
+       QClipboard *clipboard = QApplication::clipboard();
+       clipboard->setText(annotations->front().annotations().front(), QClipboard::Clipboard);
+
+       if (clipboard->supportsSelection())
+               clipboard->setText(annotations->front().annotations().front(), QClipboard::Selection);
 
        delete annotations;
 }