+QMenu* DecodeTrace::create_view_context_menu(QWidget *parent, QPoint &click_pos)
+{
+ try {
+ selected_row_ = &visible_rows_[get_row_at_point(click_pos)];
+ } catch (out_of_range&) {
+ selected_row_ = nullptr;
+ }
+
+ // Default sample range is "from here"
+ const pair<uint64_t, uint64_t> sample_range =
+ get_view_sample_range(click_pos.x(), click_pos.x() + 1);
+ selected_sample_range_ = make_pair(sample_range.first, numeric_limits<uint64_t>::max());
+
+ QMenu *const menu = new QMenu(parent);
+
+ if (decode_signal_->is_paused()) {
+ QAction *const resume =
+ new QAction(tr("Resume decoding"), this);
+ resume->setIcon(QIcon::fromTheme("media-playback-start",
+ QIcon(":/icons/media-playback-start.png")));
+ connect(resume, SIGNAL(triggered()), this, SLOT(on_pause_decode()));
+ menu->addAction(resume);
+ } else {
+ QAction *const pause =
+ new QAction(tr("Pause decoding"), this);
+ pause->setIcon(QIcon::fromTheme("media-playback-pause",
+ QIcon(":/icons/media-playback-pause.png")));
+ connect(pause, SIGNAL(triggered()), this, SLOT(on_pause_decode()));
+ menu->addAction(pause);
+ }
+
+ menu->addSeparator();
+
+ QAction *const export_all_rows =
+ new QAction(tr("Export all annotations"), this);
+ export_all_rows->setIcon(QIcon::fromTheme("document-save-as",
+ QIcon(":/icons/document-save-as.png")));
+ connect(export_all_rows, SIGNAL(triggered()), this, SLOT(on_export_all_rows()));
+ menu->addAction(export_all_rows);
+
+ QAction *const export_row =
+ new QAction(tr("Export all annotations for this row"), this);
+ export_row->setIcon(QIcon::fromTheme("document-save-as",
+ QIcon(":/icons/document-save-as.png")));
+ connect(export_row, SIGNAL(triggered()), this, SLOT(on_export_row()));
+ menu->addAction(export_row);
+
+ menu->addSeparator();
+
+ QAction *const export_all_rows_from_here =
+ new QAction(tr("Export all annotations, starting here"), this);
+ export_all_rows_from_here->setIcon(QIcon::fromTheme("document-save-as",
+ QIcon(":/icons/document-save-as.png")));
+ connect(export_all_rows_from_here, SIGNAL(triggered()), this, SLOT(on_export_all_rows_from_here()));
+ menu->addAction(export_all_rows_from_here);
+
+ QAction *const export_row_from_here =
+ new QAction(tr("Export annotations for this row, starting here"), this);
+ export_row_from_here->setIcon(QIcon::fromTheme("document-save-as",
+ QIcon(":/icons/document-save-as.png")));
+ connect(export_row_from_here, SIGNAL(triggered()), this, SLOT(on_export_row_from_here()));
+ menu->addAction(export_row_from_here);
+
+ menu->addSeparator();
+
+ QAction *const export_all_rows_with_cursor =
+ new QAction(tr("Export all annotations within cursor range"), this);
+ export_all_rows_with_cursor->setIcon(QIcon::fromTheme("document-save-as",
+ QIcon(":/icons/document-save-as.png")));
+ connect(export_all_rows_with_cursor, SIGNAL(triggered()), this, SLOT(on_export_all_rows_with_cursor()));
+ menu->addAction(export_all_rows_with_cursor);
+
+ QAction *const export_row_with_cursor =
+ new QAction(tr("Export annotations for this row within cursor range"), this);
+ export_row_with_cursor->setIcon(QIcon::fromTheme("document-save-as",
+ QIcon(":/icons/document-save-as.png")));
+ connect(export_row_with_cursor, SIGNAL(triggered()), this, SLOT(on_export_row_with_cursor()));
+ menu->addAction(export_row_with_cursor);
+
+ const View *view = owner_->view();
+ assert(view);
+
+ if (!view->cursors()->enabled()) {
+ export_all_rows_with_cursor->setEnabled(false);
+ export_row_with_cursor->setEnabled(false);
+ }
+
+ return menu;
+}
+