From: Soeren Apel Date: Sat, 2 Jun 2018 19:52:24 +0000 (+0200) Subject: Update cursor action's state whenever the cursor state changes X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e4e5a958507a2c4e2643f21e3c735021da97e577;p=pulseview.git Update cursor action's state whenever the cursor state changes --- diff --git a/pv/views/trace/standardbar.cpp b/pv/views/trace/standardbar.cpp index 382e9f31..35b87be5 100644 --- a/pv/views/trace/standardbar.cpp +++ b/pv/views/trace/standardbar.cpp @@ -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 diff --git a/pv/views/trace/standardbar.hpp b/pv/views/trace/standardbar.hpp index 060a7ef5..6e822229 100644 --- a/pv/views/trace/standardbar.hpp +++ b/pv/views/trace/standardbar.hpp @@ -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(); diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index 2837e57f..f634b4ae 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -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(); } diff --git a/pv/views/trace/view.hpp b/pv/views/trace/view.hpp index a9e5564f..1551bc0b 100644 --- a/pv/views/trace/view.hpp +++ b/pv/views/trace/view.hpp @@ -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);