From: Soeren Apel Date: Sun, 28 Oct 2018 22:26:25 +0000 (+0100) Subject: Ruler: Fix context menu for items on the ruler X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=dde5aab3c1c55ef4bf7b255b976b23320bad384f;p=pulseview.git Ruler: Fix context menu for items on the ruler --- diff --git a/pv/views/trace/marginwidget.cpp b/pv/views/trace/marginwidget.cpp index f0d50c97..86ec069b 100644 --- a/pv/views/trace/marginwidget.cpp +++ b/pv/views/trace/marginwidget.cpp @@ -53,13 +53,17 @@ void MarginWidget::show_popup(const shared_ptr &item) void MarginWidget::contextMenuEvent(QContextMenuEvent *event) { + event->setAccepted(false); + const shared_ptr r = get_mouse_over_item(mouse_point_); if (!r) return; QMenu *menu = r->create_header_context_menu(this); - if (menu) + if (menu) { + event->setAccepted(true); menu->popup(event->globalPos()); + } } void MarginWidget::keyPressEvent(QKeyEvent *event) diff --git a/pv/views/trace/ruler.cpp b/pv/views/trace/ruler.cpp index 6e74ddd0..acea8a36 100644 --- a/pv/views/trace/ruler.cpp +++ b/pv/views/trace/ruler.cpp @@ -121,6 +121,12 @@ pv::util::Timestamp Ruler::get_time_from_x_pos(uint32_t x) const void Ruler::contextMenuEvent(QContextMenuEvent *event) { + MarginWidget::contextMenuEvent(event); + + // Don't show a context menu if the MarginWidget found a widget that shows one + if (event->isAccepted()) + return; + context_menu_x_pos_ = event->pos().x(); QMenu *const menu = new QMenu(this); @@ -143,6 +149,7 @@ void Ruler::contextMenuEvent(QContextMenuEvent *event) toggle_hover_marker->setText(hover_marker_shown ? tr("Disable mouse hover marker") : tr("Enable mouse hover marker")); + event->setAccepted(true); menu->popup(event->globalPos()); }