aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-06-14 21:51:42 +0200
committerdec05eba <dec05eba@protonmail.com>2025-06-14 21:51:42 +0200
commit52f8dc5d05f5e34b0a3cf4bb4e4fe607f06965c5 (patch)
tree338a4a83685e0f0c7805ef3a884bec8274949f93 /src
parenta3843702b93513052e1e167d52f232b5a5301bd0 (diff)
Better G key behavior in matrix, add ctrl+g for encrypt reply, load mpris from system path if available for videos
Diffstat (limited to 'src')
-rw-r--r--src/Entry.cpp4
-rw-r--r--src/QuickMedia.cpp45
-rw-r--r--src/Text.cpp4
-rw-r--r--src/VideoPlayer.cpp32
4 files changed, 66 insertions, 19 deletions
diff --git a/src/Entry.cpp b/src/Entry.cpp
index 5416724..8aa2bba 100644
--- a/src/Entry.cpp
+++ b/src/Entry.cpp
@@ -107,6 +107,10 @@ namespace QuickMedia {
return text.getCaretIndex();
}
+ void Entry::set_caret_index(int index) {
+ text.setCaretIndex(index);
+ }
+
void Entry::set_position(const mgl::vec2f &pos) {
background.set_position(pos);
text.set_position(pos + mgl::vec2f(background_margin_horizontal * padding_scale, background_margin_vertical * padding_scale - (float)text.get_character_size() * 0.3f).floor());
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 8cdc874..3f59c14 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -7162,6 +7162,19 @@ namespace QuickMedia {
chat_state = ChatState::TYPING_MESSAGE;
};
+ auto start_replying = [&](std::shared_ptr<BodyItem> selected_body_item) {
+ RoomExtraData &room_extra_data = matrix->get_room_extra_data(current_room);
+ chat_state = ChatState::REPLYING;
+ currently_operating_on_item = selected_body_item;
+ 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();
+ }
+ replying_to_text.set_string("Replying to:");
+ frame_skip_text_entry = true;
+ };
+
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;
@@ -7313,7 +7326,11 @@ namespace QuickMedia {
if(event.key.code == mgl::Keyboard::G && !event.key.control) {
start_typing();
- chat_input.set_text("/encrypt ");
+ std::string chat_text = chat_input.get_text();
+ if(!string_starts_with(chat_text, "/encrypt")) {
+ chat_input.set_text("/encrypt " + chat_text);
+ chat_input.set_caret_index(chat_input.get_caret_index() + 9);
+ }
}
if(event.key.control && event.key.code == mgl::Keyboard::V) {
@@ -7400,21 +7417,27 @@ namespace QuickMedia {
// TODO: Show inline notification
show_notification("QuickMedia", "You can't reply to a message that hasn't been sent yet");
} else {
- RoomExtraData &room_extra_data = matrix->get_room_extra_data(current_room);
- chat_state = ChatState::REPLYING;
- currently_operating_on_item = selected;
- 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();
- }
- replying_to_text.set_string("Replying to:");
- frame_skip_text_entry = true;
+ start_replying(std::move(selected));
}
}
}
}
+ if(event.key.code == mgl::Keyboard::G && event.key.control) {
+ std::shared_ptr<BodyItem> selected = tabs[selected_tab].body->get_selected_shared();
+ if(static_cast<Message*>(selected->userdata)->event_id.empty()) {
+ // TODO: Show inline notification
+ show_notification("QuickMedia", "You can't reply to a message that hasn't been sent yet");
+ } else {
+ start_replying(std::move(selected));
+ std::string chat_text = chat_input.get_text();
+ if(!string_starts_with(chat_text, "/encrypt")) {
+ chat_input.set_text("/encrypt " + chat_text);
+ chat_input.set_caret_index(chat_input.get_caret_index() + 9);
+ }
+ }
+ }
+
if(event.key.code == mgl::Keyboard::B && event.key.control) {
// Reload room, goes to latest message l0l
move_room = true;
diff --git a/src/Text.cpp b/src/Text.cpp
index 2b62798..6333e8e 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -285,6 +285,10 @@ namespace QuickMedia
int Text::getCaretIndex() const {
return caretIndex;
}
+
+ void Text::setCaretIndex(int index) {
+ caretIndex = index;
+ }
void Text::set_color(mgl::Color color, bool force_color)
{
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index da92bf7..ea18289 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -177,7 +177,6 @@ namespace QuickMedia {
const std::string config_dir = "--config-dir=" + startup_args.resource_root + "mpv";
const std::string input_conf_file = "--input-conf=" + startup_args.resource_root + "mpv/input.conf";
- const std::string ytdl_hook_file = "--scripts=" + startup_args.resource_root + "mpv/scripts/ytdl_hook.lua";
std::vector<const char*> args;
// TODO: Resume playback if the last video played matches the first video played next time QuickMedia is launched
@@ -251,18 +250,33 @@ namespace QuickMedia {
if(!startup_args.referer.empty())
args.push_back(referer_arg.c_str());
- std::string mpris_arg;
- Path mpris_path = get_config_dir_xdg().join("mpv").join("scripts").join("mpris.so");
- if(get_file_type(mpris_path) == FileType::REGULAR)
- mpris_arg = "--scripts=" + mpris_path.data;
+ std::string scripts;
+ std::string scripts_arg;
+
+ const Path mpris_path = get_config_dir_xdg().join("mpv").join("scripts").join("mpris.so");
+ if(get_file_type(mpris_path) == FileType::REGULAR) {
+ if(!scripts.empty())
+ scripts += ":";
+ scripts += mpris_path.data;
+ }
+
+ const Path mpris_system_path = "/etc/mpv/scripts/mpris.so";
+ if(get_file_type(mpris_system_path) == FileType::REGULAR) {
+ if(!scripts.empty())
+ scripts += ":";
+ scripts += mpris_system_path.data;
+ }
std::string profile_arg;
if(startup_args.use_system_mpv_config) {
+ if(!scripts.empty())
+ scripts += ":";
+ scripts += startup_args.resource_root + "mpv/scripts/ytdl_hook.lua";
+
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;
@@ -271,9 +285,11 @@ namespace QuickMedia {
config_dir.c_str(),
"--config=yes"
});
+ }
- if(!mpris_arg.empty())
- args.push_back(mpris_arg.c_str());
+ if(!scripts.empty()) {
+ scripts_arg = "--scripts=" + scripts;
+ args.push_back(scripts_arg.c_str());
}
if(!profile_arg.empty())