mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
KeyboardSettings: Migrate to Directory::for_each_entry()
This commit is contained in:
parent
8f3c77a5a3
commit
1b776bffcf
Notes:
sideshowbarker
2024-07-17 09:56:35 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/1b776bffcf Pull-request: https://github.com/SerenityOS/serenity/pull/17694
1 changed files with 11 additions and 12 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue