diff options
-rw-r--r-- | plugins/Manga.hpp | 4 | ||||
-rw-r--r-- | plugins/MangaGeneric.hpp | 4 | ||||
-rw-r--r-- | plugins/Mangadex.hpp | 4 | ||||
-rw-r--r-- | plugins/Manganelo.hpp | 2 | ||||
-rw-r--r-- | src/ImageViewer.cpp | 2 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 2 | ||||
-rw-r--r-- | src/plugins/MangaGeneric.cpp | 3 | ||||
-rw-r--r-- | src/plugins/Mangadex.cpp | 3 | ||||
-rw-r--r-- | src/plugins/Manganelo.cpp | 5 | ||||
-rw-r--r-- | src/plugins/Page.cpp | 9 |
10 files changed, 28 insertions, 10 deletions
diff --git a/plugins/Manga.hpp b/plugins/Manga.hpp index 74d8ed1..a298c11 100644 --- a/plugins/Manga.hpp +++ b/plugins/Manga.hpp @@ -55,7 +55,8 @@ namespace QuickMedia { class MangaChaptersPage : public Page, public TrackablePage { public: - MangaChaptersPage(Program *program, std::string manga_name, std::string manga_url) : Page(program), TrackablePage(std::move(manga_name), std::move(manga_url)) {} + MangaChaptersPage(Program *program, std::string manga_name, std::string manga_url, const std::string &thumbnail_url) : + Page(program), TrackablePage(std::move(manga_name), std::move(manga_url)), thumbnail_url(thumbnail_url) {} const char* get_title() const override { return content_title.c_str(); } TrackResult track(const std::string &str) override; void on_navigate_to_page(Body *body) override; @@ -64,5 +65,6 @@ namespace QuickMedia { 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; + std::string thumbnail_url; }; }
\ No newline at end of file diff --git a/plugins/MangaGeneric.hpp b/plugins/MangaGeneric.hpp index 183fbb4..bb7eb65 100644 --- a/plugins/MangaGeneric.hpp +++ b/plugins/MangaGeneric.hpp @@ -155,8 +155,8 @@ namespace QuickMedia { class MangaGenericChaptersPage : public MangaChaptersPage { public: - 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) {} + MangaGenericChaptersPage(Program *program, std::string manga_name, std::string manga_url, const std::string &thumbnail_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), thumbnail_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<Tab> &result_tabs) override; const char* get_bookmark_name() const override { return service_name; } protected: diff --git a/plugins/Mangadex.hpp b/plugins/Mangadex.hpp index c9f9515..2741f0c 100644 --- a/plugins/Mangadex.hpp +++ b/plugins/Mangadex.hpp @@ -25,8 +25,8 @@ namespace QuickMedia { class MangadexChaptersPage : public MangaChaptersPage { public: - 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) {} + MangadexChaptersPage(Program *program, MangadexSearchPage *search_page, std::string manga_name, std::string manga_url, const std::string &thumbnail_url) : + MangaChaptersPage(program, std::move(manga_name), std::move(manga_url), thumbnail_url), search_page(search_page) {} PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &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"; } diff --git a/plugins/Manganelo.hpp b/plugins/Manganelo.hpp index 5012fa3..a96d0c9 100644 --- a/plugins/Manganelo.hpp +++ b/plugins/Manganelo.hpp @@ -15,7 +15,7 @@ namespace QuickMedia { class ManganeloChaptersPage : public MangaChaptersPage { public: - ManganeloChaptersPage(Program *program, std::string manga_name, std::string manga_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url)) {} + ManganeloChaptersPage(Program *program, std::string manga_name, std::string manga_url, const std::string &thumbnail_url) : MangaChaptersPage(program, std::move(manga_name), std::move(manga_url), thumbnail_url) {} PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override; const char* get_bookmark_name() const override { return "manganelo"; } protected: diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp index ff35d06..fcc3b3b 100644 --- a/src/ImageViewer.cpp +++ b/src/ImageViewer.cpp @@ -339,6 +339,8 @@ namespace QuickMedia { const double first_image_height = get_page_size(0).y; const double last_image_height = get_page_size((int)image_data.size() - 1).y; + // TODO: Limit bottom scroll if page_offset is smaller than window height + const double top_scroll = std::max(0.0, -first_image_height * 0.5 + window_size.y * 0.5); const double bottom_scroll = std::min(window_size.y, window_size.y + last_image_height * 0.5 - window_size.y * 0.5); if(scroll > top_scroll) { diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index d1cc0e3..cbe8ea4 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1642,6 +1642,8 @@ namespace QuickMedia { new_item["author"] = body_item->get_author(); if(!body_item->url.empty()) new_item["url"] = body_item->url; + if(!body_item->thumbnail_url.empty()) + new_item["thumbnail_url"] = body_item->thumbnail_url; new_item["timestamp"] = (int64_t)time(nullptr); json_root.append(std::move(new_item)); diff --git a/src/plugins/MangaGeneric.cpp b/src/plugins/MangaGeneric.cpp index 98dc708..e25fd96 100644 --- a/src/plugins/MangaGeneric.cpp +++ b/src/plugins/MangaGeneric.cpp @@ -366,7 +366,8 @@ namespace QuickMedia { auto body = create_body(); body->set_items(std::move(chapters_items)); - result_tabs.push_back(Tab{std::move(body), std::make_unique<MangaGenericChaptersPage>(program, title, url, manga_id_extractor, service_name, website_url, &list_page_query, fail_on_http_error), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); + auto chapters_page = std::make_unique<MangaGenericChaptersPage>(program, title, url, submit_body_item->thumbnail_url, manga_id_extractor, service_name, website_url, &list_page_query, fail_on_http_error); + result_tabs.push_back(Tab{std::move(body), std::move(chapters_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); for(auto &it : creators) { Creator creator; diff --git a/src/plugins/Mangadex.cpp b/src/plugins/Mangadex.cpp index 445c809..8dd6822 100644 --- a/src/plugins/Mangadex.cpp +++ b/src/plugins/Mangadex.cpp @@ -360,7 +360,8 @@ namespace QuickMedia { auto body = create_body(); body->set_items(std::move(body_items)); - result_tabs.push_back(Tab{std::move(body), std::make_unique<MangadexChaptersPage>(program, this, title, url), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); + auto chapters_page = std::make_unique<MangadexChaptersPage>(program, this, title, url, submit_body_item->thumbnail_url); + result_tabs.push_back(Tab{std::move(body), std::move(chapters_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); std::vector<Creator> creators; result = get_creators_for_manga(this, url, creators); diff --git a/src/plugins/Manganelo.cpp b/src/plugins/Manganelo.cpp index f88ac03..e5c5719 100644 --- a/src/plugins/Manganelo.cpp +++ b/src/plugins/Manganelo.cpp @@ -95,9 +95,10 @@ namespace QuickMedia { auto chapters_body = page->create_body(); chapters_body->set_items(std::move(chapters_items)); - result_tabs.push_back(Tab{std::move(chapters_body), std::make_unique<ManganeloChaptersPage>(page->program, title, url), page->create_search_bar("Search...", SEARCH_DELAY_FILTER)}); + auto chapters_page = std::make_unique<ManganeloChaptersPage>(page->program, title, url, page->submit_body_item->thumbnail_url); + result_tabs.push_back(Tab{std::move(chapters_body), std::move(chapters_page), page->create_search_bar("Search...", SEARCH_DELAY_FILTER)}); - // TODO: Fix. Doesn't work because manganelo changes creator url format + // TODO: Fix. Doesn't work because manganelo changed creator url format /*for(Creator &creator : creators) { result_tabs.push_back(Tab{page->create_body(), std::make_unique<ManganeloCreatorPage>(page->program, std::move(creator)), page->create_search_bar("Search...", SEARCH_DELAY_FILTER)}); }*/ diff --git a/src/plugins/Page.cpp b/src/plugins/Page.cpp index 4ac2a9f..34ca889 100644 --- a/src/plugins/Page.cpp +++ b/src/plugins/Page.cpp @@ -93,17 +93,26 @@ namespace QuickMedia { const Json::Value &title_json = item_json["title"]; const Json::Value &author_json = item_json["author"]; const Json::Value &url_json = item_json["url"]; + const Json::Value &thumbnail_url_json = item_json["thumbnail_url"]; const Json::Value ×tamp_json = item_json["timestamp"]; auto body_item = BodyItem::create(title_json.isString() ? title_json.asString() : ""); if(author_json.isString()) body_item->set_author(author_json.asString()); + if(url_json.isString()) body_item->url = url_json.asString(); + + if(thumbnail_url_json.isString()) { + body_item->thumbnail_url = thumbnail_url_json.asString(); + body_item->thumbnail_size = {101, 141}; + } + if(timestamp_json.isInt64()) { body_item->set_description("Bookmarked " + seconds_to_relative_time_str(time_now - timestamp_json.asInt64())); body_item->set_description_color(get_theme().faded_text_color); } + result_items.push_back(std::move(body_item)); } |