LibGUI: Add transient option to show dotfiles in FilePicker

This is particularly useful when wanting to open files in ~/.config
from the Text Editor. The option is currently not persistent, but could
be hooked into File Manager's configuration.
This commit is contained in:
Timothy Flynn 2021-03-29 13:26:28 -04:00 committed by Andreas Kling
parent e17d4f8736
commit b88de8a91f
Notes: sideshowbarker 2024-07-18 20:58:38 +09:00
2 changed files with 14 additions and 0 deletions

View File

@ -36,6 +36,7 @@
#include <LibGUI/FilePickerDialogGML.h>
#include <LibGUI/FileSystemModel.h>
#include <LibGUI/InputBox.h>
#include <LibGUI/Menu.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/MultiView.h>
#include <LibGUI/SortingProxyModel.h>
@ -184,6 +185,18 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& file_
m_filename_textbox->set_text(node.name);
};
m_context_menu = GUI::Menu::construct();
m_context_menu->add_action(GUI::Action::create_checkable("Show dotfiles", [&](auto& action) {
m_model->set_should_show_dotfiles(action.is_checked());
m_model->update();
}));
m_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
if (!index.is_valid()) {
m_context_menu->popup(event.screen_position());
}
};
auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button");
ok_button.set_text(ok_button_name(m_mode));
ok_button.on_click = [this](auto) {

View File

@ -83,6 +83,7 @@ private:
RefPtr<TextBox> m_filename_textbox;
RefPtr<TextBox> m_location_textbox;
RefPtr<Menu> m_context_menu;
Mode m_mode { Mode::Open };
};