mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
FileManager: Add layout options to View menu
File Manager's toolbar, location bar, status bar and folder pane can now be toggled on/off
This commit is contained in:
parent
cb42ba0ab1
commit
94e494d6d2
3 changed files with 89 additions and 5 deletions
|
@ -7,3 +7,9 @@ Left=150
|
||||||
Top=75
|
Top=75
|
||||||
Width=640
|
Width=640
|
||||||
Height=480
|
Height=480
|
||||||
|
|
||||||
|
[Layout]
|
||||||
|
ShowToolbar=1
|
||||||
|
ShowStatusBar=1
|
||||||
|
ShowLocationBar=1
|
||||||
|
ShowFolderPane=1
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::ToolBarContainer {
|
@GUI::ToolBarContainer {
|
||||||
|
name: "toolbar_container"
|
||||||
@GUI::ToolBar {
|
@GUI::ToolBar {
|
||||||
name: "main_toolbar"
|
name: "main_toolbar"
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,6 +330,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
|
|
||||||
widget.load_from_gml(file_manager_window_gml);
|
widget.load_from_gml(file_manager_window_gml);
|
||||||
|
|
||||||
|
auto& toolbar_container = *widget.find_descendant_of_type_named<GUI::ToolBarContainer>("toolbar_container");
|
||||||
auto& main_toolbar = *widget.find_descendant_of_type_named<GUI::ToolBar>("main_toolbar");
|
auto& main_toolbar = *widget.find_descendant_of_type_named<GUI::ToolBar>("main_toolbar");
|
||||||
auto& location_toolbar = *widget.find_descendant_of_type_named<GUI::ToolBar>("location_toolbar");
|
auto& location_toolbar = *widget.find_descendant_of_type_named<GUI::ToolBar>("location_toolbar");
|
||||||
location_toolbar.layout()->set_margins({ 6, 3, 6, 3 });
|
location_toolbar.layout()->set_margins({ 6, 3, 6, 3 });
|
||||||
|
@ -340,11 +341,6 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
breadcrumb_toolbar.layout()->set_margins({ 6, 0, 6, 0 });
|
breadcrumb_toolbar.layout()->set_margins({ 6, 0, 6, 0 });
|
||||||
auto& breadcrumb_bar = *widget.find_descendant_of_type_named<GUI::BreadcrumbBar>("breadcrumb_bar");
|
auto& breadcrumb_bar = *widget.find_descendant_of_type_named<GUI::BreadcrumbBar>("breadcrumb_bar");
|
||||||
|
|
||||||
location_textbox.on_focusout = [&] {
|
|
||||||
location_toolbar.set_visible(false);
|
|
||||||
breadcrumb_toolbar.set_visible(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto& splitter = *widget.find_descendant_of_type_named<GUI::HorizontalSplitter>("splitter");
|
auto& splitter = *widget.find_descendant_of_type_named<GUI::HorizontalSplitter>("splitter");
|
||||||
auto& tree_view = *widget.find_descendant_of_type_named<GUI::TreeView>("tree_view");
|
auto& tree_view = *widget.find_descendant_of_type_named<GUI::TreeView>("tree_view");
|
||||||
|
|
||||||
|
@ -415,6 +411,78 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
directory_view.open_parent_directory();
|
directory_view.open_parent_directory();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RefPtr<GUI::Action> layout_toolbar_action;
|
||||||
|
RefPtr<GUI::Action> layout_location_action;
|
||||||
|
RefPtr<GUI::Action> layout_statusbar_action;
|
||||||
|
RefPtr<GUI::Action> 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<GUI::Action> view_as_table_action;
|
RefPtr<GUI::Action> view_as_table_action;
|
||||||
RefPtr<GUI::Action> view_as_icons_action;
|
RefPtr<GUI::Action> view_as_icons_action;
|
||||||
RefPtr<GUI::Action> view_as_columns_action;
|
RefPtr<GUI::Action> view_as_columns_action;
|
||||||
|
@ -632,6 +700,14 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
action_show_dotfiles->set_checked(show_dotfiles);
|
action_show_dotfiles->set_checked(show_dotfiles);
|
||||||
|
|
||||||
auto& view_menu = menubar->add_menu("View");
|
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_icons_action);
|
||||||
view_menu.add_action(*view_as_table_action);
|
view_menu.add_action(*view_as_table_action);
|
||||||
view_menu.add_action(*view_as_columns_action);
|
view_menu.add_action(*view_as_columns_action);
|
||||||
|
@ -639,6 +715,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
||||||
view_menu.add_action(action_show_dotfiles);
|
view_menu.add_action(action_show_dotfiles);
|
||||||
|
|
||||||
auto go_to_location_action = GUI::Action::create("Go to location...", { Mod_Ctrl, Key_L }, [&](auto&) {
|
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);
|
location_toolbar.set_visible(true);
|
||||||
breadcrumb_toolbar.set_visible(false);
|
breadcrumb_toolbar.set_visible(false);
|
||||||
location_textbox.select_all();
|
location_textbox.select_all();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue