diff --git a/gtk/FilterBar.cc b/gtk/FilterBar.cc index 85a88b57c..26970c6d8 100644 --- a/gtk/FilterBar.cc +++ b/gtk/FilterBar.cc @@ -113,7 +113,6 @@ private: Glib::RefPtr filter_ = TorrentFilter::create(); Glib::RefPtr> filter_model_; - sigc::connection filter_model_items_changed_tag_; sigc::connection update_count_label_tag_; sigc::connection update_filter_models_tag_; sigc::connection update_filter_models_on_add_remove_tag_; @@ -583,10 +582,13 @@ bool FilterBar::Impl::update_count_label() } /* set the text */ - show_lb_->set_markup_with_mnemonic( - visibleCount == std::min(activityCount, trackerCount) ? + if (auto const new_markup = visibleCount == std::min(activityCount, trackerCount) ? _("_Show:") : - fmt::format(_("_Show {count:L} of:"), fmt::arg("count", visibleCount))); + fmt::format(_("_Show {count:L} of:"), fmt::arg("count", visibleCount)); + new_markup != show_lb_->get_label().raw()) + { + show_lb_->set_markup_with_mnemonic(new_markup); + } return false; } @@ -617,6 +619,11 @@ void FilterBar::Impl::update_filter_models(Torrent::ChangeFlags changes) } filter_->update(changes); + + if (changes.test(activity_flags | tracker_flags)) + { + update_count_label_idle(); + } } void FilterBar::Impl::update_filter_models_idle(Torrent::ChangeFlags changes) @@ -700,9 +707,9 @@ FilterBar::Impl::Impl(FilterBar& widget, Glib::RefPtr const& core) activity_combo_box_init(*activity_); tracker_combo_box_init(*tracker_); + filter_->signal_changed().connect([this](auto /*changes*/) { update_count_label_idle(); }); + filter_model_ = FilterListModel::create(core_->get_sorted_model(), filter_); - filter_model_items_changed_tag_ = filter_model_->signal_items_changed().connect( - [this](guint /*position*/, guint /*removed*/, guint /*added*/) { update_count_label_idle(); }); tracker_->signal_changed().connect(sigc::mem_fun(*this, &Impl::update_filter_tracker)); activity_->signal_changed().connect(sigc::mem_fun(*this, &Impl::update_filter_activity)); @@ -721,7 +728,6 @@ FilterBar::Impl::~Impl() update_filter_models_on_add_remove_tag_.disconnect(); update_filter_models_tag_.disconnect(); update_count_label_tag_.disconnect(); - filter_model_items_changed_tag_.disconnect(); } Glib::RefPtr FilterBar::get_filter_model() const diff --git a/gtk/Flags.h b/gtk/Flags.h index 6dbd475ad..aef741340 100644 --- a/gtk/Flags.h +++ b/gtk/Flags.h @@ -68,7 +68,7 @@ public: value_ |= get_mask(flag); } - [[nodiscard]] constexpr Flags operator|(Flags rhs) noexcept + [[nodiscard]] constexpr Flags operator|(Flags rhs) const noexcept { return Flags(value_ | rhs.value_); }