aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/Entry.hpp2
-rw-r--r--include/SearchBar.hpp6
-rw-r--r--src/Entry.cpp4
-rw-r--r--src/QuickMedia.cpp8
-rw-r--r--src/SearchBar.cpp21
5 files changed, 24 insertions, 17 deletions
diff --git a/include/Entry.hpp b/include/Entry.hpp
index 2ef6b04..23535e4 100644
--- a/include/Entry.hpp
+++ b/include/Entry.hpp
@@ -13,7 +13,7 @@ namespace sf {
namespace QuickMedia {
// Return true to clear the text
- using OnEntrySubmit = std::function<bool(const sf::String& text)>;
+ using OnEntrySubmit = std::function<bool(const std::string& text)>;
class Entry {
public:
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp
index 8a1a8a0..e5245be 100644
--- a/include/SearchBar.hpp
+++ b/include/SearchBar.hpp
@@ -14,11 +14,11 @@ namespace sf {
}
namespace QuickMedia {
- using TextUpdateCallback = std::function<void(const sf::String &text)>;
+ using TextUpdateCallback = std::function<void(const std::string &text)>;
// Return true to consume the search (clear the search field)
- using TextSubmitCallback = std::function<bool(const sf::String &text)>;
+ using TextSubmitCallback = std::function<bool(const std::string &text)>;
using TextBeginTypingCallback = std::function<void()>;
- using AutocompleteRequestCallback = std::function<void(const sf::String &text)>;
+ using AutocompleteRequestCallback = std::function<void(const std::string &text)>;
class SearchBar {
public:
diff --git a/src/Entry.cpp b/src/Entry.cpp
index c57d6cb..2b9e573 100644
--- a/src/Entry.cpp
+++ b/src/Entry.cpp
@@ -26,7 +26,9 @@ namespace QuickMedia {
text.processEvent(event);
if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Enter && !event.key.shift) {
if(on_submit_callback) {
- bool clear_text = on_submit_callback(text.getString());
+ auto u8 = text.getString().toUtf8();
+ std::string *u8_str = (std::string*)&u8;
+ bool clear_text = on_submit_callback(*u8_str);
if(clear_text)
text.setString("");
}
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 283379a..a0e9b78 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1055,7 +1055,7 @@ namespace QuickMedia {
};
search_bar->autocomplete_search_delay = current_plugin->get_autocomplete_delay();
- search_bar->onAutocompleteRequestCallback = [this, &tabs, &selected_tab, &autocomplete_text](const sf::String &text) {
+ search_bar->onAutocompleteRequestCallback = [this, &tabs, &selected_tab, &autocomplete_text](const std::string &text) {
if(tabs[selected_tab].body == body && !current_plugin->search_is_filter())
autocomplete_text = text;
};
@@ -2666,7 +2666,7 @@ namespace QuickMedia {
show_notification("QuickMedia", "File manager failed to get files in directory: " + file_manager->get_current_dir().string(), Urgency::CRITICAL);
}
- search_bar->onTextUpdateCallback = [this](const sf::String &text) {
+ search_bar->onTextUpdateCallback = [this](const std::string &text) {
body->filter_search_fuzzy(text);
body->reset_selected();
};
@@ -3507,9 +3507,9 @@ namespace QuickMedia {
chat_input.draw_background = false;
chat_input.set_editable(false);
- chat_input.on_submit_callback = [matrix, &chat_input, &tabs, &selected_tab, &current_room_id, &new_page, &chat_state, &currently_operating_on_item](const sf::String &text) mutable {
+ chat_input.on_submit_callback = [matrix, &chat_input, &tabs, &selected_tab, &current_room_id, &new_page, &chat_state, &currently_operating_on_item](const std::string &text) mutable {
if(tabs[selected_tab].type == ChatTabType::MESSAGES) {
- if(text.isEmpty())
+ if(text.empty())
return false;
if(chat_state == ChatState::TYPING_MESSAGE && text[0] == '/') {
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index fa81c61..f489779 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -91,15 +91,19 @@ namespace QuickMedia {
sf::Int32 elapsed_time = time_since_search_update.getElapsedTime().asMilliseconds();
if(updated_search && elapsed_time >= text_autosearch_delay) {
updated_search = false;
- sf::String str = text.getString();
+ auto u8 = text.getString().toUtf8();
+ std::string *u8_str = (std::string*)&u8;
if(show_placeholder)
- str.clear();
+ u8_str->clear();
if(onTextUpdateCallback)
- onTextUpdateCallback(str);
+ onTextUpdateCallback(*u8_str);
} else if(updated_autocomplete && elapsed_time >= autocomplete_search_delay) {
updated_autocomplete = false;
- if(!show_placeholder && onAutocompleteRequestCallback)
- onAutocompleteRequestCallback(text.getString());
+ if(!show_placeholder && onAutocompleteRequestCallback) {
+ auto u8 = text.getString().toUtf8();
+ std::string *u8_str = (std::string*)&u8;
+ onAutocompleteRequestCallback(*u8_str);
+ }
}
}
@@ -165,10 +169,11 @@ namespace QuickMedia {
} else if(codepoint == 13) { // Return
bool clear_search = true;
if(onTextSubmitCallback) {
+ auto u8 = text.getString().toUtf8();
+ std::string *u8_str = (std::string*)&u8;
if(show_placeholder)
- clear_search = onTextSubmitCallback("");
- else
- clear_search = onTextSubmitCallback(text.getString());
+ u8_str->clear();
+ clear_search = onTextSubmitCallback(*u8_str);
}
if(clear_search)