From 2030684b16004a4f6c60f499584366ae5ad57bc9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 15 Feb 2022 21:52:40 +0100 Subject: Finish video player --- src/plugins/LocalManga.cpp | 48 ++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 31 deletions(-) (limited to 'src/plugins/LocalManga.cpp') diff --git a/src/plugins/LocalManga.cpp b/src/plugins/LocalManga.cpp index 83dd983..8ab8cd1 100644 --- a/src/plugins/LocalManga.cpp +++ b/src/plugins/LocalManga.cpp @@ -163,13 +163,7 @@ namespace QuickMedia { return manga_list; } - enum class ReadStatus { - READ, - UNREAD - }; - - // Returns the new read status - static bool toggle_read_save_to_file(Program *program, const std::string &manga_name, const std::string &thumbnail_url, ReadStatus &read_status) { + static bool validate_local_manga_dir_config_is_set() { if(get_config().local_manga_directory.empty()) { show_notification("QuickMedia", "local_manga_directory config is not set", Urgency::CRITICAL); return false; @@ -180,6 +174,19 @@ namespace QuickMedia { return false; } + return true; + } + + enum class ReadStatus { + READ, + UNREAD + }; + + // Returns the new read status + static bool toggle_read_save_to_file(Program *program, const std::string &manga_name, const std::string &thumbnail_url, ReadStatus &read_status) { + if(!validate_local_manga_dir_config_is_set()) + return false; + Path manga_url = Path(get_config().local_manga_directory).join(manga_name); std::vector chapters = get_chapters_in_manga(manga_name, manga_url, true, true); if(chapters.empty() || chapters.front().pages.empty()) @@ -327,15 +334,8 @@ namespace QuickMedia { } PluginResult LocalMangaSearchPage::submit(const SubmitArgs &args, std::vector &result_tabs) { - if(get_config().local_manga_directory.empty()) { - show_notification("QuickMedia", "local_manga_directory config is not set", Urgency::CRITICAL); + if(!validate_local_manga_dir_config_is_set()) return PluginResult::OK; - } - - if(get_file_type(get_config().local_manga_directory) != FileType::DIRECTORY) { - show_notification("QuickMedia", "local_manga_directory config is not set to a valid directory", Urgency::CRITICAL); - return PluginResult::OK; - } Path manga_url = Path(get_config().local_manga_directory).join(args.url); std::vector chapters = get_chapters_in_manga(args.url, manga_url, false, false); @@ -371,15 +371,8 @@ namespace QuickMedia { manga_list.clear(); finished_reading_manga.clear(); - if(get_config().local_manga_directory.empty()) { - show_notification("QuickMedia", "local_manga_directory config is not set", Urgency::CRITICAL); + if(!validate_local_manga_dir_config_is_set()) return PluginResult::OK; - } - - if(get_file_type(get_config().local_manga_directory) != FileType::DIRECTORY) { - show_notification("QuickMedia", "local_manga_directory config is not set to a valid directory", Urgency::CRITICAL); - return PluginResult::OK; - } manga_list = get_manga_in_directory(get_config().local_manga_directory, true); @@ -467,15 +460,8 @@ namespace QuickMedia { } PluginResult LocalMangaChaptersPage::submit(const SubmitArgs &args, std::vector &result_tabs) { - if(get_config().local_manga_directory.empty()) { - show_notification("QuickMedia", "local_manga_directory config is not set", Urgency::CRITICAL); - return PluginResult::OK; - } - - if(get_file_type(get_config().local_manga_directory) != FileType::DIRECTORY) { - show_notification("QuickMedia", "local_manga_directory config is not set to a valid directory", Urgency::CRITICAL); + if(!validate_local_manga_dir_config_is_set()) return PluginResult::OK; - } result_tabs.push_back(Tab{nullptr, std::make_unique(program, content_title, args.url, args.url, thumbnail_url), nullptr}); return PluginResult::OK; -- cgit v1.2.3