diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-04-12 12:25:03 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-04-12 12:35:59 +0200 |
commit | dadc8f8b5b48d52b950886af9d670a8b23d0f895 (patch) | |
tree | fd6c432f663c70c39cf8409348526e22fa65b4b4 | |
parent | 6040726f92784978dd91eec4c540e92c4ca54236 (diff) |
Fix weird body move behavior when last item is selected, download manga images straight to an image
-rw-r--r-- | TODO | 2 | ||||
m--------- | depends/html-parser | 0 | ||||
-rw-r--r-- | launcher/QuickMedia_tabbed.desktop | 2 | ||||
-rw-r--r-- | src/Body.cpp | 8 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 50 |
5 files changed, 18 insertions, 44 deletions
@@ -94,7 +94,7 @@ Fetch replies/pinned message using multiple threads. Show in room tags list when there is a message in any of the rooms in the tag. Support webp. Then switch to the youtube thumbnails from the response json instead of hqdefault, to remove the black bars. Show images while they download by showing them as scanlines starting from the top. Needed for slow websites such as 4chan. -Use curl parallel download instead of downloading with multiple threads. +Use curl parallel download instead of downloading with multiple threads. This can be done with multiple -O parameters. Handle matrix groups? (which also contains join, invite, leave...). Add functionality to ignore users in matrix. This is done with an ignore request and we wont get messages and invites from that user anymore. Also add option to ignore in the invites page. Add keybind to go to invites page from any page. diff --git a/depends/html-parser b/depends/html-parser -Subproject 32b65e91db5b01b6b6da5117789c9dc473fec13 +Subproject 60bde2dc9bb3a6e0276d624fe3490b891c3a7fc diff --git a/launcher/QuickMedia_tabbed.desktop b/launcher/QuickMedia_tabbed.desktop index d8332e9..409e84f 100644 --- a/launcher/QuickMedia_tabbed.desktop +++ b/launcher/QuickMedia_tabbed.desktop @@ -3,6 +3,6 @@ Type=Application Name=QuickMedia tabbed GenericName=QuickMedia tabbed Comment=Launch QuickMedia with tabs -Exec=tabbed -k quickmedia launcher -e +Exec=tabbed -c -k quickmedia launcher -e Terminal=false Keywords=4chan;manga;matrix;nyaa;torrent;soundcloud;spotify;podcast;youtube;music;quickmedia; 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; } |