Truly independent web browser
UI/Qt: Close the current tab with Ctrl+F4 outside macOS
Callum Law5ad3d2e69bdf
diff --git a/Documentation/UI/QuietDesign.md b/Documentation/UI/QuietDesign.mdindex 8755bc15884..38249a91838 100644--- a/Documentation/UI/QuietDesign.md+++ b/Documentation/UI/QuietDesign.md@@ -810,7 +810,7 @@ address field → page. F6 moves between the chrome and the page.| Action | macOS | Windows and Linux ||---|---|---|| New tab | ⌘T | Ctrl+T |-| Close tab | ⌘W | Ctrl+W |+| Close tab | ⌘W | Ctrl+W, Ctrl+F4 || Reopen closed tab | ⇧⌘T | Ctrl+Shift+T || New window | ⌘N | Ctrl+N || New private window | ⇧⌘N | Ctrl+Shift+N |diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cppindex 5207cd3814d..916e7127c50 100644--- a/UI/Qt/Application.cpp+++ b/UI/Qt/Application.cpp@@ -418,7 +418,13 @@ public:update_reopen_recently_closed_action();m_close_current_tab_action = make_action("&Close Current Tab");- m_close_current_tab_action->setShortcuts(QKeySequence::keyBindings(QKeySequence::StandardKey::Close));+ auto close_tab_shortcuts = QKeySequence::keyBindings(QKeySequence::StandardKey::Close);+#if !defined(AK_OS_MACOS)+ QKeySequence control_f4(Qt::CTRL | Qt::Key_F4);+ if (!close_tab_shortcuts.contains(control_f4))+ close_tab_shortcuts.append(control_f4);+#endif+ m_close_current_tab_action->setShortcuts(close_tab_shortcuts);QObject::connect(m_close_current_tab_action, &QAction::triggered, this, []() {auto* tab = Application::the().active_tab();if (!tab)diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cppindex a9989b17a12..a6e7285c314 100644--- a/UI/Qt/WebContentView.cpp+++ b/UI/Qt/WebContentView.cpp@@ -810,6 +810,9 @@ static bool is_browser_reserved_shortcut(QKeyEvent const& event)if (modifiers == (Qt::ControlModifier | Qt::ShiftModifier) && (key == Qt::Key_BracketLeft || key == Qt::Key_BracketRight))return true;+#else+ if (modifiers == Qt::ControlModifier && key == Qt::Key_F4)+ return true;#endifif (modifiers == Qt::ControlModifier && key == Qt::Key_PageUp)