From a12c897435e615618b14f5cbdd50c7d01dd291fa Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 29 Aug 2021 09:27:41 +0200 Subject: Allow bookmarking manga from chapters page --- plugins/Manga.hpp | 1 + plugins/MangaGeneric.hpp | 1 + plugins/Mangadex.hpp | 1 + plugins/Manganelo.hpp | 1 + plugins/Page.hpp | 2 ++ 5 files changed, 6 insertions(+) (limited to 'plugins') diff --git a/plugins/Manga.hpp b/plugins/Manga.hpp index ee7638b..020099e 100644 --- a/plugins/Manga.hpp +++ b/plugins/Manga.hpp @@ -54,6 +54,7 @@ namespace QuickMedia { TrackResult track(const std::string &str) override; void on_navigate_to_page(Body *body) override; bool is_trackable() const override { return true; } + std::shared_ptr get_bookmark_body_item() override; protected: virtual bool extract_id_from_url(const std::string &url, std::string &manga_id) const = 0; virtual const char* get_service_name() const = 0; diff --git a/plugins/MangaGeneric.hpp b/plugins/MangaGeneric.hpp index 4b4f55c..183fbb4 100644 --- a/plugins/MangaGeneric.hpp +++ b/plugins/MangaGeneric.hpp @@ -158,6 +158,7 @@ namespace QuickMedia { MangaGenericChaptersPage(Program *program, std::string manga_name, std::string manga_url, const MangaIdExtractor &manga_id_extractor, const char *service_name, const std::string &website_url, const ListPageQuery *list_page_query, bool fail_on_http_error) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)), manga_id_extractor(manga_id_extractor), service_name(service_name), website_url(website_url), list_page_query(list_page_query), fail_on_http_error(fail_on_http_error) {} PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + const char* get_bookmark_name() const override { return service_name; } protected: bool extract_id_from_url(const std::string &url, std::string &manga_id) const override; const char* get_service_name() const override { return service_name; } diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp index cb412da..beceddb 100644 --- a/plugins/Mangadex.hpp +++ b/plugins/Mangadex.hpp @@ -32,6 +32,7 @@ namespace QuickMedia { MangadexChaptersPage(Program *program, MangadexSearchPage *search_page, std::string manga_name, std::string manga_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)), search_page(search_page) {} PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override; + const char* get_bookmark_name() const override { return "mangadex"; } protected: bool extract_id_from_url(const std::string &url, std::string &manga_id) const override; const char* get_service_name() const override { return "mangadex"; } diff --git a/plugins/Manganelo.hpp b/plugins/Manganelo.hpp index 70526ff..5012fa3 100644 --- a/plugins/Manganelo.hpp +++ b/plugins/Manganelo.hpp @@ -17,6 +17,7 @@ namespace QuickMedia { public: ManganeloChaptersPage(Program *program, std::string manga_name, std::string manga_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)) {} PluginResult submit(const std::string &title, const std::string &url, std::vector &result_tabs) override; + const char* get_bookmark_name() const override { return "manganelo"; } protected: bool extract_id_from_url(const std::string &url, std::string &manga_id) const override; const char* get_service_name() const override { return "manganelo"; } diff --git a/plugins/Page.hpp b/plugins/Page.hpp index 39d76d6..3ecb016 100644 --- a/plugins/Page.hpp +++ b/plugins/Page.hpp @@ -61,6 +61,8 @@ namespace QuickMedia { virtual bool is_trackable() const { return false; } // Return nullptr if bookmark is not supported by this page virtual const char* get_bookmark_name() const { return nullptr; } + // If this returns nullptr then the currently selected body item is used instead + virtual std::shared_ptr get_bookmark_body_item() { return nullptr; } virtual bool is_bookmark_page() const { return false; } virtual bool is_lazy_fetch_page() const { return false; } // Note: If submit is done without any selection, then the search term is sent as the |title| and |url|. Submit will only be sent if the input text is not empty or if an item is selected -- cgit v1.2.3