aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp23
-rw-r--r--src/SearchBar.cpp9
2 files changed, 21 insertions, 11 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 0845d43..29deaa3 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -109,11 +109,12 @@ namespace QuickMedia {
}
static void usage() {
- fprintf(stderr, "usage: QuickMedia <plugin> [--tor]\n");
+ fprintf(stderr, "usage: QuickMedia <plugin> [--tor] [--use-system-mpv-config] [-p placeholder-text]\n");
fprintf(stderr, "OPTIONS:\n");
- fprintf(stderr, "plugin The plugin to use. Should be either 4chan, manganelo, mangatown, mangadex, pornhub, youtube or dmenu\n");
- fprintf(stderr, "--tor Use tor. Disabled by default\n");
- fprintf(stderr, "--use-system-mpv-config Use system mpv config instead of no config. Disabled by default\n");
+ fprintf(stderr, " plugin The plugin to use. Should be either 4chan, manganelo, mangatown, mangadex, pornhub, youtube or dmenu\n");
+ fprintf(stderr, " --tor Use tor. Disabled by default\n");
+ fprintf(stderr, " --use-system-mpv-config Use system mpv config instead of no config. Disabled by default\n");
+ fprintf(stderr, " -p Change the placeholder text for dmenu\n");
fprintf(stderr, "EXAMPLES:\n");
fprintf(stderr, "QuickMedia manganelo\n");
fprintf(stderr, "QuickMedia youtube --tor\n");
@@ -147,6 +148,7 @@ namespace QuickMedia {
current_plugin = nullptr;
std::string plugin_logo_path;
+ std::string search_placeholder = "Search...";
for(int i = 1; i < argc; ++i) {
if(!current_plugin) {
@@ -181,6 +183,11 @@ namespace QuickMedia {
use_tor = true;
} else if(strcmp(argv[i], "--use-system-mpv-config") == 0) {
use_system_mpv_config = true;
+ } else if(strcmp(argv[i], "-p") == 0) {
+ if(i < argc - 1) {
+ search_placeholder = argv[i + 1];
+ ++i;
+ }
} else if(argv[i][0] == '-') {
fprintf(stderr, "Invalid option %s\n", argv[i]);
usage();
@@ -204,7 +211,7 @@ namespace QuickMedia {
plugin_logo.setSmooth(true);
}
- search_bar = std::make_unique<SearchBar>(font, plugin_logo);
+ search_bar = std::make_unique<SearchBar>(font, plugin_logo, search_placeholder);
search_bar->text_autosearch_delay = current_plugin->get_search_delay();
while(window.isOpen()) {
@@ -415,8 +422,10 @@ namespace QuickMedia {
};
search_bar->onTextSubmitCallback = [this, &tabs, &selected_tab, &typing](const std::string &text) -> bool {
- if(typing || text.empty())
- return false;
+ if(current_plugin->name != "dmenu") {
+ if(typing || text.empty())
+ return false;
+ }
Page next_page = current_plugin->get_page_after_search();
bool skip_search = next_page == Page::VIDEO_CONTENT;
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index 9d8a168..5c3c35c 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -11,15 +11,16 @@ const float PADDING_HORIZONTAL = 50.0f;
const float padding_vertical = 20.0f;
namespace QuickMedia {
- SearchBar::SearchBar(sf::Font &font, sf::Texture &plugin_logo) :
+ SearchBar::SearchBar(sf::Font &font, sf::Texture &plugin_logo, const std::string &placeholder) :
onTextUpdateCallback(nullptr),
onTextSubmitCallback(nullptr),
onTextBeginTypingCallback(nullptr),
onAutocompleteRequestCallback(nullptr),
text_autosearch_delay(0),
autocomplete_search_delay(0),
- text("Search...", font, 18),
+ text(placeholder, font, 18),
autocomplete_text("", font, 18),
+ placeholder_str(placeholder),
show_placeholder(true),
updated_search(false),
updated_autocomplete(false),
@@ -116,7 +117,7 @@ namespace QuickMedia {
text.setString(str);
if(str.getSize() == 0) {
show_placeholder = true;
- text.setString("Search...");
+ text.setString(placeholder_str);
text.setFillColor(text_placeholder_color);
autocomplete_text.setString("");
} else {
@@ -158,7 +159,7 @@ namespace QuickMedia {
if(show_placeholder)
return;
show_placeholder = true;
- text.setString("Search...");
+ text.setString(placeholder_str);
text.setFillColor(text_placeholder_color);
autocomplete_text.setString("");
needs_update = true;