From: Soeren Apel Date: Wed, 10 Oct 2018 18:13:57 +0000 (+0200) Subject: Ruler: Add "toggle mouse hover marker" to context menu X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4bc9230c442427a27a3934ce5ff6ff4fdd4e0855;p=pulseview.git Ruler: Add "toggle mouse hover marker" to context menu --- diff --git a/pv/views/trace/ruler.cpp b/pv/views/trace/ruler.cpp index 7688f2b7..a085de29 100644 --- a/pv/views/trace/ruler.cpp +++ b/pv/views/trace/ruler.cpp @@ -24,6 +24,8 @@ #include #include +#include + #include "ruler.hpp" #include "view.hpp" @@ -127,6 +129,16 @@ void Ruler::contextMenuEvent(QContextMenuEvent *event) connect(create_marker, SIGNAL(triggered()), this, SLOT(on_createMarker())); menu->addAction(create_marker); + QAction *const toggle_hover_marker = new QAction(this); + connect(toggle_hover_marker, SIGNAL(triggered()), this, SLOT(on_toggleHoverMarker())); + menu->addAction(toggle_hover_marker); + + GlobalSettings settings; + const bool hover_marker_shown = + settings.value(GlobalSettings::Key_View_ShowHoverMarker).toBool(); + toggle_hover_marker->setText(hover_marker_shown ? + tr("Disable mouse hover marker") : tr("Enable mouse hover marker")); + menu->popup(event->globalPos()); } @@ -309,6 +321,13 @@ void Ruler::on_createMarker() view_.add_flag(get_time_from_x_pos(context_menu_x_pos_)); } +void Ruler::on_toggleHoverMarker() +{ + GlobalSettings settings; + const bool state = settings.value(GlobalSettings::Key_View_ShowHoverMarker).toBool(); + settings.setValue(GlobalSettings::Key_View_ShowHoverMarker, !state); +} + } // namespace trace } // namespace views } // namespace pv diff --git a/pv/views/trace/ruler.hpp b/pv/views/trace/ruler.hpp index 61e622ac..8c1876cc 100644 --- a/pv/views/trace/ruler.hpp +++ b/pv/views/trace/ruler.hpp @@ -176,6 +176,7 @@ private Q_SLOTS: void invalidate_tick_position_cache(); void on_createMarker(); + void on_toggleHoverMarker(); private: /**