From 50b3672f5245a35a8cb1a73a256c64f203de3ca6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 7 Jul 2022 02:56:09 +0200 Subject: [PATCH] Ladybird: Add keyboard shortcut for focusing the location edit (Ctrl+L) --- Ladybird/Tab.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Ladybird/Tab.cpp b/Ladybird/Tab.cpp index 75f823894c..f82bc36216 100644 --- a/Ladybird/Tab.cpp +++ b/Ladybird/Tab.cpp @@ -23,6 +23,10 @@ Tab::Tab(QMainWindow* window) m_toolbar = new QToolBar; m_location_edit = new QLineEdit; + auto* focus_location_edit_action = new QAction("Edit Location"); + focus_location_edit_action->setShortcut(QKeySequence("Ctrl+L")); + addAction(focus_location_edit_action); + m_layout->addWidget(m_toolbar); m_layout->addWidget(m_view); @@ -59,6 +63,8 @@ Tab::Tab(QMainWindow* window) QObject::connect(m_forward_action, &QAction::triggered, this, &Tab::forward); QObject::connect(m_home_action, &QAction::triggered, this, &Tab::home); QObject::connect(m_reload_action, &QAction::triggered, this, &Tab::reload); + QObject::connect(focus_location_edit_action, &QAction::triggered, m_location_edit, qOverload<>(&QWidget::setFocus)); + QObject::connect(focus_location_edit_action, &QAction::triggered, m_location_edit, &QLineEdit::selectAll); } void Tab::navigate(QString const& url)