X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fcursor.cpp;h=80eaba232b1d8157b2bbfacbb40ebe202e79670a;hb=20c99cfc69d3c7430817abd9a1f810698deb4a18;hp=88c4ebfdca52172c12f609c1eba9c1cb0fee7018;hpb=20f59e957e70250cfb876ac7a1743134d6b83339;p=pulseview.git diff --git a/pv/views/trace/cursor.cpp b/pv/views/trace/cursor.cpp index 88c4ebfd..80eaba23 100644 --- a/pv/views/trace/cursor.cpp +++ b/pv/views/trace/cursor.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -41,10 +42,10 @@ namespace pv { namespace views { namespace trace { -const QColor Cursor::FillColour(52, 101, 164); +const QColor Cursor::FillColor(52, 101, 164); Cursor::Cursor(View &view, double time) : - TimeMarker(view, FillColour, time) + TimeMarker(view, FillColor, time) { } @@ -59,7 +60,8 @@ QString Cursor::get_text() const const pv::util::Timestamp& diff = abs(time_ - other->time_); return Ruler::format_time_with_distance( - diff, time_, view_.tick_prefix(), view_.time_unit(), view_.tick_precision()); + diff, view_.ruler()->get_ruler_time_from_absolute_time(time_), + view_.tick_prefix(), view_.time_unit(), view_.tick_precision()); } QRectF Cursor::label_rect(const QRectF &rect) const @@ -88,6 +90,19 @@ QRectF Cursor::label_rect(const QRectF &rect) const return QRectF(x - label_size.width(), top, label_size.width(), height); } +QMenu *Cursor::create_header_context_menu(QWidget *parent) +{ + QMenu *const menu = new QMenu(parent); + + QAction *const snap_disable = new QAction(tr("Disable snapping"), this); + snap_disable->setCheckable(true); + snap_disable->setChecked(snapping_disabled_); + connect(snap_disable, &QAction::toggled, this, [=](bool checked){snapping_disabled_ = checked;}); + menu->addAction(snap_disable); + + return menu; +} + shared_ptr Cursor::get_other_cursor() const { const shared_ptr cursors(view_.cursors());