aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-03 19:06:23 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-03 19:06:23 +0100
commitf7f45ddc492b992cc49a92f620e37316e4d1fed4 (patch)
tree4269403c18b067c0fb6b5b397ae368d019fabdc2 /src
parent39ab966ebf9c23c8e801a904836a73be56b5ab92 (diff)
Add thumbnail to bookmarked manga page
Diffstat (limited to 'src')
-rw-r--r--src/ImageViewer.cpp2
-rw-r--r--src/QuickMedia.cpp2
-rw-r--r--src/plugins/MangaGeneric.cpp3
-rw-r--r--src/plugins/Mangadex.cpp3
-rw-r--r--src/plugins/Manganelo.cpp5
-rw-r--r--src/plugins/Page.cpp9
6 files changed, 20 insertions, 4 deletions
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 &timestamp_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));
}