mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
Browser: Show currently loading host and remaining resource count
This commit is contained in:
parent
fb6c8781a2
commit
7594350376
13 changed files with 85 additions and 8 deletions
|
@ -80,6 +80,29 @@ void Tab::view_source(const URL& url, const String& source)
|
|||
window->show();
|
||||
}
|
||||
|
||||
void Tab::update_status(Optional<String> text_override, i32 count_waiting)
|
||||
{
|
||||
if (text_override.has_value()) {
|
||||
m_statusbar->set_text(*text_override);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_loaded) {
|
||||
m_statusbar->set_text("");
|
||||
return;
|
||||
}
|
||||
|
||||
VERIFY(m_navigating_url.has_value());
|
||||
|
||||
if (count_waiting == 0) {
|
||||
// ex: "Loading google.com"
|
||||
m_statusbar->set_text(String::formatted("Loading {}", m_navigating_url->host()));
|
||||
} else {
|
||||
// ex: "google.com is waiting on 5 resources"
|
||||
m_statusbar->set_text(String::formatted("{} is waiting on {} resource{}", m_navigating_url->host(), count_waiting, count_waiting == 1 ? ""sv : "s"sv));
|
||||
}
|
||||
}
|
||||
|
||||
Tab::Tab(BrowserWindow& window)
|
||||
{
|
||||
load_from_gml(tab_gml);
|
||||
|
@ -165,6 +188,11 @@ Tab::Tab(BrowserWindow& window)
|
|||
this);
|
||||
|
||||
hooks().on_load_start = [this](auto& url) {
|
||||
m_navigating_url = url;
|
||||
m_loaded = false;
|
||||
|
||||
update_status();
|
||||
|
||||
m_location_box->set_icon(nullptr);
|
||||
m_location_box->set_text(url.to_string());
|
||||
|
||||
|
@ -184,6 +212,11 @@ Tab::Tab(BrowserWindow& window)
|
|||
};
|
||||
|
||||
hooks().on_load_finish = [this](auto&) {
|
||||
m_navigating_url = {};
|
||||
m_loaded = true;
|
||||
|
||||
update_status();
|
||||
|
||||
if (m_dom_inspector_widget)
|
||||
m_web_content_view->inspect_dom_tree();
|
||||
};
|
||||
|
@ -196,6 +229,10 @@ Tab::Tab(BrowserWindow& window)
|
|||
}
|
||||
};
|
||||
|
||||
hooks().on_resource_status_change = [this](auto count_waiting) {
|
||||
update_status({}, count_waiting);
|
||||
};
|
||||
|
||||
m_link_context_menu = GUI::Menu::construct();
|
||||
auto link_default_action = GUI::Action::create("&Open", [this](auto&) {
|
||||
hooks().on_link_click(m_link_context_menu_url, "", 0);
|
||||
|
@ -317,9 +354,9 @@ Tab::Tab(BrowserWindow& window)
|
|||
|
||||
hooks().on_link_hover = [this](auto& url) {
|
||||
if (url.is_valid())
|
||||
m_statusbar->set_text(url.to_string());
|
||||
update_status(url.to_string());
|
||||
else
|
||||
m_statusbar->set_text("");
|
||||
update_status();
|
||||
};
|
||||
|
||||
hooks().on_url_drop = [this](auto& url) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue