diff --git a/Userland/Applications/KeyboardMapper/KeyButton.cpp b/Userland/Applications/KeyboardMapper/KeyButton.cpp index 1700626baa..401118c629 100644 --- a/Userland/Applications/KeyboardMapper/KeyButton.cpp +++ b/Userland/Applications/KeyboardMapper/KeyButton.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Hüseyin Aslıtürk + * Copyright (c) 2021, Rasmus Nylander * * SPDX-License-Identifier: BSD-2-Clause */ diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 14187f3e6e..9b8cdc19d6 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -1,12 +1,13 @@ /* * Copyright (c) 2020, Hüseyin Aslıtürk + * Copyright (c) 2021, Rasmus Nylander * * SPDX-License-Identifier: BSD-2-Clause */ #include "KeyboardMapperWidget.h" #include "KeyPositions.h" -#include +#include #include #include #include @@ -178,11 +179,9 @@ ErrorOr KeyboardMapperWidget::save_to_file(StringView filename) // Write to file. String file_content = map_json.to_string(); - auto file = TRY(Core::File::open(filename, Core::OpenMode::WriteOnly)); - - bool result = file->write(file_content); - if (!result) - return Error::from_errno(file->error()); + auto file = TRY(Core::Stream::File::open(filename, Core::Stream::OpenMode::Write)); + TRY(file.write(file_content.bytes())); + file.close(); m_modified = false; m_filename = filename; @@ -244,6 +243,7 @@ void KeyboardMapperWidget::update_window_title() window()->set_title(sb.to_string()); } -void KeyboardMapperWidget::show_error_to_user(Error error){ +void KeyboardMapperWidget::show_error_to_user(Error error) +{ GUI::MessageBox::show_error(window(), error.string_literal()); -} \ No newline at end of file +} diff --git a/Userland/Applications/KeyboardMapper/main.cpp b/Userland/Applications/KeyboardMapper/main.cpp index 962618fd65..5ec7ccbbdf 100644 --- a/Userland/Applications/KeyboardMapper/main.cpp +++ b/Userland/Applications/KeyboardMapper/main.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Hüseyin Aslıtürk + * Copyright (c) 2021, Rasmus Nylander * * SPDX-License-Identifier: BSD-2-Clause */ @@ -48,7 +49,8 @@ ErrorOr serenity_main(Main::Arguments arguments) auto open_action = GUI::CommonActions::make_open_action( [&](auto&) { Optional path = GUI::FilePicker::get_open_filepath(window, "Open", "/res/keymaps/"); - if (!path.has_value()) return; + if (!path.has_value()) + return; ErrorOr error_or = keyboard_mapper_widget->load_map_from_file(path.value()); if (error_or.is_error())