mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00:00
KeyboardSettings: Migrate to Directory::for_each_entry()
This commit is contained in:
parent
8f3c77a5a3
commit
1b776bffcf
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) 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.
|
* Copyright (c) 2022, the SerenityOS developers.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
#include <Applications/KeyboardSettings/KeymapDialogGML.h>
|
#include <Applications/KeyboardSettings/KeymapDialogGML.h>
|
||||||
#include <LibConfig/Client.h>
|
#include <LibConfig/Client.h>
|
||||||
#include <LibCore/DeprecatedFile.h>
|
#include <LibCore/DeprecatedFile.h>
|
||||||
#include <LibCore/DirIterator.h>
|
#include <LibCore/Directory.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
#include <LibGUI/ComboBox.h>
|
#include <LibGUI/ComboBox.h>
|
||||||
#include <LibGUI/Dialog.h>
|
#include <LibGUI/Dialog.h>
|
||||||
|
@ -59,19 +59,18 @@ private:
|
||||||
|
|
||||||
set_icon(parent_window->icon());
|
set_icon(parent_window->icon());
|
||||||
|
|
||||||
Core::DirIterator iterator("/res/keymaps/", Core::DirIterator::Flags::SkipDots);
|
auto iterator_result = Core::Directory::for_each_entry("/res/keymaps/"sv, Core::DirIterator::Flags::SkipDots, [&](auto const& entry, auto&) -> ErrorOr<IterationDecision> {
|
||||||
if (iterator.has_error()) {
|
auto basename = entry.name.replace(".json"sv, ""sv, ReplaceMode::FirstOnly);
|
||||||
GUI::MessageBox::show(nullptr, DeprecatedString::formatted("Error on reading mapping file list: {}", iterator.error()), "Keyboard settings"sv, GUI::MessageBox::Type::Error);
|
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);
|
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);
|
quick_sort(m_character_map_files);
|
||||||
|
|
||||||
m_selected_keymap = m_character_map_files.first();
|
m_selected_keymap = m_character_map_files.first();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue