From c5dec7a56157c71d124dafe191acfe95aa0fd4af Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 8 Jun 2025 12:20:13 +0200 Subject: Add --theme option, system_mpv_profile config and press g in matrix to start /encrypt chat immediately --- src/QuickMedia.cpp | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'src/QuickMedia.cpp') 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 ] [--instance ] [-e ] [--video-max-height ]\n"); + fprintf(stderr, "usage: quickmedia [plugin|url] [--no-video] [--upscale-images] [--upscale-images-always] [--dir ] [--instance ] [-e ] [--video-max-height ] [--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 The instance to use for peertube\n"); fprintf(stderr, " -e Embed QuickMedia into another window\n"); fprintf(stderr, " --video-max-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) { -- cgit v1.2.3-70-g09d2