]> sigrok.org Git - pulseview.git/commitdiff
Ruler: Added context menu support
authorJoel Holdsworth <redacted>
Sat, 20 Dec 2014 18:44:44 +0000 (18:44 +0000)
committerJoel Holdsworth <redacted>
Mon, 29 Dec 2014 11:56:00 +0000 (11:56 +0000)
pv/view/ruler.cpp
pv/view/ruler.hpp

index 160f1acbd9ce63babf15e337616502d6a28d7631..bcf6a5281d494195b97bfc6c152dfc59227453f1 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <QApplication>
 #include <QFontMetrics>
+#include <QMenu>
 #include <QMouseEvent>
 
 #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<TimeItem> 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);
index 7054268d586c4c6d20fd542f1503a0fa564d0925..cfba0489c213c0554df35707aaac97585b4b75d6 100644 (file)
@@ -74,6 +74,8 @@ private:
 
        void mouseDoubleClickEvent(QMouseEvent *e);
 
+       void contextMenuEvent(QContextMenuEvent *event);
+
        void keyPressEvent(QKeyEvent *e);
 
 private: