From 7e2c1dca366156d41b3faacaaa96882fb3391f84 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Fri, 5 Apr 2024 22:59:07 +0200 Subject: [PATCH] Improve stats update times for buffer switches and toolbar toggles. --- src/BufferView.cpp | 12 ++++++++++++ src/BufferView.h | 2 ++ src/frontends/qt/GuiView.cpp | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 7386c79a75..d5fa198678 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -303,6 +303,7 @@ struct BufferView::Private int stats_ref_value_w_ = 0; int stats_ref_value_c_ = 0; int stats_ref_value_nb_ = 0; + bool stats_update_trigger_ = false; }; @@ -2026,6 +2027,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr) break; case LFUN_STATISTICS_REFERENCE_CLAMP: { + d->stats_update_trigger_ = true; if (cmd.argument() == "reset") { d->stats_ref_value_w_ = d->stats_ref_value_c_ = d->stats_ref_value_nb_ = 0; break; @@ -3921,4 +3923,14 @@ bool BufferView::clickableInset() const return d->clickable_inset_; } + +bool BufferView::stats_update_trigger() +{ + if (d->stats_update_trigger_) { + d->stats_update_trigger_ = false; + return true; + } + return false; +} + } // namespace lyx diff --git a/src/BufferView.h b/src/BufferView.h index eed48209bb..631d2a58bf 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -403,6 +403,8 @@ public: int stats_ref_value_w() const; int stats_ref_value_c() const; int stats_ref_value_nb() const; + //signals need for update in gui + bool stats_update_trigger(); private: /// noncopyable diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index ac0606e985..6f15d73626 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -555,6 +555,8 @@ public: bool already_in_selection_ = false; /// Maximum size of "short" selection for which we can update with faster timer_rate int const max_sel_chars = 5000; + /// equivalent time_to_update = 0; but better to see it the code + bool stats_update_trigger_ = false; }; @@ -1454,6 +1456,12 @@ void GuiView::showStats() return; } + // UI toggle, buffer change, etc + if (bv->stats_update_trigger() || d.stats_update_trigger_) { + d.stats_update_trigger_ = false; + d.time_to_update = 0; + } + Cursor const & cur = bv->cursor(); // we start new selection and need faster update @@ -1587,6 +1595,7 @@ void GuiView::onBufferViewChanged() && zoom_slider_->value() < zoom_slider_->maximum()); zoom_out_->setEnabled(currentBufferView() && zoom_slider_->value() > zoom_slider_->minimum()); + d.stats_update_trigger_ = true; } @@ -5162,6 +5171,7 @@ bool GuiView::lfunUiToggle(string const & ui_component) } else return false; stat_counts_->setVisible(statsEnabled()); + d.stats_update_trigger_ = true; return true; }