aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO3
-rw-r--r--include/Body.hpp1
-rw-r--r--plugins/Mangatown.hpp1
-rw-r--r--plugins/Page.hpp1
-rw-r--r--plugins/Plugin.hpp1
-rw-r--r--plugins/Pornhub.hpp1
-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
12 files changed, 36 insertions, 18 deletions
diff --git a/TODO b/TODO
index c685cf6..6f01e02 100644
--- a/TODO
+++ b/TODO
@@ -111,4 +111,5 @@ to fix this we could perhaps replace the newly created body items for replies wh
Add button to skip to next video. MPV has this feature when setting "next" video (can be done over IPC).
Handle room leave in matrix and remove rooms from the list.
Use a custom allocator that replaces malloc/realloc/free/new/delete to release memory properly, using munmap in free/delete. The C allocator doesn't do that! memory usage remains high after one large allocation. The C allocator only marks it as free.
-Ignore timestamp ordering for messages in matrix? element seems to do that (or only for new messages???), and also we need the latest message to be last I guess to set read markers properly? \ No newline at end of file
+Ignore timestamp ordering for messages in matrix? element seems to do that (or only for new messages???), and also we need the latest message to be last I guess to set read markers properly?
+Merge |Page::search| and |Page::get_page|. get_page with page 0 should be the same as search. \ No newline at end of file
diff --git a/include/Body.hpp b/include/Body.hpp
index 235db88..56b18e3 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -209,7 +209,6 @@ namespace QuickMedia {
bool wrap_around;
// Set to {0, 0} to disable resizing
sf::Vector2i thumbnail_resize_target_size;
- sf::Vector2f thumbnail_fallback_size;
sf::Color line_seperator_color;
BodyItemRenderCallback body_item_render_callback;
sf::Shader *thumbnail_mask_shader;
diff --git a/plugins/Mangatown.hpp b/plugins/Mangatown.hpp
index c85b5b7..151b4c2 100644
--- a/plugins/Mangatown.hpp
+++ b/plugins/Mangatown.hpp
@@ -10,6 +10,7 @@ namespace QuickMedia {
const char* get_title() const override { return "All"; }
bool search_is_filter() override { return false; }
SearchResult search(const std::string &str, BodyItems &result_items) override;
+ PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override;
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
private:
bool extract_id_from_url(const std::string &url, std::string &manga_id) const;
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index 947f045..2adce85 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -21,6 +21,7 @@ namespace QuickMedia {
// Return empty |result_tabs| and PluginResult::OK to do nothing; which is useful for implementing custom actions on item submit
virtual PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) = 0;
+ // Note: If pagination is done by fetching the next page until we get to |page|, then the "current page" should be reset everytime |search| is called
virtual PluginResult get_page(const std::string &str, int page, BodyItems &result_items) { (void)str; (void)page; (void)result_items; return PluginResult::OK; }
virtual BodyItems get_related_media(const std::string &url);
diff --git a/plugins/Plugin.hpp b/plugins/Plugin.hpp
index d754445..2026319 100644
--- a/plugins/Plugin.hpp
+++ b/plugins/Plugin.hpp
@@ -39,4 +39,5 @@ namespace QuickMedia {
PluginResult download_result_to_plugin_result(DownloadResult download_result);
SearchResult download_result_to_search_result(DownloadResult download_result);
ImageResult download_result_to_image_result(DownloadResult download_result);
+ PluginResult search_result_to_plugin_result(SearchResult search_result);
} \ No newline at end of file
diff --git a/plugins/Pornhub.hpp b/plugins/Pornhub.hpp
index 195845f..b058bbe 100644
--- a/plugins/Pornhub.hpp
+++ b/plugins/Pornhub.hpp
@@ -9,6 +9,7 @@ namespace QuickMedia {
const char* get_title() const override { return "All"; }
bool search_is_filter() override { return false; }
SearchResult search(const std::string &str, BodyItems &result_items) override;
+ PluginResult get_page(const std::string &str, int page, BodyItems &result_items) override;
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
};
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;