mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 14:57:34 +00:00
Ladybird: Add "Copy" and "Select All" actions to the Edit menu
This commit is contained in:
parent
b79bc25a1f
commit
9c7e26b8d4
4 changed files with 45 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Matthew Costa <ucosty@gmail.com>
|
||||
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
|
||||
* Copyright (c) 2023, Linus Groh <linusg@serenityos.org>
|
||||
|
@ -18,6 +18,8 @@
|
|||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QClipboard>
|
||||
#include <QGuiApplication>
|
||||
#include <QInputDialog>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
|
@ -53,6 +55,18 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive
|
|||
quit_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q));
|
||||
menu->addAction(quit_action);
|
||||
|
||||
auto* edit_menu = menuBar()->addMenu("&Edit");
|
||||
|
||||
auto* copy_action = new QAction("&Copy", this);
|
||||
copy_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Copy));
|
||||
edit_menu->addAction(copy_action);
|
||||
QObject::connect(copy_action, &QAction::triggered, this, &BrowserWindow::copy_selected_text);
|
||||
|
||||
auto* select_all_action = new QAction("Select &All", this);
|
||||
select_all_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::SelectAll));
|
||||
edit_menu->addAction(select_all_action);
|
||||
QObject::connect(select_all_action, &QAction::triggered, this, &BrowserWindow::select_all);
|
||||
|
||||
auto* view_menu = menuBar()->addMenu("&View");
|
||||
|
||||
auto* open_next_tab_action = new QAction("Open &Next Tab", this);
|
||||
|
@ -455,3 +469,18 @@ void BrowserWindow::reset_zoom()
|
|||
if (m_current_tab)
|
||||
m_current_tab->view().reset_zoom();
|
||||
}
|
||||
|
||||
void BrowserWindow::select_all()
|
||||
{
|
||||
if (auto* tab = m_current_tab)
|
||||
tab->view().select_all();
|
||||
}
|
||||
|
||||
void BrowserWindow::copy_selected_text()
|
||||
{
|
||||
if (auto* tab = m_current_tab) {
|
||||
auto text = tab->view().selected_text();
|
||||
auto* clipboard = QGuiApplication::clipboard();
|
||||
clipboard->setText(qstring_from_ak_deprecated_string(text));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue