Add option to press backspace to remove hotkey

This commit is contained in:
dec05eba
2025-02-25 01:21:23 +01:00
parent b6c59e1049
commit d9a1e5c2eb
2 changed files with 24 additions and 5 deletions

10
TODO
View File

@@ -126,3 +126,13 @@ Add support for window capture. This should not prompt for window selection dire
For screenshots window capture should exist but "follow focused" option should not exist.
Improve audio design. It should have a button to add/remove audio tracks and button to add audio into each audio track separately and "record audio from all applications except the selected ones" for each audio track. Then also remove the "merge audio tracks" option.
Make it possible to take a screenshot through a button in the ui instead of having to use hotkey.
Handle failing to save a replay. gsr should output "failed to save replay, or something like that" to make it possible to detect that.
Dont allow saving replay while a replay save is in progress.
Make input work with cjk input systems (such as fcitx).
System startup option should also support runit and some other init systems, not only soystemd.

View File

@@ -94,7 +94,7 @@ namespace gsr {
mgl::Text title_text("Press a key combination to use for the hotkey \"" + hotkey_configure_action_name + "\":", get_theme().title_font);
mgl::Text hotkey_text(configure_hotkey_button->get_text(), get_theme().top_bar_font);
mgl::Text description_text("The hotkey has to contain one or more of these keys: Alt, Ctrl, Shift and Super. Press Esc to cancel.", get_theme().body_font);
mgl::Text description_text("The hotkey has to contain one or more of these keys: Alt, Ctrl, Shift and Super. Press Esc to cancel or Backspace to remove the hotkey.", get_theme().body_font);
const float text_max_width = std::max(title_text.get_bounds().size.x, std::max(hotkey_text.get_bounds().size.x, description_text.get_bounds().size.x));
const float padding_horizontal = int(get_theme().window_height * 0.01f);
@@ -470,6 +470,13 @@ namespace gsr {
if(event.key.code == mgl::Keyboard::Escape)
return false;
if(event.key.code == mgl::Keyboard::Backspace) {
configure_config_hotkey = {mgl::Keyboard::Unknown, 0};
configure_hotkey_button->set_text("");
configure_hotkey_stop_and_save();
return false;
}
if(mgl::Keyboard::key_is_modifier(event.key.code)) {
configure_config_hotkey.modifiers |= mgl_modifier_to_hotkey_modifier(event.key.code);
configure_hotkey_button->set_text(configure_config_hotkey.to_string());
@@ -612,10 +619,12 @@ namespace gsr {
ConfigHotkey *config_hotkey = configure_hotkey_get_config_by_active_type();
if(config_hotkey_button && config_hotkey) {
bool hotkey_used_by_another_action = false;
for_each_config_hotkey([&](ConfigHotkey *config_hotkey_item) {
if(config_hotkey_item != config_hotkey && *config_hotkey_item == configure_config_hotkey)
hotkey_used_by_another_action = true;
});
if(configure_config_hotkey.key != mgl::Keyboard::Unknown) {
for_each_config_hotkey([&](ConfigHotkey *config_hotkey_item) {
if(config_hotkey_item != config_hotkey && *config_hotkey_item == configure_config_hotkey)
hotkey_used_by_another_action = true;
});
}
if(hotkey_used_by_another_action) {
const std::string error_msg = "The hotkey \"" + configure_config_hotkey.to_string() + " is already used for something else";