aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/LocalManga.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/LocalManga.cpp')
-rw-r--r--src/plugins/LocalManga.cpp48
1 files changed, 17 insertions, 31 deletions
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<LocalMangaChapter> 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<Tab> &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<LocalMangaChapter> 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<Tab> &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<LocalMangaImagesPage>(program, content_title, args.url, args.url, thumbnail_url), nullptr});
return PluginResult::OK;