mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +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:
parent
fd27eef0d1
commit
b4ebade9c2
Notes:
github-actions[bot]
2025-01-22 16:40:10 +00:00
Author: https://github.com/aplefull
Commit: b4ebade9c2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3308
Reviewed-by: https://github.com/gmta ✅
1 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue