diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/AniList.cpp | 3 | ||||
-rw-r--r-- | src/plugins/FileManager.cpp | 4 | ||||
-rw-r--r-- | src/plugins/Fourchan.cpp | 8 | ||||
-rw-r--r-- | src/plugins/ImageBoard.cpp | 5 | ||||
-rw-r--r-- | src/plugins/Info.cpp | 5 | ||||
-rw-r--r-- | src/plugins/Matrix.cpp | 36 | ||||
-rw-r--r-- | src/plugins/MediaGeneric.cpp | 4 | ||||
-rw-r--r-- | src/plugins/MyAnimeList.cpp | 4 | ||||
-rw-r--r-- | src/plugins/NyaaSi.cpp | 8 | ||||
-rw-r--r-- | src/plugins/Page.cpp | 9 | ||||
-rw-r--r-- | src/plugins/Saucenao.cpp | 2 | ||||
-rw-r--r-- | src/plugins/Youtube.cpp | 8 | ||||
-rw-r--r-- | src/plugins/youtube/YoutubeMediaProxy.cpp | 3 |
13 files changed, 51 insertions, 48 deletions
diff --git a/src/plugins/AniList.cpp b/src/plugins/AniList.cpp index 3559a81..b892229 100644 --- a/src/plugins/AniList.cpp +++ b/src/plugins/AniList.cpp @@ -262,6 +262,7 @@ query ($id: Int, $page: Int, $perPage: Int) { } enum class ThumbnailSize { + SMALLEST, MEDIUM, LARGE }; @@ -275,7 +276,7 @@ query ($id: Int, $page: Int, $perPage: Int) { } // TODO: Somehow get the correct thumbnail size? - static sf::Vector2i thumbnail_size_get_prediced_size(ThumbnailSize thumbnail_size) { + static mgl::vec2i thumbnail_size_get_prediced_size(ThumbnailSize thumbnail_size) { switch(thumbnail_size) { case ThumbnailSize::MEDIUM: return {100, 158}; case ThumbnailSize::LARGE: return {215, 304}; diff --git a/src/plugins/FileManager.cpp b/src/plugins/FileManager.cpp index a92f3c1..59d3a2a 100644 --- a/src/plugins/FileManager.cpp +++ b/src/plugins/FileManager.cpp @@ -116,10 +116,10 @@ namespace QuickMedia { body_item->thumbnail_is_local = true; if(is_regular_file) { body_item->thumbnail_url = get_resource_loader_root_path() + std::string("images/file.png"); - body_item->thumbnail_size = sf::Vector2i(18, 24); + body_item->thumbnail_size = mgl::vec2i(18, 24); } else { body_item->thumbnail_url = get_resource_loader_root_path() + std::string("images/folder.png"); - body_item->thumbnail_size = sf::Vector2i(24, 22); + body_item->thumbnail_size = mgl::vec2i(24, 22); } } diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp index 01c8546..c906c4d 100644 --- a/src/plugins/Fourchan.cpp +++ b/src/plugins/Fourchan.cpp @@ -353,11 +353,11 @@ namespace QuickMedia { body_item->thumbnail_url = fourchan_image_url + board_id + "/" + tim_str + "s.jpg"; body_item->url = fourchan_image_url + board_id + "/" + tim_str + ext_str; - sf::Vector2i thumbnail_size(64, 64); + mgl::vec2i thumbnail_size(64, 64); const Json::Value &tn_w = post["tn_w"]; const Json::Value &tn_h = post["tn_h"]; if(tn_w.isNumeric() && tn_h.isNumeric()) - thumbnail_size = sf::Vector2i(tn_w.asInt(), tn_h.asInt()); + thumbnail_size = mgl::vec2i(tn_w.asInt(), tn_h.asInt()); body_item->thumbnail_size = std::move(thumbnail_size); } @@ -439,11 +439,11 @@ namespace QuickMedia { // thumbnails always has .jpg extension even if they are gifs or webm. body_item->thumbnail_url = fourchan_image_url + board_id + "/" + std::to_string(tim.asInt64()) + "s.jpg"; - sf::Vector2i thumbnail_size(64, 64); + mgl::vec2i thumbnail_size(64, 64); const Json::Value &tn_w = thread["tn_w"]; const Json::Value &tn_h = thread["tn_h"]; if(tn_w.isNumeric() && tn_h.isNumeric()) - thumbnail_size = sf::Vector2i(tn_w.asInt() * 0.5, tn_h.asInt() * 0.5); + thumbnail_size = mgl::vec2i(tn_w.asInt() / 2, tn_h.asInt() / 2); body_item->thumbnail_size = std::move(thumbnail_size); } diff --git a/src/plugins/ImageBoard.cpp b/src/plugins/ImageBoard.cpp index b87e4bb..3b7850b 100644 --- a/src/plugins/ImageBoard.cpp +++ b/src/plugins/ImageBoard.cpp @@ -1,9 +1,8 @@ #include "../../plugins/ImageBoard.hpp" -#include <SFML/Window/Clipboard.hpp> namespace QuickMedia { - void ImageBoardThreadPage::copy_to_clipboard(const BodyItem *body_item) const { - sf::Clipboard::setString(sf::String::fromUtf8(body_item->get_description().begin(), body_item->get_description().end())); + void ImageBoardThreadPage::copy_to_clipboard(const BodyItem *body_item) { + set_clipboard(body_item->get_description()); } PluginResult ImageBoardThreadPage::login(const std::string &token, const std::string &pin, std::string &response_msg) { diff --git a/src/plugins/Info.cpp b/src/plugins/Info.cpp index 05efc44..2b520ac 100644 --- a/src/plugins/Info.cpp +++ b/src/plugins/Info.cpp @@ -5,7 +5,6 @@ #include "../../include/Program.hpp" #include "../../include/Notification.hpp" #include "../../include/Storage.hpp" -#include <SFML/Window/Clipboard.hpp> namespace QuickMedia { static const char *REVERSE_IMAGE_SEARCH_URL = "reverse-image-search://"; @@ -50,7 +49,7 @@ namespace QuickMedia { } } - void InfoPage::copy_to_clipboard(const BodyItem *body_item) const { + void InfoPage::copy_to_clipboard(const BodyItem *body_item) { std::string url; if(string_starts_with(body_item->url, REVERSE_IMAGE_SEARCH_URL)) { url = body_item->url.substr(strlen(REVERSE_IMAGE_SEARCH_URL)); @@ -61,7 +60,7 @@ namespace QuickMedia { } if(!url.empty()) - sf::Clipboard::setString(sf::String::fromUtf8(url.begin(), url.end())); + set_clipboard(url); } // static diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index c9d57d4..2689904 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -26,7 +26,7 @@ // Remove older messages (outside screen) to save memory. Reload them when the selected body item is the top/bottom one. namespace QuickMedia { - static const sf::Vector2i thumbnail_max_size(600, 337); + static const mgl::vec2i thumbnail_max_size(600, 337); static const char* SERVICE_NAME = "matrix"; static const char* OTHERS_ROOM_TAG = "tld.name.others"; // Filter without account data. TODO: We include pinned events but limit events to 1. That means if the last event is a pin, @@ -102,17 +102,17 @@ namespace QuickMedia { return std::abs(hash); } - sf::Color user_id_to_color(const std::string &user_id) { + mgl::Color user_id_to_color(const std::string &user_id) { const int num_colors = 8; - const sf::Color colors[num_colors] = { - sf::Color(54, 139, 214), - sf::Color(172, 59, 168), - sf::Color(3, 179, 129), - sf::Color(230, 79, 122), - sf::Color(255, 129, 45), - sf::Color(45, 194, 197), - sf::Color(92, 86, 245), - sf::Color(116, 209, 44) + const mgl::Color colors[num_colors] = { + mgl::Color(54, 139, 214), + mgl::Color(172, 59, 168), + mgl::Color(3, 179, 129), + mgl::Color(230, 79, 122), + mgl::Color(255, 129, 45), + mgl::Color(45, 194, 197), + mgl::Color(92, 86, 245), + mgl::Color(116, 209, 44) }; return colors[color_hash_code(user_id) % num_colors]; } @@ -374,7 +374,7 @@ namespace QuickMedia { body_item->thumbnail_url = room->get_avatar_url(); body_item->userdata = room; // Note: this has to be valid as long as the room list is valid! body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; - body_item->thumbnail_size = sf::Vector2i(32, 32); + body_item->thumbnail_size = mgl::vec2i(32, 32); room->body_item = body_item; room_body_item_by_room[room] = body_item; rooms_page->add_body_item(body_item); @@ -440,7 +440,7 @@ namespace QuickMedia { body_item->url = room_id; body_item->thumbnail_url = invite.room_avatar_url; body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; - body_item->thumbnail_size = sf::Vector2i(32, 32); + body_item->thumbnail_size = mgl::vec2i(32, 32); body_item->set_timestamp(invite.timestamp); invites_page->add_body_item(std::move(body_item)); if(invite.new_invite) { @@ -908,7 +908,7 @@ namespace QuickMedia { if(user_info.avatar_url) body_item->thumbnail_url = user_info.avatar_url.value(); body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; - body_item->thumbnail_size = sf::Vector2i(32, 32); + body_item->thumbnail_size = mgl::vec2i(32, 32); users_body->append_item(std::move(body_item)); } @@ -1040,7 +1040,7 @@ namespace QuickMedia { } body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; - body_item->thumbnail_size = sf::Vector2i(32, 32); + body_item->thumbnail_size = mgl::vec2i(32, 32); body_item->thumbnail_url = notification.room->get_avatar_url(); auto extra_data = std::make_shared<NotificationsExtraData>(); @@ -1957,7 +1957,7 @@ namespace QuickMedia { } } - static bool message_content_extract_thumbnail_size(const rapidjson::Value &content_json, sf::Vector2i &thumbnail_size) { + static bool message_content_extract_thumbnail_size(const rapidjson::Value &content_json, mgl::vec2i &thumbnail_size) { const rapidjson::Value &info_json = GetMember(content_json, "info"); if(!info_json.IsObject()) return false; @@ -4424,7 +4424,7 @@ namespace QuickMedia { body_item->thumbnail_url = std::move(avatar_url); } body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; - body_item->thumbnail_size = sf::Vector2i(32, 32); + body_item->thumbnail_size = mgl::vec2i(32, 32); result_items.push_back(std::move(body_item)); } @@ -4736,7 +4736,7 @@ namespace QuickMedia { } void Matrix::update() { - sf::Clock timer; + mgl::Clock timer; std::optional<std::function<void()>> task; while((task = ui_thread_tasks.pop_if_available()) != std::nullopt) { task.value()(); diff --git a/src/plugins/MediaGeneric.cpp b/src/plugins/MediaGeneric.cpp index dd70efc..2b88fdb 100644 --- a/src/plugins/MediaGeneric.cpp +++ b/src/plugins/MediaGeneric.cpp @@ -37,7 +37,7 @@ namespace QuickMedia { } } - static PluginResult fetch_page_results(const std::string &url, const std::string &website_url, const std::vector<MediaTextQuery> &text_queries, const std::vector<MediaThumbnailQuery> &thumbnail_queries, sf::Vector2i thumbnail_max_size, MediaRelatedCustomHandler *custom_handler, BodyItems &result_items, bool cloudflare_bypass, const std::vector<CommandArg> &extra_commands) { + static PluginResult fetch_page_results(const std::string &url, const std::string &website_url, const std::vector<MediaTextQuery> &text_queries, const std::vector<MediaThumbnailQuery> &thumbnail_queries, mgl::vec2i thumbnail_max_size, MediaRelatedCustomHandler *custom_handler, BodyItems &result_items, bool cloudflare_bypass, const std::vector<CommandArg> &extra_commands) { std::vector<CommandArg> args = extra_commands; if(!website_url.empty()) args.push_back({ "-H", "referer: " + website_url }); @@ -118,7 +118,7 @@ namespace QuickMedia { } } - MediaGenericSearchPage::MediaGenericSearchPage(Program *program, const char *website_url, sf::Vector2i thumbnail_max_size, bool cloudflare_bypass, std::vector<CommandArg> extra_commands) : + MediaGenericSearchPage::MediaGenericSearchPage(Program *program, const char *website_url, mgl::vec2i thumbnail_max_size, bool cloudflare_bypass, std::vector<CommandArg> extra_commands) : Page(program), website_url(website_url ? website_url : ""), thumbnail_max_size(thumbnail_max_size), cloudflare_bypass(cloudflare_bypass), extra_commands(std::move(extra_commands)) { if(!this->website_url.empty()) { diff --git a/src/plugins/MyAnimeList.cpp b/src/plugins/MyAnimeList.cpp index a4d1d30..ee5d4fd 100644 --- a/src/plugins/MyAnimeList.cpp +++ b/src/plugins/MyAnimeList.cpp @@ -7,7 +7,7 @@ namespace QuickMedia { // Returns {0, 0} if unknown - static sf::Vector2i thumbnail_url_get_resolution(const std::string &url) { + static mgl::vec2i thumbnail_url_get_resolution(const std::string &url) { const size_t index = url.find("/r/"); if(index == std::string::npos) return {0, 0}; @@ -22,7 +22,7 @@ namespace QuickMedia { if(size_end_index == std::string::npos) return {0, 0}; - sf::Vector2i size; + mgl::vec2i size; if(!to_num(url.c_str() + width_index, (x_index - width_index), size.x) || !to_num(url.c_str() + height_index, (size_end_index - height_index), size.y)) return {0, 0}; diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp index f4c0560..a110c57 100644 --- a/src/plugins/NyaaSi.cpp +++ b/src/plugins/NyaaSi.cpp @@ -274,10 +274,10 @@ namespace QuickMedia { body_item->set_description(std::move(description)); body_item->url = "https://" + domain + std::move(view_url); if(is_trusted) - body_item->set_title_color(sf::Color(43, 255, 47)); + body_item->set_title_color(mgl::Color(43, 255, 47)); else if(is_remake) - body_item->set_title_color(sf::Color(255, 45, 47)); - body_item->thumbnail_size = sf::Vector2i(80, 28); + body_item->set_title_color(mgl::Color(255, 45, 47)); + body_item->thumbnail_size = mgl::vec2i(80, 28); result_items.push_back(std::move(body_item)); } @@ -457,7 +457,7 @@ namespace QuickMedia { QuickMediaStringView src = quickmedia_html_node_get_attribute_value(node, "src"); if(src.data && item_data->index < item_data->body_items->size()) { (*item_data->body_items)[item_data->index]->thumbnail_url.assign(src.data, src.size); - (*item_data->body_items)[item_data->index]->thumbnail_size = sf::Vector2i(120, 120); + (*item_data->body_items)[item_data->index]->thumbnail_size = mgl::vec2i(120, 120); item_data->index++; } return 0; diff --git a/src/plugins/Page.cpp b/src/plugins/Page.cpp index 6cf3790..4ac2a9f 100644 --- a/src/plugins/Page.cpp +++ b/src/plugins/Page.cpp @@ -3,7 +3,6 @@ #include "../../include/Theme.hpp" #include "../../include/Storage.hpp" #include "../../include/QuickMedia.hpp" -#include <SFML/Window/Clipboard.hpp> #include <json/reader.h> namespace QuickMedia { @@ -45,7 +44,11 @@ namespace QuickMedia { return program->load_manga_content_storage(service_name, manga_title, manga_url, manga_id); } - void Page::copy_to_clipboard(const BodyItem *body_item) const { + void Page::set_clipboard(const std::string &str) { + program->set_clipboard(str); + } + + void Page::copy_to_clipboard(const BodyItem *body_item) { std::string title = body_item->get_title(); std::string author = body_item->get_author(); std::string description = body_item->get_description(); @@ -65,7 +68,7 @@ namespace QuickMedia { } if(!clipboard.empty()) - sf::Clipboard::setString(sf::String::fromUtf8(clipboard.begin(), clipboard.end())); + program->set_clipboard(clipboard); } PluginResult BookmarksPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) { diff --git a/src/plugins/Saucenao.cpp b/src/plugins/Saucenao.cpp index b99c028..064bb11 100644 --- a/src/plugins/Saucenao.cpp +++ b/src/plugins/Saucenao.cpp @@ -136,7 +136,7 @@ namespace QuickMedia { QuickMediaStringView image_url = data_src.data ? data_src : src; if(image_url.data && item_data->index < item_data->body_items->size()) { (*item_data->body_items)[item_data->index]->thumbnail_url.assign(image_url.data, image_url.size); - (*item_data->body_items)[item_data->index]->thumbnail_size = sf::Vector2i(150, 147); + (*item_data->body_items)[item_data->index]->thumbnail_size = mgl::vec2i(150, 147); item_data->index++; } return 0; diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp index 7a5f0d5..8dabd2d 100644 --- a/src/plugins/Youtube.cpp +++ b/src/plugins/Youtube.cpp @@ -542,7 +542,7 @@ namespace QuickMedia { body_item->url = "https://www.youtube.com/watch?v=" + video_id_str; body_item->thumbnail_url = "https://img.youtube.com/vi/" + video_id_str + "/mqdefault.jpg"; - body_item->thumbnail_size = sf::Vector2i(192, 108); + body_item->thumbnail_size = mgl::vec2i(192, 108); added_videos.insert(video_id_str); return body_item; @@ -606,7 +606,7 @@ namespace QuickMedia { body_item->thumbnail_mask_type = ThumbnailMaskType::CIRCLE; body_item->thumbnail_size.x = thumbnail->width; body_item->thumbnail_size.y = thumbnail->height; - body_item->thumbnail_size = clamp_to_size(body_item->thumbnail_size, sf::Vector2i(136, 136)); + body_item->thumbnail_size = clamp_to_size(body_item->thumbnail_size, mgl::vec2i(136, 136)); } return body_item; } @@ -1140,7 +1140,7 @@ namespace QuickMedia { const Json::Value &author_is_channel_owner_json = comment_renderer_json["authorIsChannelOwner"]; if(author_is_channel_owner_json.isBool() && author_is_channel_owner_json.asBool()) - body_item->set_author_color(sf::Color(150, 255, 150)); + body_item->set_author_color(mgl::Color(150, 255, 150)); std::optional<std::string> comment = yt_json_get_text(comment_renderer_json, "contentText"); if(comment) @@ -1781,7 +1781,7 @@ namespace QuickMedia { body_item->set_description_color(get_theme().faded_text_color); body_item->url = "https://www.youtube.com/watch?v=" + subscription_entry.video_id; body_item->thumbnail_url = "https://img.youtube.com/vi/" + subscription_entry.video_id + "/mqdefault.jpg"; - body_item->thumbnail_size = sf::Vector2i(192, 108); + body_item->thumbnail_size = mgl::vec2i(192, 108); results.push_back({std::move(body_item), subscription_entry.published}); } return results; diff --git a/src/plugins/youtube/YoutubeMediaProxy.cpp b/src/plugins/youtube/YoutubeMediaProxy.cpp index 4fe6c74..913fb77 100644 --- a/src/plugins/youtube/YoutubeMediaProxy.cpp +++ b/src/plugins/youtube/YoutubeMediaProxy.cpp @@ -7,6 +7,7 @@ #include <string.h> #include <errno.h> #include <signal.h> +#include <inttypes.h> #include <assert.h> #include <unistd.h> @@ -222,7 +223,7 @@ namespace QuickMedia { return 0; int64_t start_range = 0; - if(sscanf(range.c_str(), " bytes=%lld", &start_range) != 1) + if(sscanf(range.c_str(), " bytes=%" PRId64, &start_range) != 1) return 0; return start_range; |