Browser: Implement notify_request_open_new_tab

This commit is contained in:
Aliaksandr Kalenik 2023-03-15 15:48:16 +03:00 committed by Tim Flynn
parent 640864b32e
commit 9d79a9b214
Notes: sideshowbarker 2024-07-17 03:00:02 +09:00
3 changed files with 9 additions and 2 deletions

View File

@ -565,7 +565,7 @@ void BrowserWindow::set_window_title_for_tab(Tab const& tab)
set_title(DeprecatedString::formatted("{} - Browser", title.is_empty() ? url.to_deprecated_string() : title));
}
void BrowserWindow::create_new_tab(URL url, bool activate)
Tab& BrowserWindow::create_new_tab(URL url, bool activate)
{
auto& new_tab = m_tab_widget->add_tab<Browser::Tab>("New tab"_short_string, *this);
@ -652,6 +652,8 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
if (activate)
m_tab_widget->set_active_widget(&new_tab);
return new_tab;
}
void BrowserWindow::create_new_window(URL url)

View File

@ -28,7 +28,7 @@ public:
GUI::TabWidget& tab_widget();
Tab& active_tab();
void create_new_tab(URL, bool activate);
Tab& create_new_tab(URL, bool activate);
void create_new_window(URL);
GUI::Action& go_back_action() { return *m_go_back_action; }

View File

@ -468,6 +468,11 @@ Tab::Tab(BrowserWindow& window)
go_forward();
};
view().on_new_tab = [this] {
auto& tab = this->window().create_new_tab(URL("about:blank"), true);
return tab.view().handle();
};
view().on_close = [this] {
on_tab_close_request(*this);
};