LibGUI: Use the global setting to show dotfiles in FilePicker

`FilePicker` will now look at the global setting at startup. Note that
changing this parameter inside `FilePicker` won't affect the global
parameter.
This commit is contained in:
Lucas CHOLLET 2023-03-08 17:09:39 -05:00 committed by Sam Atkins
parent af8b715aac
commit 8faed20603
Notes: sideshowbarker 2024-07-17 05:02:42 +09:00

View file

@ -6,6 +6,7 @@
#include <AK/Function.h>
#include <AK/LexicalPath.h>
#include <LibConfig/Client.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/StandardPaths.h>
#include <LibGUI/Action.h>
@ -207,12 +208,17 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
m_context_menu->add_action(mkdir_action);
m_context_menu->add_separator();
m_context_menu->add_action(GUI::Action::create_checkable(
auto show_dotfiles = GUI::Action::create_checkable(
"Show dotfiles", { Mod_Ctrl, Key_H }, [&](auto& action) {
m_model->set_should_show_dotfiles(action.is_checked());
m_model->invalidate();
},
this));
this);
auto show_dotfiles_preset = Config::read_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, false);
if (show_dotfiles_preset)
show_dotfiles->activate();
m_context_menu->add_action(show_dotfiles);
m_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
if (!index.is_valid()) {