From f7f45ddc492b992cc49a92f620e37316e4d1fed4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 3 Feb 2022 19:06:23 +0100 Subject: Add thumbnail to bookmarked manga page --- src/plugins/MangaGeneric.cpp | 3 ++- src/plugins/Mangadex.cpp | 3 ++- src/plugins/Manganelo.cpp | 5 +++-- src/plugins/Page.cpp | 9 +++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src/plugins') 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(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(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(program, this, title, url), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); + auto chapters_page = std::make_unique(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 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(page->program, title, url), page->create_search_bar("Search...", SEARCH_DELAY_FILTER)}); + auto chapters_page = std::make_unique(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(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)); } -- cgit v1.2.3