1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 01:51:03 +09:00

UI/Qt: Add copy/paste/select actions to the InspectorWidget

This fixes issue where it was impossible to paste text into
inspector console input.
This commit is contained in:
aplefull 2025-01-19 15:19:42 +01:00 committed by Jelle Raaijmakers
parent fd27eef0d1
commit b4ebade9c2
Notes: github-actions[bot] 2025-01-22 16:40:10 +00:00

View file

@ -11,6 +11,7 @@
#include <UI/Qt/StringUtils.h> #include <UI/Qt/StringUtils.h>
#include <QAction> #include <QAction>
#include <QClipboard>
#include <QCloseEvent> #include <QCloseEvent>
#include <QGuiApplication> #include <QGuiApplication>
#include <QMenu> #include <QMenu>
@ -37,6 +38,29 @@ InspectorWidget::InspectorWidget(QWidget* tab, WebContentView& content_view)
addAction(inspector_close_action); addAction(inspector_close_action);
connect(inspector_close_action, &QAction::triggered, [this]() { close(); }); connect(inspector_close_action, &QAction::triggered, [this]() { close(); });
auto* copy_action = new QAction("&Copy", this);
copy_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Copy));
addAction(copy_action);
connect(copy_action, &QAction::triggered, [this]() {
auto text = m_inspector_view->selected_text();
QGuiApplication::clipboard()->setText(qstring_from_ak_string(text));
});
auto* paste_action = new QAction("&Paste", this);
paste_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Paste));
addAction(paste_action);
connect(paste_action, &QAction::triggered, [this]() {
auto* clipboard = QGuiApplication::clipboard();
m_inspector_view->paste(ak_string_from_qstring(clipboard->text()));
});
auto* select_all_action = new QAction("Select &All", this);
select_all_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::SelectAll));
addAction(select_all_action);
connect(select_all_action, &QAction::triggered, [this]() {
m_inspector_view->select_all();
});
m_inspector_client = make<WebView::InspectorClient>(content_view, *m_inspector_view); m_inspector_client = make<WebView::InspectorClient>(content_view, *m_inspector_view);
m_edit_node_action = new QAction("&Edit node", this); m_edit_node_action = new QAction("&Edit node", this);