mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 11:09:05 +03:00
MenuApplets: Added ability to remove entry from ClipboardHistory (#4143)
This commit is contained in:
parent
b1fd06eb4c
commit
438829a1d5
Notes:
sideshowbarker
2024-07-19 01:16:40 +09:00
Author: https://github.com/florianjr 🔰 Commit: https://github.com/SerenityOS/serenity/commit/438829a1d5c Pull-request: https://github.com/SerenityOS/serenity/pull/4143 Issue: https://github.com/SerenityOS/serenity/issues/4119 Reviewed-by: https://github.com/linusg
@ -99,3 +99,8 @@ void ClipboardHistoryModel::add_item(const GUI::Clipboard::DataAndType& item)
|
||||
m_history_items.prepend(item);
|
||||
update();
|
||||
}
|
||||
|
||||
void ClipboardHistoryModel::remove_item(int index)
|
||||
{
|
||||
m_history_items.remove(index);
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
|
||||
const GUI::Clipboard::DataAndType& item_at(int index) const { return m_history_items[index]; }
|
||||
void add_item(const GUI::Clipboard::DataAndType& item);
|
||||
void remove_item(int index);
|
||||
|
||||
private:
|
||||
virtual int row_count(const GUI::ModelIndex&) const override { return m_history_items.size(); }
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user