diff options
author | Tommy Nguyen <remyabel@gmail.com> | 2019-12-08 00:39:45 -0500 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-08 14:07:06 +0100 |
commit | 875ab0cf107894cf7311ea6d779cdae980e88627 (patch) | |
tree | 35cfc1ce03152171eb4924ffab5254eebbf232d9 /Applications | |
parent | 5e6368948ec448dae90be5ef96bc0b79d8b55305 (diff) | |
download | serenity-875ab0cf107894cf7311ea6d779cdae980e88627.zip |
FileManager: Add separate context menus for entries
Ref: #826
Right-clicking a directory no longer has the "Open in TextEditor" entry.
Right-clicking the directory view now allows you to create a new directory.
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/FileManager/main.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index d4380cf5c2..ff84f6a7be 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -412,17 +412,37 @@ int main(int argc, char** argv) } }); - auto context_menu = make<GMenu>(); - context_menu->add_action(copy_action); - context_menu->add_action(paste_action); - context_menu->add_action(delete_action); - context_menu->add_separator(); - context_menu->add_action(open_in_text_editor_action); - context_menu->add_separator(); - context_menu->add_action(properties_action); - - directory_view->on_context_menu_request = [&](const GAbstractView&, const GModelIndex&, const GContextMenuEvent& event) { - context_menu->popup(event.screen_position()); + auto directory_context_menu = make<GMenu>(); + directory_context_menu->add_action(copy_action); + directory_context_menu->add_action(paste_action); + directory_context_menu->add_action(delete_action); + directory_context_menu->add_separator(); + directory_context_menu->add_action(properties_action); + + auto file_context_menu = make<GMenu>(); + file_context_menu->add_action(copy_action); + file_context_menu->add_action(paste_action); + file_context_menu->add_action(delete_action); + file_context_menu->add_separator(); + file_context_menu->add_action(open_in_text_editor_action); + file_context_menu->add_separator(); + file_context_menu->add_action(properties_action); + + auto directory_view_context_menu = make<GMenu>(); + directory_view_context_menu->add_action(mkdir_action); + + directory_view->on_context_menu_request = [&](const GAbstractView&, const GModelIndex& index, const GContextMenuEvent& event) { + if (index.is_valid()) { + auto& entry = directory_view->model().entry(index.row()); + + if (entry.is_directory()) { + directory_context_menu->popup(event.screen_position()); + } else { + file_context_menu->popup(event.screen_position()); + } + } else { + directory_view_context_menu->popup(event.screen_position()); + } }; // our initial location is defined as, in order of precedence: |