aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Manga.hpp2
-rw-r--r--plugins/Matrix.hpp5
-rw-r--r--plugins/Page.hpp2
-rw-r--r--src/QuickMedia.cpp9
-rw-r--r--src/plugins/Manga.cpp4
-rw-r--r--src/plugins/Matrix.cpp12
6 files changed, 22 insertions, 12 deletions
diff --git a/plugins/Manga.hpp b/plugins/Manga.hpp
index afd8a3c..cd0ab77 100644
--- a/plugins/Manga.hpp
+++ b/plugins/Manga.hpp
@@ -53,7 +53,7 @@ namespace QuickMedia {
public:
MangaChaptersPage(Program *program, std::string manga_name, std::string manga_url) : TrackablePage(program, std::move(manga_name), std::move(manga_url)) {}
TrackResult track(const std::string &str) override;
- void on_navigate_to_page(BodyItems &body_items) override;
+ void on_navigate_to_page(Body *body) override;
protected:
virtual bool extract_id_from_url(const std::string &url, std::string &manga_id) const = 0;
virtual const char* get_service_name() const = 0;
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp
index cde502d..d9e6a97 100644
--- a/plugins/Matrix.hpp
+++ b/plugins/Matrix.hpp
@@ -252,12 +252,14 @@ namespace QuickMedia {
class MatrixRoomsPage : public Page {
public:
- MatrixRoomsPage(Program *program, Body *body, std::string title, MatrixRoomTagsPage *room_tags_page = nullptr);
+ MatrixRoomsPage(Program *program, Body *body, std::string title, MatrixRoomTagsPage *room_tags_page, SearchBar *search_bar);
~MatrixRoomsPage() override;
const char* get_title() const override { return title.c_str(); }
PluginResult submit(const std::string &title, const std::string &url, std::vector<Tab> &result_tabs) override;
+ void on_navigate_to_page(Body *body) override;
+
void update() override;
void add_body_item(std::shared_ptr<BodyItem> body_item);
@@ -277,6 +279,7 @@ namespace QuickMedia {
Body *body = nullptr;
std::string title;
MatrixRoomTagsPage *room_tags_page = nullptr;
+ SearchBar *search_bar = nullptr;
MatrixChatPage *current_chat_page = nullptr;
bool clear_data_on_update = false;
bool sort_on_update = false;
diff --git a/plugins/Page.hpp b/plugins/Page.hpp
index db844c5..db11a61 100644
--- a/plugins/Page.hpp
+++ b/plugins/Page.hpp
@@ -45,7 +45,7 @@ namespace QuickMedia {
virtual bool is_lazy_fetch_page() const { return false; }
// This is called both when first navigating to page and when going back to page
- virtual void on_navigate_to_page(BodyItems &body_items) { (void)body_items; }
+ virtual void on_navigate_to_page(Body *body) { (void)body; }
// Called periodically (every frame right now) if this page is the currently active one
virtual void update() {}
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 61e59a3..fe2e7b0 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -898,7 +898,7 @@ namespace QuickMedia {
for(Tab &tab : tabs) {
tab.body->thumbnail_max_size = tab.page->get_thumbnail_max_size();
- tab.page->on_navigate_to_page(tab.body->items);
+ tab.page->on_navigate_to_page(tab.body.get());
}
const Json::Value *json_chapters = &Json::Value::nullSingleton();
@@ -1026,7 +1026,7 @@ namespace QuickMedia {
} else {
page_loop(new_tabs);
}
- tabs[selected_tab].page->on_navigate_to_page(tabs[selected_tab].body->items);
+ tabs[selected_tab].page->on_navigate_to_page(tabs[selected_tab].body.get());
if(content_storage_json.isObject()) {
const Json::Value &chapters_json = content_storage_json["chapters"];
if(chapters_json.isObject())
@@ -4238,7 +4238,8 @@ namespace QuickMedia {
auto rooms_body = create_body();
rooms_body->thumbnail_mask_shader = &circle_mask_shader;
- auto matrix_rooms_page = std::make_unique<MatrixRoomsPage>(this, rooms_body.get(), "All rooms");
+ auto matrix_rooms_page_search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER);
+ auto matrix_rooms_page = std::make_unique<MatrixRoomsPage>(this, rooms_body.get(), "All rooms", nullptr, matrix_rooms_page_search_bar.get());
auto rooms_tags_body = create_body();
rooms_tags_body->thumbnail_mask_shader = &circle_mask_shader;
@@ -4252,7 +4253,7 @@ namespace QuickMedia {
matrix->start_sync(&matrix_handler);
std::vector<Tab> tabs;
- tabs.push_back(Tab{std::move(rooms_body), std::move(matrix_rooms_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
+ tabs.push_back(Tab{std::move(rooms_body), std::move(matrix_rooms_page), std::move(matrix_rooms_page_search_bar)});
tabs.push_back(Tab{std::move(rooms_tags_body), std::move(matrix_rooms_tag_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
tabs.push_back(Tab{std::move(invites_body), std::move(matrix_invites_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
diff --git a/src/plugins/Manga.cpp b/src/plugins/Manga.cpp
index 4685cec..f3c6814 100644
--- a/src/plugins/Manga.cpp
+++ b/src/plugins/Manga.cpp
@@ -10,8 +10,8 @@ namespace QuickMedia {
return TrackResult::ERR;
}
- void MangaChaptersPage::on_navigate_to_page(BodyItems &body_items) {
- (void)body_items;
+ void MangaChaptersPage::on_navigate_to_page(Body *body) {
+ (void)body;
std::string manga_id;
if(extract_id_from_url(content_url, manga_id))
load_manga_content_storage(get_service_name(), content_title, manga_id);
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index fd05399..2e96cd0 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -442,7 +442,7 @@ namespace QuickMedia {
pending_room_messages.clear();
}
- MatrixRoomsPage::MatrixRoomsPage(Program *program, Body *body, std::string title, MatrixRoomTagsPage *room_tags_page) : Page(program), body(body), title(std::move(title)), room_tags_page(room_tags_page) {
+ MatrixRoomsPage::MatrixRoomsPage(Program *program, Body *body, std::string title, MatrixRoomTagsPage *room_tags_page, SearchBar *search_bar) : Page(program), body(body), title(std::move(title)), room_tags_page(room_tags_page), search_bar(search_bar) {
if(room_tags_page)
room_tags_page->set_current_rooms_page(this);
}
@@ -460,6 +460,11 @@ namespace QuickMedia {
return PluginResult::OK;
}
+ void MatrixRoomsPage::on_navigate_to_page(Body *body) {
+ if(search_bar)
+ body->filter_search_fuzzy(search_bar->get_text());
+ }
+
void MatrixRoomsPage::update() {
{
std::lock_guard<std::mutex> lock(mutex);
@@ -548,9 +553,10 @@ namespace QuickMedia {
TagData &tag_data = tag_body_items_by_name[url];
body->items = tag_data.room_body_items;
sort_room_body_items(body->items);
- auto rooms_page = std::make_unique<MatrixRoomsPage>(program, body_ptr, tag_data.tag_item->get_title(), this);
+ auto search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER);
+ auto rooms_page = std::make_unique<MatrixRoomsPage>(program, body_ptr, tag_data.tag_item->get_title(), this, search_bar.get());
rooms_page->matrix_delegate = matrix_delegate;
- result_tabs.push_back(Tab{std::move(body), std::move(rooms_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)});
+ result_tabs.push_back(Tab{std::move(body), std::move(rooms_page), std::move(search_bar)});
return PluginResult::OK;
}