mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
Browser: Implement notify_request_open_new_tab
This commit is contained in:
parent
640864b32e
commit
9d79a9b214
3 changed files with 9 additions and 2 deletions
|
@ -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));
|
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);
|
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)
|
if (activate)
|
||||||
m_tab_widget->set_active_widget(&new_tab);
|
m_tab_widget->set_active_widget(&new_tab);
|
||||||
|
|
||||||
|
return new_tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::create_new_window(URL url)
|
void BrowserWindow::create_new_window(URL url)
|
||||||
|
|
|
@ -28,7 +28,7 @@ public:
|
||||||
|
|
||||||
GUI::TabWidget& tab_widget();
|
GUI::TabWidget& tab_widget();
|
||||||
Tab& active_tab();
|
Tab& active_tab();
|
||||||
void create_new_tab(URL, bool activate);
|
Tab& create_new_tab(URL, bool activate);
|
||||||
void create_new_window(URL);
|
void create_new_window(URL);
|
||||||
|
|
||||||
GUI::Action& go_back_action() { return *m_go_back_action; }
|
GUI::Action& go_back_action() { return *m_go_back_action; }
|
||||||
|
|
|
@ -468,6 +468,11 @@ Tab::Tab(BrowserWindow& window)
|
||||||
go_forward();
|
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] {
|
view().on_close = [this] {
|
||||||
on_tab_close_request(*this);
|
on_tab_close_request(*this);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue