Integration Popup into Trace
[pulseview.git] / pv / view / header.cpp
index 549b71918627b4bd1a6d0e01f2e20f6fe17994f6..f8f5b6380514ac2604730ce0a687c0c469fff04a 100644 (file)
@@ -34,6 +34,8 @@
 #include <QPainter>
 #include <QRect>
 
+#include <pv/widgets/popup.h>
+
 using namespace boost;
 using namespace std;
 
@@ -151,11 +153,28 @@ void Header::mousePressEvent(QMouseEvent *event)
 
 void Header::mouseReleaseEvent(QMouseEvent *event)
 {
+       using pv::widgets::Popup;
+
        assert(event);
        if (event->button() == Qt::LeftButton) {
+               if (_dragging)
+                       _view.normalize_layout();
+               else
+               {
+                       const shared_ptr<Trace> mouse_over_trace =
+                               get_mouse_over_trace(event->pos());
+                       if (mouse_over_trace) {
+                               Popup *const p =
+                                       mouse_over_trace->create_popup(&_view);
+                               p->set_position(mapToGlobal(QPoint(width(),
+                                       mouse_over_trace->get_y())),
+                                       Popup::Right);
+                               p->show();
+                       }
+               }
+
                _dragging = false;
                _drag_traces.clear();
-               _view.normalize_layout();
        }
 }