mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:27:34 +00:00
Browser: Add reset zoom level button to toolbar
This button shows the current zoom level and when clicked resets the zoom back to 100%. It is only displayed for zoom levels other than 100%.
This commit is contained in:
parent
64da05a96d
commit
b7f9b316ed
4 changed files with 30 additions and 6 deletions
|
@ -201,6 +201,15 @@ Tab::Tab(BrowserWindow& window)
|
|||
},
|
||||
this);
|
||||
|
||||
m_reset_zoom_button = toolbar.add<GUI::Button>();
|
||||
m_reset_zoom_button->on_click = [&](auto) {
|
||||
view().reset_zoom();
|
||||
update_reset_zoom_button();
|
||||
};
|
||||
m_reset_zoom_button->set_button_style(Gfx::ButtonStyle::Coolbar);
|
||||
m_reset_zoom_button->set_visible(false);
|
||||
m_reset_zoom_button->set_preferred_width(GUI::SpecialDimension::Shrink);
|
||||
|
||||
m_bookmark_button = toolbar.add<GUI::Button>();
|
||||
m_bookmark_button->set_action(bookmark_action);
|
||||
m_bookmark_button->set_button_style(Gfx::ButtonStyle::Coolbar);
|
||||
|
@ -514,6 +523,17 @@ Tab::Tab(BrowserWindow& window)
|
|||
};
|
||||
}
|
||||
|
||||
void Tab::update_reset_zoom_button()
|
||||
{
|
||||
auto zoom_level = view().zoom_level();
|
||||
if (zoom_level != 1.0f) {
|
||||
m_reset_zoom_button->set_text(MUST(String::formatted("{}%", round_to<int>(zoom_level * 100))));
|
||||
m_reset_zoom_button->set_visible(true);
|
||||
} else {
|
||||
m_reset_zoom_button->set_visible(false);
|
||||
}
|
||||
}
|
||||
|
||||
Optional<URL> Tab::url_from_location_bar(MayAppendTLD may_append_tld)
|
||||
{
|
||||
if (m_location_box->text().starts_with('?') && g_search_engine.is_empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue