From 611d22bf269672ba56f98e12eb6b2a40efdaa5b9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 3 Jul 2021 16:23:36 +0200 Subject: Remove dependency on tidy, fix ph, support all 4chan markup Go back to previous page when failing to fetch number of pages --- src/QuickMedia.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/QuickMedia.cpp') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 9788c0a..e21e591 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1217,22 +1217,22 @@ namespace QuickMedia { } } else if(strcmp(plugin_name, "pornhub") == 0) { check_youtube_dl_installed(plugin_name); - auto search_page = std::make_unique(this, "https://www.pornhub.com/", sf::Vector2i(320/1.5f, 180/1.5f)); + auto search_page = std::make_unique(this, "https://www.pornhub.com/", sf::Vector2i(320/1.5f, 180/1.5f), false); add_pornhub_handlers(search_page.get()); tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)}); } else if(strcmp(plugin_name, "spankbang") == 0) { check_youtube_dl_installed(plugin_name); - auto search_page = std::make_unique(this, "https://spankbang.com/", sf::Vector2i(500/2.5f, 281/2.5f)); + auto search_page = std::make_unique(this, "https://spankbang.com/", sf::Vector2i(500/2.5f, 281/2.5f), true); add_spankbang_handlers(search_page.get()); tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)}); } else if(strcmp(plugin_name, "xvideos") == 0) { check_youtube_dl_installed(plugin_name); - auto search_page = std::make_unique(this, "https://www.xvideos.com/", sf::Vector2i(352/1.5f, 198/1.5f)); + auto search_page = std::make_unique(this, "https://www.xvideos.com/", sf::Vector2i(352/1.5f, 198/1.5f), false); add_xvideos_handlers(search_page.get()); tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)}); } else if(strcmp(plugin_name, "xhamster") == 0) { check_youtube_dl_installed(plugin_name); - auto search_page = std::make_unique(this, "https://xhamster.com/", sf::Vector2i(240, 135)); + auto search_page = std::make_unique(this, "https://xhamster.com/", sf::Vector2i(240, 135), false); add_xhamster_handlers(search_page.get()); tabs.push_back(Tab{create_body(false, true), std::move(search_page), create_search_bar("Search...", 500)}); } else if(strcmp(plugin_name, "soundcloud") == 0) { @@ -1972,7 +1972,9 @@ namespace QuickMedia { BodyItem *selected_item = tabs[selected_tab].body->get_selected(); if(selected_item && tabs[selected_tab].page->is_trackable()) { TrackablePage *trackable_page = dynamic_cast(tabs[selected_tab].page.get()); - trackable_page->track(selected_item->get_title()); + run_task_with_loading_screen([trackable_page, selected_item](){ + return trackable_page->track(selected_item->get_title()) == TrackResult::OK; + }); } } else if(event.key.code == sf::Keyboard::C && event.key.control) { BodyItem *selected_item = tabs[selected_tab].body->get_selected(); @@ -3183,6 +3185,7 @@ namespace QuickMedia { image_download_future.cancel(); image_download_cancel = false; + num_manga_pages = 0; std::promise num_manga_pages_promise; num_manga_pages_future = num_manga_pages_promise.get_future(); @@ -3346,6 +3349,11 @@ namespace QuickMedia { sf::Event event; download_chapter_images_if_needed(images_page); + if(num_manga_pages == 0) { + current_page = pop_page_stack(); + return 0; + } + if(current_page != PageType::IMAGES || !window.isOpen()) return 0; @@ -3541,6 +3549,11 @@ namespace QuickMedia { } download_chapter_images_if_needed(images_page); + if(num_manga_pages == 0) { + current_page = pop_page_stack(); + return; + } + if(current_page != PageType::IMAGES_CONTINUOUS || !window.isOpen()) return; @@ -4281,6 +4294,9 @@ namespace QuickMedia { update_idle_state(); handle_window_close(); + if(current_page != PageType::CHAT_LOGIN) + break; + if(redraw) { redraw = false; get_body_dimensions(window_size, nullptr, body_pos, body_size); -- cgit v1.2.3