diff --git a/Base/home/anon/.config/FileManager.ini b/Base/home/anon/.config/FileManager.ini index bd5a932272..d0853b1890 100644 --- a/Base/home/anon/.config/FileManager.ini +++ b/Base/home/anon/.config/FileManager.ini @@ -7,3 +7,9 @@ Left=150 Top=75 Width=640 Height=480 + +[Layout] +ShowToolbar=1 +ShowStatusBar=1 +ShowLocationBar=1 +ShowFolderPane=1 diff --git a/Userland/Applications/FileManager/FileManagerWindow.gml b/Userland/Applications/FileManager/FileManagerWindow.gml index d607b39457..9568fabc3f 100644 --- a/Userland/Applications/FileManager/FileManagerWindow.gml +++ b/Userland/Applications/FileManager/FileManagerWindow.gml @@ -5,6 +5,7 @@ } @GUI::ToolBarContainer { + name: "toolbar_container" @GUI::ToolBar { name: "main_toolbar" } diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index 05af081853..e491136d4d 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -330,6 +330,7 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio widget.load_from_gml(file_manager_window_gml); + auto& toolbar_container = *widget.find_descendant_of_type_named("toolbar_container"); auto& main_toolbar = *widget.find_descendant_of_type_named("main_toolbar"); auto& location_toolbar = *widget.find_descendant_of_type_named("location_toolbar"); location_toolbar.layout()->set_margins({ 6, 3, 6, 3 }); @@ -340,11 +341,6 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio breadcrumb_toolbar.layout()->set_margins({ 6, 0, 6, 0 }); auto& breadcrumb_bar = *widget.find_descendant_of_type_named("breadcrumb_bar"); - location_textbox.on_focusout = [&] { - location_toolbar.set_visible(false); - breadcrumb_toolbar.set_visible(true); - }; - auto& splitter = *widget.find_descendant_of_type_named("splitter"); auto& tree_view = *widget.find_descendant_of_type_named("tree_view"); @@ -415,6 +411,78 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio directory_view.open_parent_directory(); }); + RefPtr layout_toolbar_action; + RefPtr layout_location_action; + RefPtr layout_statusbar_action; + RefPtr layout_folderpane_action; + + auto show_toolbar = config->read_bool_entry("Layout", "ShowToolbar", true); + layout_toolbar_action = GUI::Action::create_checkable("Toolbar", [&](auto& action) { + if (action.is_checked()) { + main_toolbar.set_visible(true); + toolbar_container.set_visible(true); + } else { + main_toolbar.set_visible(false); + if (!location_toolbar.is_visible() && !breadcrumb_toolbar.is_visible()) + toolbar_container.set_visible(false); + } + show_toolbar = action.is_checked(); + config->write_bool_entry("Layout", "ShowToolbar", action.is_checked()); + config->sync(); + }); + layout_toolbar_action->set_checked(show_toolbar); + main_toolbar.set_visible(show_toolbar); + + auto show_location = config->read_bool_entry("Layout", "ShowLocationBar", true); + layout_location_action = GUI::Action::create_checkable("Location bar", [&](auto& action) { + if (action.is_checked()) { + breadcrumb_toolbar.set_visible(true); + location_toolbar.set_visible(false); + toolbar_container.set_visible(true); + } else { + breadcrumb_toolbar.set_visible(false); + location_toolbar.set_visible(false); + if (!main_toolbar.is_visible()) + toolbar_container.set_visible(false); + } + show_location = action.is_checked(); + config->write_bool_entry("Layout", "ShowLocationBar", action.is_checked()); + config->sync(); + }); + layout_location_action->set_checked(show_location); + breadcrumb_toolbar.set_visible(show_location); + + toolbar_container.set_visible(show_location | show_toolbar); + + layout_statusbar_action = GUI::Action::create_checkable("Status bar", [&](auto& action) { + action.is_checked() ? statusbar.set_visible(true) : statusbar.set_visible(false); + config->write_bool_entry("Layout", "ShowStatusBar", action.is_checked()); + config->sync(); + }); + + auto show_statusbar = config->read_bool_entry("Layout", "ShowStatusBar", true); + layout_statusbar_action->set_checked(show_statusbar); + statusbar.set_visible(show_statusbar); + + layout_folderpane_action = GUI::Action::create_checkable("Folder pane", { Mod_Ctrl, Key_P }, [&](auto& action) { + action.is_checked() ? tree_view.set_visible(true) : tree_view.set_visible(false); + config->write_bool_entry("Layout", "ShowFolderPane", action.is_checked()); + config->sync(); + }); + + auto show_folderpane = config->read_bool_entry("Layout", "ShowFolderPane", true); + layout_folderpane_action->set_checked(show_folderpane); + tree_view.set_visible(show_folderpane); + + location_textbox.on_focusout = [&] { + if (show_location) + breadcrumb_toolbar.set_visible(true); + if (!(show_location | show_toolbar)) + toolbar_container.set_visible(false); + + location_toolbar.set_visible(false); + }; + RefPtr view_as_table_action; RefPtr view_as_icons_action; RefPtr view_as_columns_action; @@ -632,6 +700,14 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio action_show_dotfiles->set_checked(show_dotfiles); auto& view_menu = menubar->add_menu("View"); + auto& layout_menu = view_menu.add_submenu("Layout"); + layout_menu.add_action(*layout_toolbar_action); + layout_menu.add_action(*layout_location_action); + layout_menu.add_action(*layout_statusbar_action); + layout_menu.add_action(*layout_folderpane_action); + + view_menu.add_separator(); + view_menu.add_action(*view_as_icons_action); view_menu.add_action(*view_as_table_action); view_menu.add_action(*view_as_columns_action); @@ -639,6 +715,7 @@ int run_in_windowed_mode(RefPtr config, String initial_locatio view_menu.add_action(action_show_dotfiles); auto go_to_location_action = GUI::Action::create("Go to location...", { Mod_Ctrl, Key_L }, [&](auto&) { + toolbar_container.set_visible(true); location_toolbar.set_visible(true); breadcrumb_toolbar.set_visible(false); location_textbox.select_all();