aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-03-09 02:04:19 +0100
committerdec05eba <dec05eba@protonmail.com>2021-03-09 02:04:19 +0100
commit1fe31ba2e244d9ae26d1f8d00f411713d2eaacf7 (patch)
treeb8fbb0d8ed2c81dcbee1e4e94e33f0839333ddf7 /src
parentf8617f2043ea4ec536c4622df63a77b25268aeb0 (diff)
Fix clipboard unicode
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp6
-rw-r--r--src/QuickMedia.cpp15
-rw-r--r--src/SearchBar.cpp6
3 files changed, 17 insertions, 10 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 44d1a2d..ca91566 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -567,7 +567,7 @@ namespace QuickMedia {
if(body_item->dirty) {
body_item->dirty = false;
// TODO: Find a way to optimize fromUtf8
- sf::String str = sf::String::fromUtf8(body_item->get_title().data(), body_item->get_title().data() + body_item->get_title().size());
+ sf::String str = sf::String::fromUtf8(body_item->get_title().begin(), body_item->get_title().end());
if(body_item->title_text)
body_item->title_text->setString(std::move(str));
else
@@ -578,7 +578,7 @@ namespace QuickMedia {
if(body_item->dirty_description) {
body_item->dirty_description = false;
- sf::String str = sf::String::fromUtf8(body_item->get_description().data(), body_item->get_description().data() + body_item->get_description().size());
+ sf::String str = sf::String::fromUtf8(body_item->get_description().begin(), body_item->get_description().end());
if(body_item->description_text)
body_item->description_text->setString(std::move(str));
else
@@ -589,7 +589,7 @@ namespace QuickMedia {
if(body_item->dirty_author) {
body_item->dirty_author = false;
- sf::String str = sf::String::fromUtf8(body_item->get_author().data(), body_item->get_author().data() + body_item->get_author().size());
+ sf::String str = sf::String::fromUtf8(body_item->get_author().begin(), body_item->get_author().end());
if(body_item->author_text)
body_item->author_text->setString(std::move(str));
else
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 03fe6b2..7e758b9 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1838,9 +1838,11 @@ namespace QuickMedia {
double time_in_file;
if(video_player->get_time_in_file(&time_in_file) != VideoPlayer::Error::OK)
time_in_file = 0.0;
- sf::Clipboard::setString(video_url + "&t=" + std::to_string((int)time_in_file));
+
+ std::string clipboard = video_url + "&t=" + std::to_string((int)time_in_file);
+ sf::Clipboard::setString(sf::String::fromUtf8(clipboard.begin(), clipboard.end()));
} else {
- sf::Clipboard::setString(video_url);
+ sf::Clipboard::setString(sf::String::fromUtf8(video_url.begin(), video_url.end()));
}
};
@@ -4331,8 +4333,10 @@ namespace QuickMedia {
if(current_room) {
if(event.key.control && event.key.code == sf::Keyboard::C) {
BodyItem *selected = tabs[selected_tab].body->get_selected();
- if(selected)
- sf::Clipboard::setString(selected->get_description());
+ if(selected) {
+ auto desc = selected->get_description();
+ sf::Clipboard::setString(sf::String::fromUtf8(desc.begin(), desc.end()));
+ }
}
}
@@ -4352,7 +4356,8 @@ namespace QuickMedia {
if(event.key.control && event.key.code == sf::Keyboard::V) {
frame_skip_text_entry = true;
// TODO: Upload multiple files.
- upload_file(sf::Clipboard::getString());
+ auto clipboard = sf::Clipboard::getString().toUtf8();
+ upload_file(std::string(clipboard.begin(), clipboard.end()));
}
if(event.key.code == sf::Keyboard::R) {
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index 5c5b860..9b5e882 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -92,8 +92,10 @@ namespace QuickMedia {
backspace_pressed = true;
else if(event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Backspace)
backspace_pressed = false;
- if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::V && event.key.control)
- append_text(sf::Clipboard::getString());
+ if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::V && event.key.control) {
+ auto clipboard = sf::Clipboard::getString().toUtf8();
+ append_text(std::string(clipboard.begin(), clipboard.end()));
+ }
if(event.type == sf::Event::TextEntered && event.text.unicode != 8 && event.text.unicode != 127) // 8 = backspace, 127 = del
onTextEntered(event.text.unicode);
else if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Backspace)