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

MenuApplets: Added ability to remove entry from ClipboardHistory (#4143)

This commit is contained in:
Florian Förster 2020-11-24 21:37:04 +01:00 committed by GitHub
parent b1fd06eb4c
commit 438829a1d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View file

@ -25,8 +25,10 @@
*/
#include "ClipboardHistoryModel.h"
#include <LibGUI/Action.h>
#include <LibGUI/Application.h>
#include <LibGUI/ImageWidget.h>
#include <LibGUI/Menu.h>
#include <LibGUI/TableView.h>
#include <LibGUI/Window.h>
#include <stdio.h>
@ -73,6 +75,16 @@ int main(int argc, char* argv[])
GUI::Clipboard::the().set_data(data_and_type.data, data_and_type.mime_type, data_and_type.metadata);
};
auto delete_action = GUI::CommonActions::make_delete_action([&](const GUI::Action&) {
model->remove_item(table_view.selection().first().row());
});
auto entry_context_menu = GUI::Menu::construct();
entry_context_menu->add_action(delete_action);
table_view.on_context_menu_request = [&](const GUI::ModelIndex&, const GUI::ContextMenuEvent& event) {
entry_context_menu->popup(event.screen_position());
};
auto applet_window = GUI::Window::construct();
applet_window->set_title("ClipboardHistory");
applet_window->set_window_type(GUI::WindowType::MenuApplet);