mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +00:00
ClipboardHistory: Add a Clear history action
This clears the history from the table view and clears the clipboard.
This commit is contained in:
parent
944c43a8b4
commit
68fa8525bf
3 changed files with 15 additions and 0 deletions
|
@ -67,12 +67,20 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
});
|
||||
});
|
||||
|
||||
auto clear_action = GUI::Action::create("Clear history", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/trash-can.png"sv)), [&](const GUI::Action&) {
|
||||
model->clear();
|
||||
GUI::Clipboard::the().clear();
|
||||
});
|
||||
|
||||
auto entry_context_menu = TRY(GUI::Menu::try_create());
|
||||
TRY(entry_context_menu->try_add_action(delete_action));
|
||||
TRY(entry_context_menu->try_add_action(debug_dump_action));
|
||||
entry_context_menu->add_separator();
|
||||
TRY(entry_context_menu->try_add_action(clear_action));
|
||||
table_view->on_context_menu_request = [&](GUI::ModelIndex const&, GUI::ContextMenuEvent const& event) {
|
||||
delete_action->set_enabled(!table_view->selection().is_empty());
|
||||
debug_dump_action->set_enabled(!table_view->selection().is_empty());
|
||||
clear_action->set_enabled(!model->is_empty());
|
||||
entry_context_menu->popup(event.screen_position());
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue