]> sigrok.org Git - pulseview.git/commitdiff
Ruler: Add "toggle mouse hover marker" to context menu
authorSoeren Apel <redacted>
Wed, 10 Oct 2018 18:13:57 +0000 (20:13 +0200)
committerSoeren Apel <redacted>
Sat, 13 Oct 2018 13:37:04 +0000 (15:37 +0200)
pv/views/trace/ruler.cpp
pv/views/trace/ruler.hpp

index 7688f2b7e1c0262fc12a89e82e2ee6c75b5605d2..a085de29123cba27181414134c5e0673f2d642f7 100644 (file)
@@ -24,6 +24,8 @@
 #include <QMenu>
 #include <QMouseEvent>
 
+#include <pv/globalsettings.hpp>
+
 #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
index 61e622ac7afa350bf7ea1cfd1852fa465f7cf4b8..8c1876cced37f5e2598f655a51e309eff0c4fbd7 100644 (file)
@@ -176,6 +176,7 @@ private Q_SLOTS:
        void invalidate_tick_position_cache();
 
        void on_createMarker();
+       void on_toggleHoverMarker();
 
 private:
        /**