diff options
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r-- | src/QuickMedia.cpp | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 7e758b9..9f8c7bd 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -549,7 +549,7 @@ namespace QuickMedia { } if(use_tor && !is_program_executable_by_name("torsocks")) { - fprintf(stderr, "torsocks needs to be installed (and accessible from PATH environment variable) when using the --tor option\n"); + fprintf(stderr, "torsocks needs to be installed when using the --tor option\n"); return -2; } @@ -560,7 +560,7 @@ namespace QuickMedia { } if(!is_program_executable_by_name("waifu2x-ncnn-vulkan")) { - fprintf(stderr, "waifu2x-ncnn-vulkan needs to be installed (and accessible from PATH environment variable) when using the --upscale-images/--upscale-images-always option\n"); + fprintf(stderr, "waifu2x-ncnn-vulkan needs to be installed when using the --upscale-images/--upscale-images-always option\n"); return -2; } @@ -1023,7 +1023,7 @@ namespace QuickMedia { } } - void Program::page_loop(std::vector<Tab> &tabs, int start_tab_index, std::function<void()> after_submit_handler) { + void Program::page_loop(std::vector<Tab> &tabs, int start_tab_index, PageLoopSubmitHandler after_submit_handler) { if(tabs.empty()) { show_notification("QuickMedia", "No tabs provided!", Urgency::CRITICAL); return; @@ -1077,9 +1077,6 @@ namespace QuickMedia { return; } - if(after_submit_handler) - after_submit_handler(); - if(tabs[selected_tab].page->clear_search_after_submit() && tabs[selected_tab].search_bar) { if(!tabs[selected_tab].search_bar->get_text().empty()) { tabs[selected_tab].search_bar->clear(); @@ -1103,6 +1100,9 @@ namespace QuickMedia { if(new_tabs.empty()) return; + if(after_submit_handler) + after_submit_handler(new_tabs); + for(Tab &tab : tabs) { tab.body->clear_cache(); } @@ -1407,7 +1407,7 @@ namespace QuickMedia { associated_data.lazy_fetch_finished = true; FetchResult fetch_result = associated_data.fetch_future.get(); tabs[i].body->items = std::move(fetch_result.body_items); - tabs[i].body->filter_search_fuzzy(tabs[i].search_bar->get_text()); + if(tabs[i].search_bar) tabs[i].body->filter_search_fuzzy(tabs[i].search_bar->get_text()); if(fetch_result.result != PluginResult::OK) associated_data.search_result_text.setString("Failed to fetch page!"); else if(tabs[i].body->items.empty()) @@ -1760,7 +1760,7 @@ namespace QuickMedia { current_page = previous_page; } else { channel_url.clear(); - // TODO: Make async. What if the server is frozen? + // TODO: Remove this and use lazy_fetch instead related_videos = video_page->get_related_media(video_url, channel_url); // TODO: Make this also work for other video plugins @@ -1880,6 +1880,7 @@ namespace QuickMedia { int search_delay = 0; auto search_page = video_page->create_search_page(this, search_delay); + auto comments_page = video_page->create_comments_page(this); auto related_videos_page = video_page->create_related_videos_page(this, video_url, video_title); auto channels_page = video_page->create_channels_page(this, channel_url); if(search_page || related_videos_page || channels_page) { @@ -1890,6 +1891,9 @@ namespace QuickMedia { if(search_page) { tabs.push_back(Tab{create_body(), std::move(search_page), create_search_bar("Search...", search_delay)}); } + if(comments_page) { + tabs.push_back(Tab{create_body(), std::move(comments_page), nullptr}); + } if(related_videos_page) { auto related_videos_body = create_body(); related_videos_body->items = related_videos; @@ -1900,19 +1904,21 @@ namespace QuickMedia { } bool page_changed = false; - page_loop(tabs, 1, [this, &video_player, &page_changed]() { - window.setMouseCursorVisible(true); - if(video_player) { - video_player->quit_and_save_watch_later(); - while(true) { - VideoPlayer::Error update_err = video_player->update(); - if(update_err != VideoPlayer::Error::OK) - break; - std::this_thread::sleep_for(std::chrono::milliseconds(20)); + page_loop(tabs, 1, [this, &video_player, &page_changed](const std::vector<Tab> &new_tabs) { + if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::VIDEO) { + window.setMouseCursorVisible(true); + if(video_player) { + video_player->quit_and_save_watch_later(); + while(true) { + VideoPlayer::Error update_err = video_player->update(); + if(update_err != VideoPlayer::Error::OK) + break; + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + } + video_player.reset(); } - video_player.reset(); + page_changed = true; } - page_changed = true; }); if(page_changed) { |