Ladybird: Update pointer to current tab when the selected tab changes

This allows requests like dumping the DOM tree to be forwarded to the
correct tab. Otherwise, the event would be forwarded to the most
recently created tab.
This commit is contained in:
Timothy Flynn 2022-09-13 12:18:32 -04:00 committed by Andrew Kaster
parent e04db5efed
commit 4850a2d272

View file

@ -10,6 +10,7 @@
#include "Settings.h"
#include "SettingsDialog.h"
#include "WebView.h"
#include <AK/TypeCasts.h>
#include <QAction>
#include <QDialog>
#include <QPlainTextEdit>
@ -190,6 +191,7 @@ BrowserWindow::BrowserWindow()
QObject::connect(m_tabs_container, &QTabWidget::currentChanged, [this](int index) {
setWindowTitle(QString("%1 - Ladybird").arg(m_tabs_container->tabText(index)));
setWindowIcon(m_tabs_container->tabIcon(index));
m_current_tab = verify_cast<Tab>(m_tabs_container->widget(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);