mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
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:
parent
e17d4f8736
commit
b88de8a91f
Notes:
sideshowbarker
2024-07-18 20:58:38 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/b88de8a91fe Pull-request: https://github.com/SerenityOS/serenity/pull/6012
@ -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) {
|
||||
|
@ -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 };
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user