QPoint pos = event->pos() - QPoint(0, ruler_->sizeHint().height());
const shared_ptr<ViewItem> r = viewport_->get_mouse_over_item(pos);
- if (!r)
- return;
- QMenu *menu = r->create_view_context_menu(this, pos);
+ QMenu* menu = nullptr;
+
+ if (!r) {
+ context_menu_x_pos_ = pos.x();
+
+ // No view item under cursor, use generic menu
+ menu = new QMenu(this);
+
+ QAction *const create_marker_here = new QAction(tr("Create marker here"), this);
+ connect(create_marker_here, SIGNAL(triggered()), this, SLOT(on_create_marker_here()));
+ menu->addAction(create_marker_here);
+ } else {
+ menu = r->create_view_context_menu(this, pos);
+ }
+
if (menu)
menu->popup(event->globalPos());
}
}
}
+void View::on_create_marker_here()
+{
+ const QPoint p = ruler_->mapFrom(this, QPoint(context_menu_x_pos_, 0));
+
+ add_flag(ruler_->get_absolute_time_from_x_pos(p.x()));
+}
+
void View::on_settingViewTriggerIsZeroTime_changed(const QVariant new_value)
{
(void)new_value;
void on_settingViewTriggerIsZeroTime_changed(const QVariant new_value);
+ void on_create_marker_here();
+
virtual void perform_delayed_view_update();
void process_sticky_events();
// These are used to determine whether the view was altered after acq started
double scale_at_acq_start_;
pv::util::Timestamp offset_at_acq_start_;
+
+ // X coordinate of mouse cursor where the user clicked to open a context menu
+ uint32_t context_menu_x_pos_;
};
} // namespace trace