]> sigrok.org Git - pulseview.git/commitdiff
Update cursor action's state whenever the cursor state changes
authorSoeren Apel <redacted>
Sat, 2 Jun 2018 19:52:24 +0000 (21:52 +0200)
committerUwe Hermann <redacted>
Sun, 3 Jun 2018 17:02:28 +0000 (19:02 +0200)
pv/views/trace/standardbar.cpp
pv/views/trace/standardbar.hpp
pv/views/trace/view.cpp
pv/views/trace/view.hpp

index 382e9f31a347ec05de5ad468c5276110edd8142a..35b87be51b904869c7720276675477805e53a6eb 100644 (file)
@@ -133,6 +133,9 @@ StandardBar::StandardBar(Session &session, QWidget *parent,
        connect(view_, SIGNAL(always_zoom_to_fit_changed(bool)),
                this, SLOT(on_always_zoom_to_fit_changed(bool)));
 
+       connect(view_, SIGNAL(cursor_state_changed(bool)),
+               this, SLOT(on_cursor_state_changed(bool)));
+
        if (add_default_widgets)
                add_toolbar_widgets();
 }
@@ -216,7 +219,8 @@ void StandardBar::on_actionViewZoomOneToOne_triggered()
 
 void StandardBar::on_actionViewShowCursors_triggered()
 {
-       const bool show = !view_->cursors_shown();
+       const bool show = action_view_show_cursors_->isChecked();
+
        if (show)
                view_->centre_cursors();
 
@@ -308,6 +312,11 @@ void StandardBar::on_segment_display_mode_changed(int mode, bool segment_selecta
        }
 }
 
+void StandardBar::on_cursor_state_changed(bool show)
+{
+       action_view_show_cursors_->setChecked(show);
+}
+
 } // namespace trace
 } // namespace views
 } // namespace pv
index 060a7ef55a3ee90285eb2beb757a50fba12b39d9..6e822229e3aebc8ab43e4d27f99444ab5318315b 100644 (file)
@@ -96,6 +96,7 @@ protected Q_SLOTS:
        void on_actionViewZoomOneToOne_triggered();
 
        void on_actionViewShowCursors_triggered();
+       void on_cursor_state_changed(bool show);
 
        void on_actionSDMLast_triggered();
        void on_actionSDMLastComplete_triggered();
index 2837e57fae3332e84ade1bfe8a50dd28c4acab12..f634b4ae532966be2c08ae793bdb88df0aa3bb88 100644 (file)
@@ -246,6 +246,7 @@ void View::reset_view_state()
        suppress_zoom_to_fit_after_acq_ = false;
 
        show_cursors_ = false;
+       cursor_state_changed(show_cursors_);
        flags_.clear();
 
        // Update the zoom state
@@ -815,6 +816,7 @@ bool View::cursors_shown() const
 void View::show_cursors(bool show)
 {
        show_cursors_ = show;
+       cursor_state_changed(show);
        ruler_->update();
        viewport_->update();
 }
index a9e5564f1838d404b104e960f71e240aa25f1244..1551bc0b13a09ce8e3f5e95c412fa997bc20d228 100644 (file)
@@ -343,6 +343,9 @@ Q_SIGNALS:
        /// @param mode is a value of Trace::SegmentDisplayMode
        void segment_display_mode_changed(int mode, bool segment_selectable);
 
+       /// Emitted when the cursors are shown/hidden
+       void cursor_state_changed(bool show);
+
 public Q_SLOTS:
        void trigger_event(int segment_id, util::Timestamp location);