aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp57
1 files changed, 44 insertions, 13 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index f7d35d9..f11b69f 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1770,6 +1770,47 @@ namespace QuickMedia {
}
}
+ static void copy_body_item_text_to_clipboard(BodyItem *body_item) {
+ if(!body_item)
+ return;
+
+ std::string title = body_item->get_title();
+ std::string author = body_item->get_author();
+ std::string description = body_item->get_description();
+
+ std::string clipboard = std::move(title);
+
+ if(!author.empty()) {
+ if(!clipboard.empty())
+ clipboard += '\n';
+ clipboard += std::move(author);
+ }
+
+ if(!description.empty()) {
+ if(!clipboard.empty())
+ clipboard += '\n';
+ clipboard += std::move(description);
+ }
+
+ if(!clipboard.empty())
+ sf::Clipboard::setString(sf::String::fromUtf8(clipboard.begin(), clipboard.end()));
+ }
+
+ static void set_search_bar_to_body_item_text(BodyItem *body_item, SearchBar *search_bar) {
+ if(!body_item || !search_bar)
+ return;
+
+ if(!body_item->get_title().empty()) {
+ search_bar->set_text(body_item->get_title());
+ return;
+ }
+
+ if(!body_item->get_author().empty()) {
+ search_bar->set_text(body_item->get_author());
+ return;
+ }
+ }
+
bool Program::page_loop(std::vector<Tab> &tabs, int start_tab_index, PageLoopSubmitHandler after_submit_handler) {
if(tabs.empty()) {
show_notification("QuickMedia", "No tabs provided!", Urgency::CRITICAL);
@@ -2153,23 +2194,13 @@ namespace QuickMedia {
}
}
} else if(event.key.code == sf::Keyboard::C && event.key.control) {
- BodyItem *selected_item = tabs[selected_tab].body->get_selected();
- if(selected_item) {
- std::string title = selected_item->get_title();
- std::string description = selected_item->get_description();
- std::string clipboard = std::move(title);
- if(!description.empty()) {
- if(!clipboard.empty())
- clipboard += '\n';
- clipboard += std::move(description);
- }
- if(!clipboard.empty())
- sf::Clipboard::setString(sf::String::fromUtf8(clipboard.begin(), clipboard.end()));
- }
+ copy_body_item_text_to_clipboard(tabs[selected_tab].body->get_selected());
} else if(event.key.code == sf::Keyboard::I && event.key.control) {
BodyItem *selected_item = tabs[selected_tab].body->get_selected();
if(show_info_page(selected_item, false))
redraw = true;
+ } else if(event.key.code == sf::Keyboard::Tab && !event.key.control) {
+ set_search_bar_to_body_item_text(tabs[selected_tab].body->get_selected(), tabs[selected_tab].search_bar.get());
}
}
}