aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-07-03 04:38:39 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-03 04:38:42 +0200
commit837c9a29dc72dc42a160d6777f1935f1f272d072 (patch)
tree1c004cbe910d368425a69e56776282d717423b82 /src/QuickMedia.cpp
parent13681189d41f3d5c6c132d92b7451fea151fb713 (diff)
Fix being able to submit text while searching, filter not cleared when exiting images view
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 15e345b..55f8688 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -211,6 +211,7 @@ namespace QuickMedia {
case Page::SEARCH_SUGGESTION:
body->draw_thumbnails = current_plugin->search_suggestions_has_thumbnails();
search_suggestion_page();
+ search_bar->onTextBeginTypingCallback = nullptr;
break;
#if 0
case Page::SEARCH_RESULT:
@@ -231,6 +232,8 @@ namespace QuickMedia {
window.setKeyRepeatEnabled(false);
window.setFramerateLimit(4);
image_page();
+ body->filter_search_fuzzy("");
+ body->select_first_item();
window.setFramerateLimit(0);
window.setKeyRepeatEnabled(true);
break;
@@ -238,6 +241,8 @@ namespace QuickMedia {
case Page::IMAGES_CONTINUOUS: {
body->draw_thumbnails = false;
image_continuous_page();
+ body->filter_search_fuzzy("");
+ body->select_first_item();
break;
}
case Page::CONTENT_LIST: {
@@ -333,6 +338,7 @@ namespace QuickMedia {
void Program::search_suggestion_page() {
std::string update_search_text;
bool search_running = false;
+ bool typing = false;
Body history_body(this, font, bold_font);
const float tab_text_size = 18.0f;
@@ -386,16 +392,24 @@ namespace QuickMedia {
});
}
- search_bar->onTextUpdateCallback = [&update_search_text, this, &tabs, &selected_tab](const std::string &text) {
+ search_bar->onTextBeginTypingCallback = [&typing]() {
+ typing = true;
+ };
+
+ search_bar->onTextUpdateCallback = [&update_search_text, this, &tabs, &selected_tab, &typing](const std::string &text) {
if(tabs[selected_tab].body == body && !current_plugin->search_is_filter())
update_search_text = text;
else {
tabs[selected_tab].body->filter_search_fuzzy(text);
tabs[selected_tab].body->clamp_selection();
}
+ typing = false;
};
- search_bar->onTextSubmitCallback = [this, &tabs, &selected_tab](const std::string &text) -> bool {
+ search_bar->onTextSubmitCallback = [this, &tabs, &selected_tab, &typing](const std::string &text) -> bool {
+ if(typing || text.empty())
+ return false;
+
Page next_page = current_plugin->get_page_after_search();
// TODO: This shouldn't be done if search_selected_suggestion fails
if(search_selected_suggestion(tabs[selected_tab].body, body, current_plugin, content_title, content_url) != SearchResult::OK) {
@@ -552,6 +566,8 @@ namespace QuickMedia {
search_bar->draw(window, false);
window.display();
}
+
+ search_bar->onTextBeginTypingCallback = nullptr;
}
void Program::search_result_page() {