aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp14
-rw-r--r--src/QuickMedia.cpp6
-rw-r--r--src/plugins/Mangatown.cpp13
-rw-r--r--src/plugins/NyaaSi.cpp5
-rw-r--r--src/plugins/Plugin.cpp1
-rw-r--r--src/plugins/Pornhub.cpp7
6 files changed, 30 insertions, 16 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 9a811a9..fe57130 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -57,10 +57,8 @@ namespace QuickMedia {
{
progress_text.setFillColor(sf::Color::White);
replies_text.setFillColor(sf::Color(129, 162, 190));
- thumbnail_resize_target_size.x = 200;
- thumbnail_resize_target_size.y = 119;
- thumbnail_fallback_size.x = 50.0f;
- thumbnail_fallback_size.y = 100.0f;
+ thumbnail_resize_target_size.x = 120;
+ thumbnail_resize_target_size.y = 120;
image_fallback.setFillColor(sf::Color::White);
item_background.setFillColor(sf::Color(55, 60, 68));
}
@@ -304,7 +302,11 @@ namespace QuickMedia {
}
// TODO: Optimize this, especially when scrolling to top/bottom.
- // TODO: Test when wrapping is enabled
+ // TODO: If the thumbnail fallback size is larger than the real thumbnail size then the scroll will be incorrect when scrolling down
+ // because first we scroll by a larger value and then the thumbnail size changes when the thumbnail has finished loading
+ // and the selected item will no longer be exactly at the bottom of the window, and we will see parts of then next item.
+ // To fix this, we should detect when the selected item is at the bottom of the screen and the thumbnail changes from image fallback to the real thumbnail
+ // and add the difference in size to scroll, if the real thumbnail size is smaller than the image fallback.
int selected_item_diff = selected_item - prev_selected_item;
int selected_int_diff_abs = std::abs(selected_item_diff);
if(selected_item_diff > 0) {
@@ -378,8 +380,8 @@ namespace QuickMedia {
if(after_pos.y - start_y >= size.y)
break;
- float item_height = get_item_height(item.get());
update_dirty_state(item.get(), size);
+ float item_height = get_item_height(item.get());
item->last_drawn_time = elapsed_time;
// This is needed here rather than above the loop, since update_dirty_text cant be called inside scissor because it corrupts the text for some reason
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 0ab78a1..625a426 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -284,6 +284,7 @@ namespace QuickMedia {
auto body_item = BodyItem::create(recommended_title_json.asString());
body_item->url = "https://www.youtube.com/watch?v=" + recommended_item_id;
body_item->thumbnail_url = "https://img.youtube.com/vi/" + recommended_item_id + "/hqdefault.jpg";
+ body_item->thumbnail_size = sf::Vector2i(158, 119);
body_items.push_back(std::move(body_item));
// We dont want more than 150 recommendations
@@ -753,6 +754,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 + "/hqdefault.jpg";
body_item->set_description(timestamp_to_relative_time_str(std::max(0l, time_now - timestamp.asInt64())));
+ body_item->thumbnail_size = sf::Vector2i(158, 119);
body_items.push_back(std::move(body_item));
}
@@ -2943,8 +2945,6 @@ namespace QuickMedia {
messages_tab.body->draw_thumbnails = true;
messages_tab.body->thumbnail_resize_target_size.x = 600;
messages_tab.body->thumbnail_resize_target_size.y = 337;
- messages_tab.body->thumbnail_fallback_size.x = 32;
- messages_tab.body->thumbnail_fallback_size.y = 32;
messages_tab.body->thumbnail_mask_shader = &circle_mask_shader;
//messages_tab.body->line_seperator_color = sf::Color::Transparent;
messages_tab.text = sf::Text("Messages", *font, tab_text_size);
@@ -2955,8 +2955,6 @@ namespace QuickMedia {
rooms_tab.body = std::make_unique<Body>(this, font.get(), bold_font.get(), cjk_font.get());
rooms_tab.body->draw_thumbnails = true;
//rooms_tab.body->line_seperator_color = sf::Color::Transparent;
- rooms_tab.body->thumbnail_fallback_size.x = 32;
- rooms_tab.body->thumbnail_fallback_size.y = 32;
rooms_tab.body->thumbnail_mask_shader = &circle_mask_shader;
rooms_tab.text = sf::Text("Rooms", *font, tab_text_size);
tabs.push_back(std::move(rooms_tab));
diff --git a/src/plugins/Mangatown.cpp b/src/plugins/Mangatown.cpp
index 992e0cc..d9013f7 100644
--- a/src/plugins/Mangatown.cpp
+++ b/src/plugins/Mangatown.cpp
@@ -12,12 +12,13 @@ namespace QuickMedia {
return atoi(str) != 0;
}
- SearchResult MangatownSearchPage::search(const std::string &str, BodyItems &result_items) {
+ static SearchResult search_page(const std::string &str, int page, bool use_tor, BodyItems &result_items) {
std::string url = "https://www.mangatown.com/search?name=";
url += url_param_encode(str);
+ url += "&page=" + std::to_string(page);
std::string website_data;
- if(download_to_string(url, website_data, {}, is_tor_enabled(), true) != DownloadResult::OK)
+ if(download_to_string(url, website_data, {}, use_tor, true) != DownloadResult::OK)
return SearchResult::NET_ERR;
if(website_data.empty())
@@ -59,6 +60,14 @@ namespace QuickMedia {
return SearchResult::OK;
}
+ SearchResult MangatownSearchPage::search(const std::string &str, BodyItems &result_items) {
+ return search_page(str, 1, is_tor_enabled(), result_items);
+ }
+
+ PluginResult MangatownSearchPage::get_page(const std::string &str, int page, BodyItems &result_items) {
+ return search_result_to_plugin_result(search_page(str, 1 + page, is_tor_enabled(), result_items));
+ }
+
PluginResult MangatownSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
BodyItems chapters_items;
diff --git a/src/plugins/NyaaSi.cpp b/src/plugins/NyaaSi.cpp
index 3ae6ffb..fa4e94f 100644
--- a/src/plugins/NyaaSi.cpp
+++ b/src/plugins/NyaaSi.cpp
@@ -39,10 +39,6 @@ namespace QuickMedia {
return body_item;
}
- static PluginResult search_result_to_plugin_result(SearchResult search_result) {
- return (PluginResult)search_result;
- }
-
// TODO: Also show the number of comments for each torrent. TODO: Optimize?
// TODO: Show each field as seperate columns instead of seperating by |
static SearchResult search_page(const std::string &list_url, const std::string &text, int page, bool use_tor, BodyItems &result_items) {
@@ -174,6 +170,7 @@ namespace QuickMedia {
body_item->set_title_color(sf::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);
result_items.push_back(std::move(body_item));
}
diff --git a/src/plugins/Plugin.cpp b/src/plugins/Plugin.cpp
index 0b554ae..a391d06 100644
--- a/src/plugins/Plugin.cpp
+++ b/src/plugins/Plugin.cpp
@@ -5,4 +5,5 @@ namespace QuickMedia {
PluginResult download_result_to_plugin_result(DownloadResult download_result) { return (PluginResult)download_result; }
SearchResult download_result_to_search_result(DownloadResult download_result) { return (SearchResult)download_result; }
ImageResult download_result_to_image_result(DownloadResult download_result) { return (ImageResult)download_result; }
+ PluginResult search_result_to_plugin_result(SearchResult search_result) { return (PluginResult)search_result; }
} \ No newline at end of file
diff --git a/src/plugins/Pornhub.cpp b/src/plugins/Pornhub.cpp
index b063a32..c0e3fa1 100644
--- a/src/plugins/Pornhub.cpp
+++ b/src/plugins/Pornhub.cpp
@@ -131,6 +131,13 @@ namespace QuickMedia {
return get_videos_in_page(url, is_tor_enabled(), result_items);
}
+ PluginResult PornhubSearchPage::get_page(const std::string &str, int page, BodyItems &result_items) {
+ std::string url = "https://www.pornhub.com/video/search?search=";
+ url += url_param_encode(str);
+ url += "&page=" + std::to_string(1 + page);
+ return search_result_to_plugin_result(get_videos_in_page(url, is_tor_enabled(), result_items));
+ }
+
PluginResult PornhubSearchPage::submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) {
(void)title;
(void)url;