Skip to content

Commit

Permalink
UI/Qt: Add copy/paste/select actions to the InspectorWidget
Browse files Browse the repository at this point in the history
This fixes issue where it was impossible to paste text into
inspector console input.
  • Loading branch information
aplefull committed Jan 19, 2025
1 parent add8bf4 commit 27fee0c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions UI/Qt/InspectorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <UI/Qt/StringUtils.h>

#include <QAction>
#include <QClipboard>
#include <QCloseEvent>
#include <QGuiApplication>
#include <QMenu>
Expand All @@ -37,6 +38,29 @@ InspectorWidget::InspectorWidget(QWidget* tab, WebContentView& content_view)
addAction(inspector_close_action);
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_edit_node_action = new QAction("&Edit node", this);
Expand Down

0 comments on commit 27fee0c

Please sign in to comment.