]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/view.cpp
Fix regression introduced by 2980ff2da269c9ed
[pulseview.git] / pv / views / trace / view.cpp
index 0070c743e8d13de97747b356aeb49d287cc847cc..65b06aea82cba76279f185f40b4af933578a18dd 100644 (file)
@@ -38,6 +38,7 @@
 #include <QApplication>
 #include <QEvent>
 #include <QFontMetrics>
+#include <QMenu>
 #include <QMouseEvent>
 #include <QScrollBar>
 #include <QVBoxLayout>
@@ -385,7 +386,7 @@ void View::restore_settings(QSettings &settings)
                        boost::archive::text_iarchive ia(ss);
                        ia >> boost::serialization::make_nvp("ruler_shift", shift);
                        ruler_shift_ = shift;
-               } catch (boost::archive::archive_exception) {
+               } catch (boost::archive::archive_exception&) {
                        qDebug() << "Could not restore the view ruler shift";
                }
        }
@@ -400,7 +401,7 @@ void View::restore_settings(QSettings &settings)
                        ia >> boost::serialization::make_nvp("offset", offset);
                        // This also updates ruler_offset_
                        set_offset(offset);
-               } catch (boost::archive::archive_exception) {
+               } catch (boost::archive::archive_exception&) {
                        qDebug() << "Could not restore the view offset";
                }
        }
@@ -874,6 +875,11 @@ void View::restack_all_trace_tree_items()
                i->animate_to_layout_v_offset();
 }
 
+int View::header_width() const
+{
+        return header_->extended_size_hint().width();
+}
+
 void View::on_setting_changed(const QString &key, const QVariant &value)
 {
        if (key == GlobalSettings::Key_View_TriggerIsZeroTime)
@@ -1086,12 +1092,11 @@ void View::set_scroll_default()
 void View::determine_if_header_was_shrunk()
 {
        const int header_pane_width = splitter_->sizes().front();
-       const int header_width = header_->extended_size_hint().width();
 
        // Allow for a slight margin of error so that we also accept
        // slight differences when e.g. a label name change increased
        // the overall width
-       header_was_shrunk_ = (header_pane_width < (header_width - 10));
+       header_was_shrunk_ = (header_pane_width < (header_width() - 10));
 }
 
 void View::resize_header_to_fit()
@@ -1251,6 +1256,19 @@ bool View::eventFilter(QObject *object, QEvent *event)
        return QObject::eventFilter(object, event);
 }
 
+void View::contextMenuEvent(QContextMenuEvent *event)
+{
+       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);
+       if (menu)
+               menu->exec(event->globalPos());
+}
+
 void View::resizeEvent(QResizeEvent* event)
 {
        // Only adjust the top margin if we shrunk vertically
@@ -1297,6 +1315,7 @@ void View::extents_changed(bool horz, bool vert)
                (horz ? TraceTreeItemHExtentsChanged : 0) |
                (vert ? TraceTreeItemVExtentsChanged : 0);
 
+       lazy_event_handler_.stop();
        lazy_event_handler_.start();
 }