Ladybird/Qt: Implement pasting Web data to the clipboard

This commit is contained in:
Timothy Flynn 2023-11-10 13:44:12 -05:00 committed by Andreas Kling
parent 9421ffd4ec
commit 6732a38cf8
Notes: sideshowbarker 2024-07-17 08:45:34 +09:00

View file

@ -30,6 +30,7 @@
#include <QInputDialog>
#include <QMenu>
#include <QMessageBox>
#include <QMimeData>
#include <QPainter>
#include <QPoint>
#include <QResizeEvent>
@ -289,6 +290,16 @@ Tab::Tab(BrowserWindow* window, StringView webdriver_content_ipc_path, WebView::
m_inspector_widget->set_accessibility_json(accessibility_tree);
};
view().on_insert_clipboard_entry = [](auto const& data, auto const&, auto const& mime_type) {
QByteArray qdata { data.bytes_as_string_view().characters_without_null_termination(), static_cast<qsizetype>(data.bytes_as_string_view().length()) };
auto* mime_data = new QMimeData();
mime_data->setData(qstring_from_ak_string(mime_type), qdata);
auto* clipboard = QGuiApplication::clipboard();
clipboard->setMimeData(mime_data);
};
auto* search_selected_text_action = new QAction("&Search for <query>", this);
search_selected_text_action->setIcon(load_icon_from_uri("resource://icons/16x16/find.png"sv));
QObject::connect(search_selected_text_action, &QAction::triggered, this, [this]() {