diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-01-30 22:30:46 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-01 09:54:32 +0100 |
commit | d9e7e13fb23f1d904c439ded253c2be14f82c86b (patch) | |
tree | 41a0d7fb2aca55d1e7706de55fd5a3c62b5c2664 /Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp | |
parent | dd4e670f72c44a59b40ffb6af72751606fadd680 (diff) | |
download | serenity-d9e7e13fb23f1d904c439ded253c2be14f82c86b.zip |
KeyboardMapper: Without arguments, load current keymap
Diffstat (limited to 'Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp')
-rw-r--r-- | Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index a8cf0440d1..3c88339b71 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -31,6 +31,7 @@ #include <LibGUI/InputBox.h> #include <LibGUI/MessageBox.h> #include <LibGUI/RadioButton.h> +#include <LibKeyboard/CharacterMap.h> #include <LibKeyboard/CharacterMapFile.h> #include <fcntl.h> #include <stdio.h> @@ -145,9 +146,7 @@ void KeyboardMapperWidget::create_frame() void KeyboardMapperWidget::load_from_file(String file_name) { auto result = Keyboard::CharacterMapFile::load_from_file(file_name); - if (!result.has_value()) { - ASSERT_NOT_REACHED(); - } + ASSERT(result.has_value()); m_file_name = file_name; m_character_map = result.value(); @@ -161,6 +160,23 @@ void KeyboardMapperWidget::load_from_file(String file_name) update_window_title(); } +void KeyboardMapperWidget::load_from_system() +{ + auto result = Keyboard::CharacterMap::fetch_system_map(); + ASSERT(!result.is_error()); + + m_file_name = String::formatted("/res/keymaps/{}.json", result.value().character_map_name()); + m_character_map = result.value().character_map_data(); + set_current_map("map"); + + for (Widget* widget : m_map_group->child_widgets()) { + auto radio_button = (GUI::RadioButton*)widget; + radio_button->set_checked(radio_button->name() == "map"); + } + + update_window_title(); +} + void KeyboardMapperWidget::save() { save_to_file(m_file_name); |