aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-06-08 12:20:13 +0200
committerdec05eba <dec05eba@protonmail.com>2025-06-08 12:20:13 +0200
commitc5dec7a56157c71d124dafe191acfe95aa0fd4af (patch)
tree7ef0752d632221a4ef19ae23cc60fbb4265a0567 /src
parentc71a676edf4ccc583652e1f31c571f3cd898d60e (diff)
Add --theme option, system_mpv_profile config and press g in matrix to start /encrypt chat immediately
Diffstat (limited to 'src')
-rw-r--r--src/Config.cpp3
-rw-r--r--src/QuickMedia.cpp46
-rw-r--r--src/VideoPlayer.cpp7
3 files changed, 44 insertions, 12 deletions
diff --git a/src/Config.cpp b/src/Config.cpp
index ecc1fce..64d5019 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -406,6 +406,7 @@ namespace QuickMedia {
get_json_value(json_root, "use_system_fonts", config->use_system_fonts);
get_json_value(json_root, "use_system_mpv_config", config->use_system_mpv_config);
+ get_json_value(json_root, "system_mpv_profile", config->system_mpv_profile);
get_json_value(json_root, "enable_shaders", config->enable_shaders);
get_json_value(json_root, "theme", config->theme);
get_json_value(json_root, "scale", config->scale);
@@ -414,7 +415,7 @@ namespace QuickMedia {
get_json_value(json_root, "low_latency_mode", config->low_latency_mode);
}
- const Config& get_config() {
+ Config& get_config() {
init_config();
return *config;
}
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index b09e09f..037d218 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -339,7 +339,7 @@ namespace QuickMedia {
}
static void usage() {
- fprintf(stderr, "usage: quickmedia [plugin|url] [--no-video] [--upscale-images] [--upscale-images-always] [--dir <directory>] [--instance <instance>] [-e <window>] [--video-max-height <height>]\n");
+ fprintf(stderr, "usage: quickmedia [plugin|url] [--no-video] [--upscale-images] [--upscale-images-always] [--dir <directory>] [--instance <instance>] [-e <window>] [--video-max-height <height>] [--theme <theme>]\n");
fprintf(stderr, "OPTIONS:\n");
fprintf(stderr, " plugin|url The plugin to use. Should be either launcher, 4chan, manga, manganelo, manganelos, mangatown, mangakatana, mangadex, onimanga, local-manga, local-anime, youtube, peertube, lbry, soundcloud, nyaa.si, matrix, saucenao, hotexamples, anilist, dramacool, file-manager, stdin, pornhub, spankbang, xvideos or xhamster. This can also be a youtube url, youtube channel url or a 4chan thread url\n");
fprintf(stderr, " --no-video Only play audio when playing a video. Disabled by default\n");
@@ -349,6 +349,7 @@ namespace QuickMedia {
fprintf(stderr, " --instance <instance> The instance to use for peertube\n");
fprintf(stderr, " -e <window-id> Embed QuickMedia into another window\n");
fprintf(stderr, " --video-max-height <height> Media plugins will try to select a video source that is this size or smaller\n");
+ fprintf(stderr, " --theme The theme to use. If this is specified then it overrides the theme selected in the QuickMedia config file. Optional.\n");
fprintf(stderr, "EXAMPLES:\n");
fprintf(stderr, " quickmedia\n");
fprintf(stderr, " quickmedia --upscale-images-always manganelo\n");
@@ -409,6 +410,7 @@ namespace QuickMedia {
std::string program_path = Path(argv[0]).parent().data;
std::string instance;
std::string download_filename;
+ std::string theme;
bool no_dialog = false;
for(int i = 1; i < argc; ++i) {
@@ -523,6 +525,15 @@ namespace QuickMedia {
}
} else if(strcmp(argv[i], "--no-dialog") == 0) {
no_dialog = true;
+ } else if(strcmp(argv[i], "--theme") == 0) {
+ if(i < argc - 1) {
+ theme = argv[i + 1];
+ ++i;
+ } else {
+ fprintf(stderr, "Missing theme after --theme argument\n");
+ usage();
+ return -1;
+ }
} else if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
usage();
return 0;
@@ -602,7 +613,7 @@ namespace QuickMedia {
};
no_video = force_no_video;
- init(parent_window, program_path, no_dialog);
+ init(parent_window, program_path, no_dialog, theme);
if(strcmp(plugin_name, "download") == 0) {
if(!url) {
@@ -687,7 +698,7 @@ namespace QuickMedia {
return focused_monitor_center;
}
- void Program::init(mgl::WindowHandle parent_window, std::string &program_path, bool no_dialog) {
+ void Program::init(mgl::WindowHandle parent_window, std::string &program_path, bool no_dialog, const std::string &theme) {
disp = XOpenDisplay(NULL);
if (!disp) {
show_notification("QuickMedia", "Failed to open display to X11 server", Urgency::CRITICAL);
@@ -699,6 +710,9 @@ namespace QuickMedia {
// Initialize config and theme early to prevent possible race condition on initialize
get_config();
+ if(!theme.empty())
+ get_config().theme = theme;
+
get_theme();
mgl::vec2i monitor_size;
@@ -3516,6 +3530,7 @@ namespace QuickMedia {
startup_args.parent_window = window.get_system_handle();
startup_args.no_video = is_audio_only;
startup_args.use_system_mpv_config = get_config().use_system_mpv_config || video_page->is_local();
+ startup_args.system_mpv_profile = get_config().system_mpv_profile;
startup_args.use_system_input_config = video_page->is_local();
startup_args.keep_open = is_matrix && !is_youtube;
startup_args.resume = false;
@@ -7133,6 +7148,17 @@ namespace QuickMedia {
}
};
+ auto start_typing = [&] {
+ RoomExtraData &room_extra_data = matrix->get_room_extra_data(current_room);
+ frame_skip_text_entry = true;
+ chat_input.set_editable(true);
+ if(get_config().matrix.clear_message_on_escape || !room_extra_data.editing_message_id.empty()) {
+ chat_input.set_text("");
+ room_extra_data.editing_message_id.clear();
+ }
+ chat_state = ChatState::TYPING_MESSAGE;
+ };
+
for(size_t i = 0; i < tabs.size(); ++i) {
tabs[i].body->on_top_reached = on_top_reached;
tabs[i].body->on_bottom_reached = on_bottom_reached;
@@ -7279,14 +7305,12 @@ namespace QuickMedia {
}
if(event.key.code == mgl::Keyboard::I && !event.key.control) {
- RoomExtraData &room_extra_data = matrix->get_room_extra_data(current_room);
- frame_skip_text_entry = true;
- chat_input.set_editable(true);
- if(get_config().matrix.clear_message_on_escape || !room_extra_data.editing_message_id.empty()) {
- chat_input.set_text("");
- room_extra_data.editing_message_id.clear();
- }
- chat_state = ChatState::TYPING_MESSAGE;
+ start_typing();
+ }
+
+ if(event.key.code == mgl::Keyboard::G && !event.key.control) {
+ start_typing();
+ chat_input.set_text("/encrypt ");
}
if(event.key.control && event.key.code == mgl::Keyboard::V) {
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index 3aa4eca..0fac7aa 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -256,12 +256,16 @@ namespace QuickMedia {
if(get_file_type(mpris_path) == FileType::REGULAR)
mpris_arg = "--scripts=" + mpris_path.data;
+ std::string profile_arg;
if(startup_args.use_system_mpv_config) {
args.push_back("--config=yes");
args.push_back("--load-scripts=yes");
args.push_back("--osc=yes");
args.push_back(input_conf_file.c_str());
args.push_back(ytdl_hook_file.c_str());
+
+ if(!startup_args.system_mpv_profile.empty())
+ profile_arg = "--profile=" + startup_args.system_mpv_profile;
} else {
args.insert(args.end(), {
config_dir.c_str(),
@@ -272,6 +276,9 @@ namespace QuickMedia {
args.push_back(mpris_arg.c_str());
}
+ if(!profile_arg.empty())
+ args.push_back(profile_arg.c_str());
+
std::string force_media_title_arg;
if(!startup_args.title.empty()) {
force_media_title_arg = "--force-media-title=" + startup_args.title;