aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-03 03:10:50 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-03 03:10:50 +0200
commit13681189d41f3d5c6c132d92b7451fea151fb713 (patch)
treeafd0f7fc51179cdd4f9180daa5e30117d7aec30c
parent59295d52e65deaba992df55c5fe2ad4f52fa3046 (diff)
bind I to switching between single image and scroll mode
-rw-r--r--README.md8
-rw-r--r--include/ImageViewer.hpp8
-rw-r--r--include/QuickMedia.hpp7
-rw-r--r--src/ImageViewer.cpp10
-rw-r--r--src/QuickMedia.cpp29
5 files changed, 49 insertions, 13 deletions
diff --git a/README.md b/README.md
index e24c663..625938d 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ QuickMedia youtube --tor
echo -e "hello\nworld" | QuickMedia dmenu
```
## Controls
-Press `arrow up` and `arrow down` to navigate the menu and also to scroll to the previous/next image when viewing manga. Alternatively you can use the mouse scroll to scroll to the previous/next manga.\
+Press `arrow up` and `arrow down` to navigate the menu and also to scroll to the previous/next image when viewing manga in scorll mode. Alternatively you can use the mouse scroll to scroll to the previous/next manga in scroll mode.\
Press `Enter` (aka `Return`) to select the item.\
Press `ESC` to go back to the previous menu.\
Press `Ctrl + T` when hovering over a manga chapter to start tracking manga after that chapter. This only works if AutoMedia is installed and
@@ -30,7 +30,8 @@ Press `Backspace` to return to the preview item when reading replies in image bo
Press `R` to paste the post number of the selected post into the post field (image boards).\
Press `Ctrl + C` to begin writing a post to a thread (image boards).\
Press `1 to 9` or `Numpad 1 to 9` to select google captcha image when posting a comment on 4chan.\
-Press `P` to preview the attached item of the selected row in full screen view. Only works for image boards when browsing a thread.
+Press `P` to preview the attached item of the selected row in full screen view. Only works for image boards when browsing a thread.\
+Press `I` to switch between single image and scroll image view mode when reading manga.
## Video controls
Press `space` to pause/unpause video. `Double-click` video to fullscreen or leave fullscreen.
# Mangadex
@@ -76,5 +77,4 @@ Add support for special formatting for posts by admins on imageboards.\
For image boards, track (You)'s and show notification when somebody replies to your post.\
In image boards when viewing videos, automatically play the next one after the current one has finished playing (just like the youtube plugin does).\
When viewing images the image download start from page 1 to the end page. The image download should start from the viewing page.\
-Go to next chapter when reaching the end of the chapter in image endless mode.\
-Allow to switch between 1 page and endless mode for images.
+Go to next chapter when reaching the end of the chapter in image endless mode.\ \ No newline at end of file
diff --git a/include/ImageViewer.hpp b/include/ImageViewer.hpp
index fb1e5e3..ed3363d 100644
--- a/include/ImageViewer.hpp
+++ b/include/ImageViewer.hpp
@@ -25,10 +25,16 @@ namespace QuickMedia {
bool loaded;
};
+ enum class ImageViewerAction {
+ NONE,
+ RETURN,
+ SWITCH_TO_SINGLE_IMAGE_MODE
+ };
+
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);
- bool draw(sf::RenderWindow &window);
+ ImageViewerAction draw(sf::RenderWindow &window);
// Returns page as 1 indexed
int get_focused_page() const;
int get_num_pages() const { return num_pages; }
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 387a5a5..8884c79 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -18,6 +18,11 @@
namespace QuickMedia {
class Plugin;
class Manga;
+
+ enum class ImageViewMode {
+ SINGLE,
+ SCROLL
+ };
class Program {
public:
@@ -85,5 +90,7 @@ namespace QuickMedia {
std::string resources_root;
bool use_tor = false;
bool use_system_mpv_config = false;
+ // TODO: Save this to config file when switching modes
+ ImageViewMode image_view_mode = ImageViewMode::SINGLE;
};
} \ No newline at end of file
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index b567e1b..41993ad 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -115,7 +115,7 @@ namespace QuickMedia {
return true;
}
- bool ImageViewer::draw(sf::RenderWindow &window) {
+ ImageViewerAction ImageViewer::draw(sf::RenderWindow &window) {
const double frame_delta = frame_timer.restart().asSeconds();
const double scroll_speed_key_input = 450.0;
const double scroll_speed_mouse_wheel = 450.0;
@@ -134,7 +134,7 @@ namespace QuickMedia {
if (event.type == sf::Event::Closed) {
//current_page = Page::EXIT;
window.close();
- return false;
+ return ImageViewerAction::RETURN;
} else if(event.type == sf::Event::Resized) {
window_size.x = event.size.width;
window_size.y = event.size.height;
@@ -149,7 +149,9 @@ namespace QuickMedia {
} else if(event.key.code == sf::Keyboard::Down) {
scroll_speed -= scroll_speed_key_input * frame_delta;
} else if(event.key.code == sf::Keyboard::Escape) {
- return false;
+ return ImageViewerAction::RETURN;
+ } else if(event.key.code == sf::Keyboard::I) {
+ return ImageViewerAction::SWITCH_TO_SINGLE_IMAGE_MODE;
}
} else if(event.type == sf::Event::MouseWheelScrolled && event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel) {
scroll_speed += scroll_speed_mouse_wheel * event.mouseWheelScroll.delta * frame_delta;
@@ -224,7 +226,7 @@ namespace QuickMedia {
++i;
}
- return true;
+ return ImageViewerAction::NONE;
}
int ImageViewer::get_focused_page() const {
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 400603b..15e345b 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -802,7 +802,15 @@ namespace QuickMedia {
images_url = item->url;
chapter_title = item->title;
image_index = 0;
- current_page = Page::IMAGES_CONTINUOUS;
+ switch(image_view_mode) {
+ case ImageViewMode::SINGLE:
+ current_page = Page::IMAGES;
+ break;
+ case ImageViewMode::SCROLL:
+ current_page = Page::IMAGES_CONTINUOUS;
+ break;
+ }
+
if(start_from_beginning)
return;
@@ -1123,6 +1131,9 @@ namespace QuickMedia {
}
} else if(event.key.code == sf::Keyboard::Escape) {
current_page = Page::EPISODE_LIST;
+ } else if(event.key.code == sf::Keyboard::I) {
+ current_page = Page::IMAGES_CONTINUOUS;
+ image_view_mode = ImageViewMode::SCROLL;
}
}
}
@@ -1230,14 +1241,24 @@ namespace QuickMedia {
while(current_page == Page::IMAGES_CONTINUOUS) {
window.clear(back_color);
- if(!image_viewer.draw(window))
- current_page = Page::EPISODE_LIST;
+ ImageViewerAction action = image_viewer.draw(window);
+ switch(action) {
+ case ImageViewerAction::NONE:
+ break;
+ case ImageViewerAction::RETURN:
+ current_page = Page::EPISODE_LIST;
+ break;
+ case ImageViewerAction::SWITCH_TO_SINGLE_IMAGE_MODE:
+ image_view_mode = ImageViewMode::SINGLE;
+ current_page = Page::IMAGES;
+ break;
+ }
window.display();
int focused_page = image_viewer.get_focused_page();
+ image_index = focused_page - 1;
if(focused_page > latest_read) {
latest_read = focused_page;
- image_index = latest_read - 1;
json_chapter["current"] = latest_read;
json_chapters[chapter_title] = json_chapter;
if(!save_manga_progress_json(content_storage_file, content_storage_json)) {