UI/Qt: Add standard shortcuts for find in page actions

This commit adds the standard shortcuts for the Find Next and Find
Previous buttons on the find in page panel. These shortcuts are usually
F3 and Shift+F3 respectively, although Qt standard shortcuts may vary
across platforms.
This commit is contained in:
Tim Ledbetter
2024-06-13 21:09:49 +01:00
committed by Andreas Kling
parent fdacf8ebeb
commit 88d134a4da
5 changed files with 39 additions and 0 deletions

View File

@@ -157,6 +157,20 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::Cook
m_find_in_page_action->setIcon(load_icon_from_uri("resource://icons/16x16/find.png"sv));
m_find_in_page_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Find));
auto find_previous_shortcuts = QKeySequence::keyBindings(QKeySequence::StandardKey::FindPrevious);
for (auto const& shortcut : find_previous_shortcuts)
new QShortcut(shortcut, this, [this] {
if (m_current_tab)
m_current_tab->find_previous();
});
auto find_next_shortcuts = QKeySequence::keyBindings(QKeySequence::StandardKey::FindNext);
for (auto const& shortcut : find_next_shortcuts)
new QShortcut(shortcut, this, [this] {
if (m_current_tab)
m_current_tab->find_next();
});
edit_menu->addAction(m_find_in_page_action);
QObject::connect(m_find_in_page_action, &QAction::triggered, this, &BrowserWindow::show_find_in_page);