summaryrefslogtreecommitdiff
path: root/Userland/Applications/FileManager
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-08-17 17:55:01 -0400
committerAndreas Kling <kling@serenityos.org>2022-08-18 15:58:41 +0200
commit299cebbbcb2dd8c87737ca7ebfdb29941a72fb9a (patch)
tree9ca9a73e06f5cc5b6341dfdea4e2760c6afe90d7 /Userland/Applications/FileManager
parentd26203ff90cec02f2a46576fc106f0879f8a6b97 (diff)
downloadserenity-299cebbbcb2dd8c87737ca7ebfdb29941a72fb9a.zip
FileManager: Do not activate "Show Dotfiles" action on every startup
Commit 75d1840cf detects if the initial path provided to the FileManager contains a dotfile, and if so, forces the FileManager to show dotfiles. However, it does this by activating the "Show Dotfiles" action. This has the side effect of always setting and persisting the configuration, overriding whatever the user's preference was. Instead, only transiently update the view to show dotfiles if the path contains a dotfile.
Diffstat (limited to 'Userland/Applications/FileManager')
-rw-r--r--Userland/Applications/FileManager/main.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp
index 9475b0108c..617d91c36d 100644
--- a/Userland/Applications/FileManager/main.cpp
+++ b/Userland/Applications/FileManager/main.cpp
@@ -986,20 +986,21 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
TRY(edit_menu->try_add_separator());
TRY(edit_menu->try_add_action(select_all_action));
+ auto show_dotfiles_in_view = [&](bool show_dotfiles) {
+ directory_view->set_should_show_dotfiles(show_dotfiles);
+ directories_model->set_should_show_dotfiles(show_dotfiles);
+ };
+
auto show_dotfiles_action = GUI::Action::create_checkable("&Show Dotfiles", { Mod_Ctrl, Key_H }, [&](auto& action) {
- directory_view->set_should_show_dotfiles(action.is_checked());
- directories_model->set_should_show_dotfiles(action.is_checked());
+ show_dotfiles_in_view(action.is_checked());
refresh_tree_view();
Config::write_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, action.is_checked());
});
auto show_dotfiles = Config::read_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, false);
- directory_view->set_should_show_dotfiles(show_dotfiles);
+ show_dotfiles |= initial_location.contains("/."sv);
show_dotfiles_action->set_checked(show_dotfiles);
-
- auto const initial_location_contains_dotfile = initial_location.contains("/."sv);
- show_dotfiles_action->set_checked(initial_location_contains_dotfile);
- show_dotfiles_action->on_activation(show_dotfiles_action);
+ show_dotfiles_in_view(show_dotfiles);
auto view_menu = TRY(window->try_add_menu("&View"));
auto layout_menu = TRY(view_menu->try_add_submenu("&Layout"));