aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-12 12:25:03 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-12 12:35:59 +0200
commitdadc8f8b5b48d52b950886af9d670a8b23d0f895 (patch)
treefd6c432f663c70c39cf8409348526e22fa65b4b4 /src
parent6040726f92784978dd91eec4c540e92c4ca54236 (diff)
Fix weird body move behavior when last item is selected, download manga images straight to an image
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp8
-rw-r--r--src/QuickMedia.cpp50
2 files changed, 16 insertions, 42 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 32d70fc..4c715ed 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -561,7 +561,7 @@ namespace QuickMedia {
} else if(selected_item_diff < 0) {
int num_items_scrolled = 0;
int i = prev_selected_item - 1;
- BodyItem *prev_body_item = get_previous_visible_item(i);
+ BodyItem *prev_body_item;
while(num_items_scrolled < selected_int_diff_abs && i >= 0) {
if(items[i]->visible) {
prev_body_item = get_previous_visible_item(i);
@@ -603,14 +603,13 @@ namespace QuickMedia {
else if(offset_to_bottom > 0.0f)
page_scroll += offset_to_bottom;
} else {
- if(attach_side == AttachSide::TOP)
+ if((attach_side == AttachSide::TOP && first_item_fully_visible) || (first_item_fully_visible && !last_item_fully_visible))
page_scroll -= offset_to_top;
- else if(attach_side == AttachSide::BOTTOM)
+ else if((attach_side == AttachSide::BOTTOM && last_item_fully_visible) || (last_item_fully_visible && !first_item_fully_visible))
page_scroll += offset_to_bottom;
}
if(page_scroll > size.y - selected_item_height && selected_item_fits_on_screen) {
- //fprintf(stderr, "top: %f\n", page_scroll - (size.y - selected_item_height));
page_scroll = size.y - selected_item_height;
if(merge_with_previous)
page_scroll += spacing_y*2.0f;
@@ -620,7 +619,6 @@ namespace QuickMedia {
if(!merge_with_previous && merge_with_next)
page_scroll += spacing_y;
} else if(page_scroll < (merge_with_previous ? spacing_y : 0.0f) && selected_line_top_visible && selected_item_fits_on_screen) {
- //fprintf(stderr, "bottom!\n");
if(merge_with_previous)
page_scroll = spacing_y;
else
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index a5318be..c478876 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1520,7 +1520,7 @@ namespace QuickMedia {
if(associated_data.fetching_next_page_running && associated_data.next_page_future.ready()) {
BodyItems new_body_items = associated_data.next_page_future.get();
- fprintf(stderr, "Finished fetching page %d, num new messages: %zu\n", associated_data.fetched_page + 1, new_body_items.size());
+ fprintf(stderr, "Finished fetching page %d, num new items: %zu\n", associated_data.fetched_page + 1, new_body_items.size());
size_t num_new_messages = new_body_items.size();
if(num_new_messages > 0) {
tabs[i].body->append_items(std::move(new_body_items));
@@ -2130,7 +2130,7 @@ namespace QuickMedia {
return true;
});
- fprintf(stderr, "Finished fetching page %d, num new messages: %zu\n", fetch_page, new_body_items.size());
+ fprintf(stderr, "Finished fetching page %d, num new items: %zu\n", fetch_page, new_body_items.size());
size_t num_new_messages = new_body_items.size();
if(num_new_messages > 0) {
next_play_items.insert(next_play_items.end(), new_body_items.begin(), new_body_items.end());
@@ -2315,48 +2315,24 @@ namespace QuickMedia {
return true;
std::vector<CommandArg> extra_args;
- if(strcmp(images_page->get_service_name(), "manganelo") == 0) {
+ const bool is_manganelo = (strcmp(images_page->get_service_name(), "manganelo") == 0);
+ if(is_manganelo) {
extra_args = {
- CommandArg { "-H", "accept: image/png,image/*,*/*;q=0.8" },
+ CommandArg { "-H", "accept: image/jpeg,image/png,image/*,*/*;q=0.8" },
CommandArg { "-H", "sec-fetch-site: cross-site" },
CommandArg { "-H", "sec-fetch-mode: no-cors" },
CommandArg { "-H", "sec-fetch-dest: image" },
- CommandArg { "-H", "referer: https://manganelo.com/" }
+ CommandArg { "-H", "referer: https://manganelo.com/" },
+ CommandArg { "-m", "30" },
+ CommandArg { "--connect-timeout", "30" }
};
}
- // TODO: Download directly to file instead. TODO: Move to page
- std::string image_content;
- if(download_to_string(url, image_content, extra_args, true) != DownloadResult::OK || image_content.size() <= 255) {
- if(strcmp(images_page->get_service_name(), "manganelo") == 0) {
- bool try_backup_url = false;
- std::string new_url = url;
- if(string_replace_all(new_url, "s3.mkklcdnv3.com", "bu.mkklcdnbuv1.com") > 0) {
- try_backup_url = true;
- } else {
- try_backup_url = (string_replace_all(new_url, "s41.mkklcdnv41.com", "bu.mkklcdnbuv1.com") > 0);
- }
-
- if(try_backup_url) {
- image_content.clear();
- if(download_to_string(new_url, image_content, extra_args, true) != DownloadResult::OK || image_content.size() <= 255) {
- if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + new_url, Urgency::CRITICAL);
- return true;
- }
- } else {
- if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
- return true;
- }
- } else {
- if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
- return true;
- }
- }
-
- Path image_filepath_tmp(image_filepath.data + ".tmp");
-
- if(file_overwrite(image_filepath_tmp, image_content) != 0) {
- show_notification("QuickMedia", "Failed to save image to file: " + image_filepath_tmp.data, Urgency::CRITICAL);
+ Path image_filepath_tmp(image_filepath.data + ".tmpz");
+ // TODO: Move to page
+ size_t file_size = 0;
+ if(download_to_file(url, image_filepath_tmp.data, extra_args, true) != DownloadResult::OK || (is_manganelo && file_get_size(image_filepath_tmp, &file_size) == 0 && file_size < 255)) {
+ if(!image_download_cancel) show_notification("QuickMedia", "Failed to download image: " + url, Urgency::CRITICAL);
return true;
}