From d83c0123ed3e51ef1e8d6a164e87343dd5335331 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 17 Sep 2020 02:10:10 +0200 Subject: Show error message on failure to load image for same page Show title of manga when viewing pages --- include/ImageViewer.hpp | 3 ++- src/ImageViewer.cpp | 9 +++++---- src/QuickMedia.cpp | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/ImageViewer.hpp b/include/ImageViewer.hpp index 18faa9c..7fe4921 100644 --- a/include/ImageViewer.hpp +++ b/include/ImageViewer.hpp @@ -33,7 +33,7 @@ namespace QuickMedia { class ImageViewer { public: - ImageViewer(Manga *manga, const std::string &images_url, const std::string &chapter_title, int current_page, const Path &chapter_cache_dir, sf::Font *font); + ImageViewer(Manga *manga, const std::string &images_url, const std::string &content_title, const std::string &chapter_title, int current_page, const Path &chapter_cache_dir, sf::Font *font); ImageViewerAction draw(sf::RenderWindow &window); // Returns page as 1 indexed int get_focused_page() const; @@ -46,6 +46,7 @@ namespace QuickMedia { int num_pages; int page_center; + std::string content_title; std::string chapter_title; Path chapter_cache_dir; diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp index d2b1a95..fc31274 100644 --- a/src/ImageViewer.cpp +++ b/src/ImageViewer.cpp @@ -7,9 +7,10 @@ #include namespace QuickMedia { - ImageViewer::ImageViewer(Manga *manga, const std::string &images_url, const std::string &chapter_title, int current_page, const Path &chapter_cache_dir, sf::Font *font) : + ImageViewer::ImageViewer(Manga *manga, const std::string &images_url, const std::string &content_title, const std::string &chapter_title, int current_page, const Path &chapter_cache_dir, sf::Font *font) : current_page(current_page), num_pages(0), + content_title(content_title), chapter_title(chapter_title), chapter_cache_dir(chapter_cache_dir), focused_page(current_page), @@ -101,7 +102,7 @@ namespace QuickMedia { // TODO: Make image loading asynchronous if(get_file_type(image_path) == FileType::REGULAR) { - fprintf(stderr, "ImageViewer: Load page %d\n", 1 + page); + fprintf(stderr, "ImageViewer: Loaded page %d\n", 1 + page); page_image_data = std::make_unique(); page_image_data->visible_on_screen = true; std::string image_data; @@ -268,7 +269,7 @@ namespace QuickMedia { if(focused_page != prev_focused_page) { prev_focused_page = focused_page; - page_text.setString(chapter_title + " | Page " + std::to_string(1 + focused_page) + "/" + std::to_string(num_pages)); + page_text.setString(content_title + " | " + chapter_title + " | Page " + std::to_string(1 + focused_page) + "/" + std::to_string(num_pages)); } const float font_height = page_text.getCharacterSize() + 8.0f; @@ -287,7 +288,7 @@ namespace QuickMedia { int i = 0; for(auto &page_data : image_data) { if(page_data && !page_data->visible_on_screen) { - fprintf(stderr, "ImageViewer: Unload page %d\n", 1 + i); + fprintf(stderr, "ImageViewer: Unloaded page %d\n", 1 + i); page_data.reset(); } ++i; diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 44e6bd9..377729f 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1990,9 +1990,9 @@ namespace QuickMedia { bool redraw = true; sf::Event event; - sf::Text chapter_text(chapter_title + " | Page " + std::to_string(image_index + 1) + "/" + std::to_string(num_images), font, 14); + sf::Text chapter_text(content_title + " | " + chapter_title + " | Page " + std::to_string(image_index + 1) + "/" + std::to_string(num_images), font, 14); if(image_index == num_images) - chapter_text.setString(chapter_title + " | End"); + chapter_text.setString(content_title + " | " + chapter_title + " | End"); chapter_text.setFillColor(sf::Color::White); sf::RectangleShape chapter_text_background; chapter_text_background.setFillColor(sf::Color(0, 0, 0, 150)); @@ -2062,6 +2062,7 @@ namespace QuickMedia { texture_size_f = sf::Vector2f(texture_size.x, texture_size.y); } else if(load_image_result == LoadImageResult::FAILED) { download_in_progress = false; + error = true; } error_message.setString(error_msg); redraw = true; @@ -2143,7 +2144,7 @@ namespace QuickMedia { json_chapter = Json::Value(Json::objectValue); } - ImageViewer image_viewer(image_plugin, images_url, chapter_title, image_index, content_cache_dir, &font); + ImageViewer image_viewer(image_plugin, images_url, content_title, chapter_title, image_index, content_cache_dir, &font); json_chapter["current"] = std::min(latest_read, image_viewer.get_num_pages()); json_chapter["total"] = image_viewer.get_num_pages(); -- cgit v1.2.3