aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-04-01 17:59:36 +0200
committerdec05eba <dec05eba@protonmail.com>2021-04-01 17:59:36 +0200
commit276395f468c8ee05951401a1d352e0dec3c3a3a8 (patch)
tree3eab155a956c61268a4077322de9de9d7ca17ce0 /src/QuickMedia.cpp
parent521589c6026246113117a0f8ad568e0061aba46a (diff)
Matrix: add room directory for joining rooms, resize video thumbnail
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 95eb47a..92f9309 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1096,16 +1096,16 @@ namespace QuickMedia {
window_size.x = window_size_u.x;
window_size.y = window_size_u.y;
- std::function<void()> submit_handler;
+ std::function<void(const std::string&)> submit_handler;
- submit_handler = [this, &submit_handler, &after_submit_handler, &json_chapters, &tabs, &tab_associated_data, &selected_tab, &loop_running, &redraw]() {
+ submit_handler = [this, &submit_handler, &after_submit_handler, &json_chapters, &tabs, &tab_associated_data, &selected_tab, &loop_running, &redraw](const std::string &search_text) {
auto selected_item = tabs[selected_tab].body->get_selected_shared();
- if(!selected_item)
+ if(!selected_item && !tabs[selected_tab].page->allow_submit_no_selection())
return;
std::vector<Tab> new_tabs;
tabs[selected_tab].page->submit_body_item = selected_item;
- PluginResult submit_result = tabs[selected_tab].page->submit(selected_item->get_title(), selected_item->url, new_tabs);
+ PluginResult submit_result = tabs[selected_tab].page->submit(selected_item ? selected_item->get_title() : search_text, selected_item ? selected_item->url : "", new_tabs);
if(submit_result != PluginResult::OK) {
// TODO: Show the exact cause of error (get error message from curl).
show_notification("QuickMedia", std::string("Submit failed for page ") + tabs[selected_tab].page->get_title(), Urgency::CRITICAL);
@@ -1147,7 +1147,9 @@ namespace QuickMedia {
hide_virtual_keyboard();
- if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::MANGA_IMAGES) {
+ if(tabs[selected_tab].page->allow_submit_no_selection()) {
+ page_loop(new_tabs, 0, after_submit_handler);
+ } else if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::MANGA_IMAGES) {
select_episode(selected_item.get(), false);
Body *chapters_body = tabs[selected_tab].body.get();
chapters_body->filter_search_fuzzy(""); // Needed (or not really) to go to the next chapter when reaching the last page of a chapter
@@ -1205,7 +1207,7 @@ namespace QuickMedia {
}
tabs[selected_tab].body->body_item_select_callback = [&submit_handler](BodyItem *body_item) {
- submit_handler();
+ submit_handler(body_item->get_title());
};
//select_body_item_by_room(tabs[selected_tab].body.get(), current_chat_room);
current_chat_room = nullptr;
@@ -1231,7 +1233,7 @@ namespace QuickMedia {
for(size_t i = 0; i < tabs.size(); ++i) {
Tab &tab = tabs[i];
tab.body->body_item_select_callback = [&submit_handler](BodyItem *body_item) {
- submit_handler();
+ submit_handler(body_item->get_title());
};
TabAssociatedData &associated_data = tab_associated_data[i];
@@ -1255,10 +1257,10 @@ namespace QuickMedia {
associated_data.typing = false;
};
- tab.search_bar->onTextSubmitCallback = [&submit_handler, &associated_data](const std::string&) {
+ tab.search_bar->onTextSubmitCallback = [&submit_handler, &associated_data](const std::string &search_text) {
if(associated_data.typing)
return;
- submit_handler();
+ submit_handler(search_text);
};
}
@@ -1355,7 +1357,10 @@ namespace QuickMedia {
} else if(event.key.code == sf::Keyboard::Tab) {
if(tabs[selected_tab].search_bar) tabs[selected_tab].search_bar->set_to_autocomplete();
} else if(event.key.code == sf::Keyboard::Enter) {
- if(!tabs[selected_tab].search_bar) submit_handler();
+ if(!tabs[selected_tab].search_bar) {
+ BodyItem *selected_item = tabs[selected_tab].body->get_selected();
+ submit_handler(selected_item ? selected_item->get_title() : "");
+ }
} else if(event.key.code == sf::Keyboard::T && event.key.control) {
BodyItem *selected_item = tabs[selected_tab].body->get_selected();
if(selected_item && tabs[selected_tab].page && tabs[selected_tab].page->is_trackable()) {
@@ -5132,11 +5137,10 @@ namespace QuickMedia {
auto matrix_invites_page_search_bar = create_search_bar("Search...", SEARCH_DELAY_FILTER);
auto matrix_invites_page = std::make_unique<MatrixInvitesPage>(this, matrix, invites_body.get(), matrix_invites_page_search_bar.get());
- //Tab options_tab = create_menu_selection_tab("Options",
- //{
- // { "Notifications", nullptr, 0, [](Program *program) { return std::make_unique<MatrixNotificationsPage>(program); } },
- // { "Room directory", "Search for search on...", SEARCH_DELAY_FILTER, [](Program *program) { return std::make_unique<MatrixRoomDirectoryPage>(program); } }
- //});
+ auto room_directory_body = create_body();
+ room_directory_body->items.push_back(BodyItem::create(matrix->get_homeserver_domain()));
+ room_directory_body->items.push_back(BodyItem::create("matrix.org"));
+ auto matrix_room_directory_page = std::make_unique<MatrixRoomDirectoryPage>(this, matrix);
MatrixQuickMedia matrix_handler(this, matrix, matrix_rooms_page.get(), matrix_rooms_tag_page.get(), matrix_invites_page.get());
bool sync_cached = false;
@@ -5147,6 +5151,7 @@ namespace QuickMedia {
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), std::move(matrix_rooms_tage_page_search_bar)});
tabs.push_back(Tab{std::move(invites_body), std::move(matrix_invites_page), std::move(matrix_invites_page_search_bar)});
+ tabs.push_back(Tab{std::move(room_directory_body), std::move(matrix_room_directory_page), create_search_bar("Server to search on...", SEARCH_DELAY_FILTER)});
while(window.isOpen()) {
page_loop(tabs);