From: Joel Holdsworth Date: Sat, 20 Dec 2014 18:44:44 +0000 (+0000) Subject: Ruler: Added context menu support X-Git-Tag: pulseview-0.3.0~324 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=115a522abb9dc4071f62a3df77b9501e1f9ff722;p=pulseview.git Ruler: Added context menu support --- diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index 160f1acb..bcf6a528 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include "ruler.hpp" @@ -229,6 +230,17 @@ void Ruler::mouseDoubleClickEvent(QMouseEvent *e) view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale()); } +void Ruler::contextMenuEvent(QContextMenuEvent *event) +{ + const shared_ptr r = get_mouse_over_item(mouse_point_); + if (!r) + return; + + QMenu *menu = r->create_context_menu(this); + if (menu) + menu->exec(event->globalPos()); +} + void Ruler::keyPressEvent(QKeyEvent *e) { assert(e); diff --git a/pv/view/ruler.hpp b/pv/view/ruler.hpp index 7054268d..cfba0489 100644 --- a/pv/view/ruler.hpp +++ b/pv/view/ruler.hpp @@ -74,6 +74,8 @@ private: void mouseDoubleClickEvent(QMouseEvent *e); + void contextMenuEvent(QContextMenuEvent *event); + void keyPressEvent(QKeyEvent *e); private: