1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:37:43 +00:00

LibGUI: Add keyboard shortcuts to FilePicker

Taken from FileManager.
This commit is contained in:
Karol Kosek 2021-07-22 00:41:24 +02:00 committed by Andreas Kling
parent 0d963fd641
commit 232f0fb2d3

View file

@ -123,7 +123,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen
toolbar.add_separator(); toolbar.add_separator();
auto mkdir_action = Action::create( auto mkdir_action = Action::create(
"New directory...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) { "New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"), [this](const Action&) {
String value; String value;
if (InputBox::show(this, value, "Enter name:", "New directory") == InputBox::ExecOK && !value.is_empty()) { if (InputBox::show(this, value, "Enter name:", "New directory") == InputBox::ExecOK && !value.is_empty()) {
auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_model->root_path(), value)); auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_model->root_path(), value));
@ -171,10 +171,12 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& filen
}; };
m_context_menu = GUI::Menu::construct(); m_context_menu = GUI::Menu::construct();
m_context_menu->add_action(GUI::Action::create_checkable("Show dotfiles", [&](auto& action) { m_context_menu->add_action(GUI::Action::create_checkable(
m_model->set_should_show_dotfiles(action.is_checked()); "Show dotfiles", { Mod_Ctrl, Key_H }, [&](auto& action) {
m_model->update(); m_model->set_should_show_dotfiles(action.is_checked());
})); m_model->update();
},
this));
m_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) { m_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) {
if (!index.is_valid()) { if (!index.is_valid()) {