1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:57:45 +00:00

FileManager: Add a basic context menu with copy/paste/delete/...

I also added a dummy "Properties..." action just to fill out the menu a
little bit. :^)

Fixes #270.
This commit is contained in:
Andreas Kling 2019-09-13 22:00:47 +02:00
parent f360858836
commit 3a02bd40f8
3 changed files with 34 additions and 2 deletions

View file

@ -178,6 +178,8 @@ int main(int argc, char** argv)
}
});
auto properties_action = GAction::create("Properties...", { Mod_Alt, Key_Return }, [](auto&) {});
auto delete_action = GAction::create("Delete", GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), [](const GAction&) {
dbgprintf("'Delete' action activated!\n");
});
@ -271,6 +273,17 @@ int main(int argc, char** argv)
progressbar->set_visible(true);
};
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(properties_action);
directory_view->on_context_menu_request = [&](const GAbstractView&, const GModelIndex&, const GContextMenuEvent& event) {
context_menu->popup(event.screen_position());
};
// our initial location is defined as, in order of precedence:
// 1. the first command-line argument (e.g. FileManager /bin)
// 2. the user's home directory