diff options
Diffstat (limited to 'Ladybird/BrowserWindow.cpp')
-rw-r--r-- | Ladybird/BrowserWindow.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Ladybird/BrowserWindow.cpp b/Ladybird/BrowserWindow.cpp index cca366632a..0da3447251 100644 --- a/Ladybird/BrowserWindow.cpp +++ b/Ladybird/BrowserWindow.cpp @@ -30,6 +30,10 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop) new_tab_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_T)); menu->addAction(new_tab_action); + auto* close_current_tab_action = new QAction("Close Current Tab"); + close_current_tab_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_W)); + menu->addAction(close_current_tab_action); + auto* quit_action = new QAction("&Quit"); quit_action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); menu->addAction(quit_action); @@ -165,6 +169,7 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop) setWindowIcon(m_tabs_container->tabIcon(index)); }); QObject::connect(m_tabs_container, &QTabWidget::tabCloseRequested, this, &BrowserWindow::close_tab); + QObject::connect(close_current_tab_action, &QAction::triggered, this, &BrowserWindow::close_current_tab); new_tab(); @@ -210,6 +215,15 @@ void BrowserWindow::close_tab(int index) m_tabs_bar->hide(); } +void BrowserWindow::close_current_tab() +{ + auto count = m_tabs_container->count() - 1; + if (!count) + close(); + else + close_tab(m_tabs_container->currentIndex()); +} + int BrowserWindow::tab_index(Tab* tab) { return m_tabs_container->indexOf(tab); |