diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-09-09 19:40:19 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-09-09 19:40:19 +0200 |
commit | 9c5cd0ebb51350c05d3fc3496851f43a209f84ec (patch) | |
tree | 64b09af13842ed36efefd78f71e77b6ef8e26aba /src | |
parent | 6d9a07369a9ae20f73cf0d70cdf8b3e0cc06e87d (diff) |
Do not require ctrl for vim keys for manga and matrix
Diffstat (limited to 'src')
-rw-r--r-- | src/Body.cpp | 11 | ||||
-rw-r--r-- | src/ImageViewer.cpp | 4 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 14 |
3 files changed, 16 insertions, 13 deletions
diff --git a/src/Body.cpp b/src/Body.cpp index 5a72165..5de0c56 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -471,23 +471,24 @@ namespace QuickMedia { } } - bool Body::on_event(const mgl::Window &window, const mgl::Event &event, bool keyboard_navigation) { + bool Body::on_event(const mgl::Window &window, const mgl::Event &event, bool keyboard_navigation, bool vim_keys_require_ctrl) { if(keyboard_navigation && event.type == mgl::Event::KeyPressed && !event.key.alt) { const bool rendering_card_view = card_view && card_view_enabled; + const bool vim_keys_valid = (vim_keys_require_ctrl && event.key.control) || !vim_keys_require_ctrl; - if(event.key.code == mgl::Keyboard::Up || (event.key.control && event.key.code == mgl::Keyboard::K)) { + if(event.key.code == mgl::Keyboard::Up || (vim_keys_valid && event.key.code == mgl::Keyboard::K)) { render_selected_item_bg = true; bool top_reached = select_previous_item(true); if(!top_reached && on_top_reached) on_top_reached(); return true; - } else if(event.key.code == mgl::Keyboard::Down || (event.key.control && event.key.code == mgl::Keyboard::J)) { + } else if(event.key.code == mgl::Keyboard::Down || (vim_keys_valid && event.key.code == mgl::Keyboard::J)) { render_selected_item_bg = true; bool bottom_reached = select_next_item(true); if(!bottom_reached && on_bottom_reached) on_bottom_reached(); return true; - } else if(rendering_card_view && selected_column > 0 && ((!event.key.control && event.key.code == mgl::Keyboard::Left) || (event.key.control && event.key.code == mgl::Keyboard::H))) { + } else if(rendering_card_view && selected_column > 0 && ((!event.key.control && event.key.code == mgl::Keyboard::Left) || (vim_keys_valid && event.key.code == mgl::Keyboard::H))) { render_selected_item_bg = true; const int new_selected_item = get_previous_visible_item(selected_item); if(new_selected_item != -1) { @@ -496,7 +497,7 @@ namespace QuickMedia { on_top_reached(); } return true; - } else if(rendering_card_view && selected_column + 1 < num_columns && ((!event.key.control && event.key.code == mgl::Keyboard::Right) || (event.key.control && event.key.code == mgl::Keyboard::L))) { + } else if(rendering_card_view && selected_column + 1 < num_columns && ((!event.key.control && event.key.code == mgl::Keyboard::Right) || (vim_keys_valid && event.key.code == mgl::Keyboard::L))) { render_selected_item_bg = true; const int new_selected_item = get_next_visible_item(selected_item); if(new_selected_item != -1) { diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp index 179669d..e670d66 100644 --- a/src/ImageViewer.cpp +++ b/src/ImageViewer.cpp @@ -217,11 +217,11 @@ namespace QuickMedia { } static bool is_key_scroll_up(const mgl::Event::KeyEvent &key) { - return (!key.control && key.code == mgl::Keyboard::Up) || (!key.alt && key.control && key.code == mgl::Keyboard::K); + return (!key.control && key.code == mgl::Keyboard::Up) || (!key.alt && key.code == mgl::Keyboard::K); } static bool is_key_scroll_down(const mgl::Event::KeyEvent &key) { - return (!key.control && key.code == mgl::Keyboard::Down) || (!key.alt && key.control && key.code == mgl::Keyboard::J); + return (!key.control && key.code == mgl::Keyboard::Down) || (!key.alt && key.code == mgl::Keyboard::J); } void ImageViewer::scroll_to_page(int page) { diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 9f233da..95938c5 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -4138,7 +4138,7 @@ namespace QuickMedia { } else if(event.type == mgl::Event::GainedFocus) { redraw = true; } else if(event.type == mgl::Event::KeyPressed) { - if((!event.key.control && event.key.code == mgl::Keyboard::Up) || (!event.key.alt && event.key.control && event.key.code == mgl::Keyboard::K)) { + if((!event.key.control && event.key.code == mgl::Keyboard::Up) || (!event.key.alt && event.key.code == mgl::Keyboard::K)) { if(image_index > 0) { --image_index; goto end_of_images_page; @@ -4146,7 +4146,7 @@ namespace QuickMedia { page_navigation = -1; goto end_of_images_page; } - } else if((!event.key.control && event.key.code == mgl::Keyboard::Down) || (!event.key.alt && event.key.control && event.key.code == mgl::Keyboard::J)) { + } else if((!event.key.control && event.key.code == mgl::Keyboard::Down) || (!event.key.alt && event.key.code == mgl::Keyboard::J)) { if(image_index < num_manga_pages) { ++image_index; goto end_of_images_page; @@ -6626,24 +6626,26 @@ namespace QuickMedia { ui_tabs.on_event(event); if(chat_state == ChatState::URL_SELECTION) { - if(url_selection_body.on_event(window, event)) + if(url_selection_body.on_event(window, event, true, false)) idle_active_handler(); } else { - if(tabs[selected_tab].body->on_event(window, event, chat_state == ChatState::NAVIGATING)) + if(tabs[selected_tab].body->on_event(window, event, chat_state == ChatState::NAVIGATING, false)) idle_active_handler(); } base_event_handler(event, PageType::EXIT, tabs[selected_tab].body.get(), nullptr, false, false); event_idle_handler(event); if(!frame_skip_text_entry) { - if(!mention.visible || event.type != mgl::Event::KeyPressed || (event.key.code != mgl::Keyboard::Up && event.key.code != mgl::Keyboard::Down && event.key.code != mgl::Keyboard::Left && event.key.code != mgl::Keyboard::Right)) + const bool move_arrows = (event.key.code == mgl::Keyboard::Up || event.key.code == mgl::Keyboard::Down || event.key.code == mgl::Keyboard::Left || event.key.code == mgl::Keyboard::Right); + const bool move_vim_keys = (event.key.control && (event.key.code == mgl::Keyboard::J || event.key.code != mgl::Keyboard::K)); + if(!mention.visible || event.type != mgl::Event::KeyPressed || (!move_arrows && !move_vim_keys)) chat_input.process_event(window, event); if(chat_input.is_editable()) mention.handle_event(event); } if(draw_room_list) { - if(matrix_chat_page->rooms_page->body->on_event(window, event, false)) + if(matrix_chat_page->rooms_page->body->on_event(window, event, false, false)) idle_active_handler(); } |