diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-03-02 17:46:48 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-05 20:23:42 +0100 |
commit | 1b776bffcf54b693d58389e91dbb93d531870ccf (patch) | |
tree | 5947f8f0d16195149f9390e0b712e9b66e8f9cc7 /Userland | |
parent | 8f3c77a5a3806908c751d979285b25c72de85aad (diff) | |
download | serenity-1b776bffcf54b693d58389e91dbb93d531870ccf.zip |
KeyboardSettings: Migrate to Directory::for_each_entry()
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp index f77cfa546d..842018a569 100644 --- a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp +++ b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, Hüseyin Aslıtürk <asliturk@hotmail.com> - * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org> + * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org> * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause @@ -13,7 +13,7 @@ #include <Applications/KeyboardSettings/KeymapDialogGML.h> #include <LibConfig/Client.h> #include <LibCore/DeprecatedFile.h> -#include <LibCore/DirIterator.h> +#include <LibCore/Directory.h> #include <LibGUI/Application.h> #include <LibGUI/ComboBox.h> #include <LibGUI/Dialog.h> @@ -59,19 +59,18 @@ private: set_icon(parent_window->icon()); - Core::DirIterator iterator("/res/keymaps/", Core::DirIterator::Flags::SkipDots); - if (iterator.has_error()) { - GUI::MessageBox::show(nullptr, DeprecatedString::formatted("Error on reading mapping file list: {}", iterator.error()), "Keyboard settings"sv, GUI::MessageBox::Type::Error); + auto iterator_result = Core::Directory::for_each_entry("/res/keymaps/"sv, Core::DirIterator::Flags::SkipDots, [&](auto const& entry, auto&) -> ErrorOr<IterationDecision> { + auto basename = entry.name.replace(".json"sv, ""sv, ReplaceMode::FirstOnly); + if (selected_keymaps.find(basename).is_end()) + m_character_map_files.append(basename); + return IterationDecision::Continue; + }); + + if (iterator_result.is_error()) { + GUI::MessageBox::show(nullptr, DeprecatedString::formatted("Error on reading mapping file list: {}", iterator_result.error()), "Keyboard settings"sv, GUI::MessageBox::Type::Error); GUI::Application::the()->quit(-1); } - while (iterator.has_next()) { - auto name = iterator.next_path(); - auto basename = name.replace(".json"sv, ""sv, ReplaceMode::FirstOnly); - if (!selected_keymaps.find(basename).is_end()) - continue; - m_character_map_files.append(basename); - } quick_sort(m_character_map_files); m_selected_keymap = m_character_map_files.first(); |