1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#pragma once
#include "Body.hpp"
#include "SearchBar.hpp"
#include "Page.hpp"
#include "Storage.hpp"
#include <vector>
#include <memory>
#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <json/value.h>
#include <unordered_set>
#include <future>
#include <stack>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
namespace QuickMedia {
class Plugin;
class Manga;
enum class ImageViewMode {
SINGLE,
SCROLL
};
class Program {
public:
Program();
~Program();
int run(int argc, char **argv);
Plugin* get_current_plugin() { return current_plugin; }
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();
enum class LoadImageResult {
OK,
FAILED,
DOWNLOAD_IN_PROGRESS
};
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 select_episode(BodyItem *item, bool start_from_beginning);
// Returns Page::EXIT if empty
Page 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 save_recommendations_from_related_videos();
private:
Display *disp;
sf::RenderWindow window;
sf::Vector2f window_size;
sf::Font font;
sf::Font bold_font;
Body *body;
Plugin *current_plugin;
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;
int image_index;
Path content_storage_file;
Path content_cache_dir;
std::string manga_id_base64;
Json::Value content_storage_json;
std::unordered_set<std::string> watched_videos;
std::future<BodyItems> search_suggestion_future;
std::future<std::string> autocomplete_future;
std::future<void> image_download_future;
std::string downloading_chapter_url;
bool image_download_cancel = false;
int exit_code = 0;
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;
Body *related_media_body;
};
}
|