feat: add generic favicon_cache class for reuse between Qt, GTK app (#5294)

This commit is contained in:
Charles Kerr
2023-04-22 21:11:16 -05:00
committed by GitHub
parent 9d2507c7e3
commit 1b6b85989c
21 changed files with 385 additions and 441 deletions

View File

@@ -147,6 +147,11 @@ public:
return signal_torrents_changed_;
}
[[nodiscard]] constexpr auto& favicon_cache()
{
return favicon_cache_;
}
private:
Glib::RefPtr<Session> get_core_ptr() const;
@@ -209,6 +214,8 @@ private:
Glib::RefPtr<SortListModel<Torrent>> sorted_model_;
Glib::RefPtr<TorrentSorter> sorter_ = TorrentSorter::create();
tr_session* session_ = nullptr;
FaviconCache<Glib::RefPtr<Gdk::Pixbuf>> favicon_cache_;
};
Glib::RefPtr<Session> Session::Impl::get_core_ptr() const
@@ -531,8 +538,8 @@ Session::Session(tr_session* session)
Session::~Session() = default;
Session::Impl::Impl(Session& core, tr_session* session)
: core_(core)
, session_(session)
: core_{ core }
, session_{ session }
{
raw_model_ = Gio::ListStore<Torrent>::create();
signal_torrents_changed_.connect(sigc::hide<0>(sigc::mem_fun(*sorter_.get(), &TorrentSorter::update)));
@@ -1359,6 +1366,11 @@ tr_torrent* Session::find_torrent(tr_torrent_id_t id) const
return tor;
}
FaviconCache<Glib::RefPtr<Gdk::Pixbuf>>& Session::favicon_cache() const
{
return impl_->favicon_cache();
}
void Session::open_folder(tr_torrent_id_t torrent_id) const
{
auto const* tor = find_torrent(torrent_id);