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

LibGUI: Add a ClipboardClient for GUI::Clipboard

Anyone who inherits from `GUI::Clipboard::ClipboardClient` will receive
clipboard notifications via `clipboard_content_did_change()`.

Update ClipboardHistoryModel, TextEditor and TerminalWidget to inherit
from this class.
This commit is contained in:
TheFightingCatfish 2021-07-27 03:19:56 +08:00 committed by Andreas Kling
parent 95f393ebcd
commit 0c53c2dfa2
8 changed files with 106 additions and 72 deletions

View file

@ -49,11 +49,6 @@ int main(int argc, char* argv[])
auto model = ClipboardHistoryModel::create();
table_view.set_model(model);
GUI::Clipboard::the().on_change = [&](const String&) {
auto item = GUI::Clipboard::the().data_and_type();
model->add_item(item);
};
table_view.on_activation = [&](const GUI::ModelIndex& index) {
auto& data_and_type = model->item_at(index.row());
GUI::Clipboard::the().set_data(data_and_type.data, data_and_type.mime_type, data_and_type.metadata);