forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ladybird: Add "Copy" and "Select All" actions to the Edit menu
- Loading branch information
1 parent
b79bc25
commit 9c7e26b
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2022, Andreas Kling <[email protected]> | ||
* Copyright (c) 2022-2023, Andreas Kling <[email protected]> | ||
* Copyright (c) 2022, Matthew Costa <[email protected]> | ||
* Copyright (c) 2022, Filiph Sandström <[email protected]> | ||
* Copyright (c) 2023, Linus Groh <[email protected]> | ||
|
@@ -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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters