aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Body.hpp4
-rw-r--r--include/ImageViewer.hpp4
-rw-r--r--include/Page.hpp7
-rw-r--r--include/QuickMedia.hpp69
-rw-r--r--include/SearchBar.hpp4
-rw-r--r--include/Storage.hpp2
-rw-r--r--include/Tab.hpp15
7 files changed, 54 insertions, 51 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index 3d5c870..875ad61 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -101,7 +101,6 @@ namespace QuickMedia {
class Body {
public:
Body(Program *program, sf::Font *font, sf::Font *bold_font, sf::Font *cjk_font);
- ~Body();
// Select previous page, ignoring invisible items. Returns true if the item was changed. This can be used to check if the top was hit when wrap_around is set to false
bool select_previous_page();
@@ -126,6 +125,8 @@ namespace QuickMedia {
void append_items(BodyItems new_items);
void insert_item_by_timestamp(std::shared_ptr<BodyItem> body_item);
void insert_items_by_timestamps(BodyItems new_items);
+ void clear_cache();
+ void clear_text_cache();
void clear_thumbnails();
BodyItem* get_selected() const;
@@ -188,7 +189,6 @@ namespace QuickMedia {
sf::RectangleShape item_background_shadow;
sf::RoundedRectangleShape item_background;
sf::Sprite image;
- std::future<void> load_thumbnail_future;
int num_visible_items;
bool last_item_fully_visible;
int last_fully_visible_item;
diff --git a/include/ImageViewer.hpp b/include/ImageViewer.hpp
index b8063ee..2cf3ac2 100644
--- a/include/ImageViewer.hpp
+++ b/include/ImageViewer.hpp
@@ -15,7 +15,7 @@ namespace sf {
}
namespace QuickMedia {
- class Manga;
+ class MangaImagesPage;
enum class ImageStatus {
WAITING,
@@ -46,7 +46,7 @@ namespace QuickMedia {
class ImageViewer {
public:
- 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);
+ ImageViewer(MangaImagesPage *manga_images_page, 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;
diff --git a/include/Page.hpp b/include/Page.hpp
index f8af3c0..d0e40b3 100644
--- a/include/Page.hpp
+++ b/include/Page.hpp
@@ -1,16 +1,11 @@
#pragma once
namespace QuickMedia {
- enum class Page {
+ enum class PageType {
EXIT,
- SEARCH_SUGGESTION,
VIDEO_CONTENT,
- EPISODE_LIST,
IMAGES,
IMAGES_CONTINUOUS,
- CONTENT_LIST,
- CONTENT_DETAILS,
- IMAGE_BOARD_THREAD_LIST,
IMAGE_BOARD_THREAD,
CHAT_LOGIN,
CHAT,
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 016202c..0a0b509 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -4,6 +4,7 @@
#include "SearchBar.hpp"
#include "Page.hpp"
#include "Storage.hpp"
+#include "Tab.hpp"
#include <vector>
#include <memory>
#include <SFML/Graphics/Font.hpp>
@@ -20,9 +21,10 @@
#include <X11/Xatom.h>
namespace QuickMedia {
- class Plugin;
+ class Matrix;
class FileManager;
- class Manga;
+ class MangaImagesPage;
+ class ImageBoardThreadPage;
enum class ImageViewMode {
SINGLE,
@@ -40,24 +42,23 @@ namespace QuickMedia {
~Program();
int run(int argc, char **argv);
- Plugin* get_current_plugin() { return current_plugin; }
+ bool is_tor_enabled();
+ std::unique_ptr<Body> create_body();
+ std::unique_ptr<SearchBar> create_search_bar(const std::string &placeholder, int search_delay);
+
+ bool load_manga_content_storage(const char *service_name, const std::string &manga_title, const std::string &manga_id);
+
+ void select_file(const std::string &filepath);
private:
- void base_event_handler(sf::Event &event, Page previous_page, bool handle_key_press = true, bool clear_on_escape = true, bool handle_searchbar = true);
- void search_suggestion_page();
- void search_result_page();
- void video_content_page();
- void episode_list_page();
- void image_page();
- void image_continuous_page();
- void content_list_page();
- void content_details_page();
- void image_board_thread_list_page();
- void image_board_thread_page();
+ void base_event_handler(sf::Event &event, PageType previous_page, Body *body, SearchBar *search_bar, bool handle_key_press = true, bool handle_searchbar = true);
+ void page_loop(std::vector<Tab> tabs);
+ void video_content_page(Page *page, std::string video_url, std::string video_title);
+ // Returns -1 to go to previous chapter, 0 to stay on same chapter and 1 to go to next chapter
+ int image_page(MangaImagesPage *images_page, Body *chapters_body);
+ void image_continuous_page(MangaImagesPage *images_page);
+ void image_board_thread_page(ImageBoardThreadPage *thread_page, Body *thread_body);
void chat_login_page();
void chat_page();
- void file_manager_page();
-
- bool on_search_suggestion_submit_text(Body *input_body, Body *output_body);
enum class LoadImageResult {
OK,
@@ -66,17 +67,18 @@ namespace QuickMedia {
};
LoadImageResult load_image_by_index(int image_index, sf::Texture &image_texture, sf::String &error_message);
- void download_chapter_images_if_needed(Manga *image_plugin);
+ void download_chapter_images_if_needed(MangaImagesPage *images_page);
void select_episode(BodyItem *item, bool start_from_beginning);
- // Returns Page::EXIT if empty
- Page pop_page_stack();
+ // Returns PageType::EXIT if empty
+ PageType pop_page_stack();
- void plugin_get_watch_history(Plugin *plugin, BodyItems &history_items);
- Json::Value load_video_history_json(Plugin *plugin);
- Json::Value load_recommended_json(Plugin *plugin);
+ void manga_get_watch_history(const char *plugin_name, BodyItems &history_items);
+ void youtube_get_watch_history(BodyItems &history_items);
+ Json::Value load_video_history_json();
+ Json::Value load_recommended_json();
- void save_recommendations_from_related_videos();
+ void save_recommendations_from_related_videos(const std::string &video_url, const std::string &video_title, const Body *related_media_body);
private:
enum class UpscaleImageAction {
NO,
@@ -86,25 +88,16 @@ namespace QuickMedia {
Display *disp;
sf::RenderWindow window;
+ Matrix *matrix = nullptr;
int monitor_hz;
sf::Vector2f window_size;
std::unique_ptr<sf::Font> font;
std::unique_ptr<sf::Font> bold_font;
std::unique_ptr<sf::Font> cjk_font;
- Body *body;
- Plugin *current_plugin;
+ const char *plugin_name = nullptr;
sf::Texture plugin_logo;
- std::unique_ptr<SearchBar> search_bar;
- Page current_page;
- std::stack<Page> page_stack;
- // TODO: Combine these
- std::string images_url;
- std::string content_title;
- std::string content_episode;
- std::string content_url;
- std::string content_list_url;
- std::string image_board_thread_list_url;
- std::string chapter_title;
+ PageType current_page;
+ std::stack<PageType> page_stack;
int image_index;
Path content_storage_file;
Path content_cache_dir;
@@ -130,9 +123,7 @@ namespace QuickMedia {
bool running = false;
// TODO: Save this to config file when switching modes
ImageViewMode image_view_mode = ImageViewMode::SINGLE;
- Body *related_media_body;
std::vector<std::string> selected_files;
- FileManager *file_manager = nullptr;
bool fit_image_to_window = false;
};
} \ No newline at end of file
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp
index e5245be..6b7ca6d 100644
--- a/include/SearchBar.hpp
+++ b/include/SearchBar.hpp
@@ -15,8 +15,7 @@ namespace sf {
namespace QuickMedia {
using TextUpdateCallback = std::function<void(const std::string &text)>;
- // Return true to consume the search (clear the search field)
- using TextSubmitCallback = std::function<bool(const std::string &text)>;
+ using TextSubmitCallback = std::function<void(const std::string &text)>;
using TextBeginTypingCallback = std::function<void()>;
using AutocompleteRequestCallback = std::function<void(const std::string &text)>;
@@ -69,6 +68,7 @@ namespace QuickMedia {
bool draw_logo;
bool needs_update;
bool input_masked;
+ bool typing;
float vertical_pos;
sf::Clock time_since_search_update;
};
diff --git a/include/Storage.hpp b/include/Storage.hpp
index 38c083e..8a1bbfa 100644
--- a/include/Storage.hpp
+++ b/include/Storage.hpp
@@ -29,4 +29,6 @@ namespace QuickMedia {
bool read_file_as_json(const Path &filepath, Json::Value &result);
bool save_json_to_file_atomic(const Path &path, const Json::Value &json);
+
+ bool is_program_executable_by_name(const char *name);
} \ No newline at end of file
diff --git a/include/Tab.hpp b/include/Tab.hpp
new file mode 100644
index 0000000..ccb8c85
--- /dev/null
+++ b/include/Tab.hpp
@@ -0,0 +1,15 @@
+#pragma once
+
+#include <memory>
+
+namespace QuickMedia {
+ class Body;
+ class Page;
+ class SearchBar;
+
+ struct Tab {
+ std::unique_ptr<Body> body;
+ std::unique_ptr<Page> page; // Only null when current page has |is_single_page()| set to true
+ std::unique_ptr<SearchBar> search_bar; // Nullable
+ };
+} \ No newline at end of file