mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-22 10:59:51 +03:00
Browser: Implement notify_request_open_new_tab
This commit is contained in:
parent
640864b32e
commit
9d79a9b214
Notes:
sideshowbarker
2024-07-17 03:00:02 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/9d79a9b214 Pull-request: https://github.com/SerenityOS/serenity/pull/17855 Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/trflynn89 ✅
@ -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)
|
||||
|
@ -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; }
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user