From 03a228f81f4a7a827a5a383bc16b8a2fb3abadb4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 9 Jul 2020 05:59:39 +0200 Subject: Fix item selection not working with empty search Fix history not working on mangatown. Make image scrolling faster in infinite scroll mode. --- src/Body.cpp | 8 ++++++++ src/ImageViewer.cpp | 4 ++-- src/QuickMedia.cpp | 7 +++++-- src/plugins/Mangatown.cpp | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index 54134b6..da7152d 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -346,4 +346,12 @@ namespace QuickMedia { item->visible = string_find_case_insensitive(item->title, text); } } + + bool Body::no_items_visible() const { + for(auto &item : items) { + if(item->visible) + return false; + } + return true; + } } \ No newline at end of file diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp index 41993ad..102d73a 100644 --- a/src/ImageViewer.cpp +++ b/src/ImageViewer.cpp @@ -118,8 +118,8 @@ namespace QuickMedia { ImageViewerAction ImageViewer::draw(sf::RenderWindow &window) { const double frame_delta = frame_timer.restart().asSeconds(); const double scroll_speed_key_input = 450.0; - const double scroll_speed_mouse_wheel = 450.0; - const double scroll_deaccel = 0.93; + const double scroll_speed_mouse_wheel = 600.0; + const double scroll_deaccel = 0.96; if(!window_size_set) { auto window_size_i = window.getSize(); diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 956ab32..cae1234 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -378,7 +378,6 @@ namespace QuickMedia { exit(1); } // TODO: Make asynchronous - // TODO: Make this also work for mangadex. Would require storing both id and name of the manga for_files_in_dir_sort_last_modified(content_storage_dir, [&history_body, this](const std::filesystem::path &filepath) { Path fullpath(filepath.c_str()); Json::Value body; @@ -396,6 +395,10 @@ namespace QuickMedia { body_item->url = "https://manganelo.com/manga/" + base64_decode(filename.string()); else if(current_plugin->name == "mangadex") body_item->url = "https://mangadex.org/title/" + base64_decode(filename.string()); + else if(current_plugin->name == "mangatown") + body_item->url = "https://mangatown.com/manga/" + base64_decode(filename.string()); + else + fprintf(stderr, "Error: Not implemented: filename to manga chapter list\n"); history_body.items.push_back(std::move(body_item)); } return true; @@ -423,7 +426,7 @@ namespace QuickMedia { search_bar->onTextSubmitCallback = [this, &tabs, &selected_tab, &typing](const std::string &text) -> bool { if(current_plugin->name != "dmenu") { - if(typing || text.empty()) + if(typing || tabs[selected_tab].body->no_items_visible()) return false; } diff --git a/src/plugins/Mangatown.cpp b/src/plugins/Mangatown.cpp index 1954854..8dcf8d3 100644 --- a/src/plugins/Mangatown.cpp +++ b/src/plugins/Mangatown.cpp @@ -160,7 +160,7 @@ namespace QuickMedia { std::string image_src; std::string website_data; std::string full_url = chapter_url + std::to_string(page_index++) + ".html"; - if(download_to_string(full_url, website_data, {}, use_tor, true) != DownloadResult::OK) + if(download_to_string_cache(full_url, website_data, {}, use_tor, true) != DownloadResult::OK) break; QuickMediaHtmlSearch html_search; -- cgit v1.2.3