summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/Browser/BrowserWindow.cpp11
-rw-r--r--Userland/Applications/Browser/BrowserWindow.h2
-rw-r--r--Userland/Applications/Browser/Tab.cpp20
-rw-r--r--Userland/Applications/Browser/Tab.h3
4 files changed, 30 insertions, 6 deletions
diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp
index 65a37e1b48..65f4335549 100644
--- a/Userland/Applications/Browser/BrowserWindow.cpp
+++ b/Userland/Applications/Browser/BrowserWindow.cpp
@@ -84,7 +84,7 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
auto& tab = static_cast<Browser::Tab&>(active_widget);
set_window_title_for_tab(tab);
tab.did_become_active();
- update_zoom_menu_text();
+ update_displayed_zoom_level();
};
m_tab_widget->on_middle_click = [](auto& clicked_widget) {
@@ -178,21 +178,21 @@ void BrowserWindow::build_menus()
[this](auto&) {
auto& tab = active_tab();
tab.view().zoom_in();
- update_zoom_menu_text();
+ update_displayed_zoom_level();
},
this));
m_zoom_menu->add_action(GUI::CommonActions::make_zoom_out_action(
[this](auto&) {
auto& tab = active_tab();
tab.view().zoom_out();
- update_zoom_menu_text();
+ update_displayed_zoom_level();
},
this));
m_zoom_menu->add_action(GUI::CommonActions::make_reset_zoom_action(
[this](auto&) {
auto& tab = active_tab();
tab.view().reset_zoom();
- update_zoom_menu_text();
+ update_displayed_zoom_level();
},
this));
view_menu.add_separator();
@@ -796,11 +796,12 @@ ErrorOr<void> BrowserWindow::take_screenshot(ScreenshotType type)
return {};
}
-void BrowserWindow::update_zoom_menu_text()
+void BrowserWindow::update_displayed_zoom_level()
{
VERIFY(m_zoom_menu);
auto zoom_level_text = DeprecatedString::formatted("&Zoom ({}%)", round_to<int>(active_tab().view().zoom_level() * 100));
m_zoom_menu->set_name(zoom_level_text);
+ active_tab().update_reset_zoom_button();
}
}
diff --git a/Userland/Applications/Browser/BrowserWindow.h b/Userland/Applications/Browser/BrowserWindow.h
index 2e46a6075d..df7c9026dd 100644
--- a/Userland/Applications/Browser/BrowserWindow.h
+++ b/Userland/Applications/Browser/BrowserWindow.h
@@ -62,7 +62,7 @@ private:
virtual void event(Core::Event&) override;
- void update_zoom_menu_text();
+ void update_displayed_zoom_level();
enum class ScreenshotType {
Visible,
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index 40759fea08..e412d80639 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -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()) {
diff --git a/Userland/Applications/Browser/Tab.h b/Userland/Applications/Browser/Tab.h
index bb7f13ed32..ac5db49646 100644
--- a/Userland/Applications/Browser/Tab.h
+++ b/Userland/Applications/Browser/Tab.h
@@ -90,6 +90,8 @@ public:
void show_storage_inspector();
void show_history_inspector();
+ void update_reset_zoom_button();
+
DeprecatedString const& title() const { return m_title; }
Gfx::Bitmap const* icon() const { return m_icon; }
@@ -124,6 +126,7 @@ private:
RefPtr<WebView::OutOfProcessWebView> m_web_content_view;
RefPtr<GUI::UrlBox> m_location_box;
+ RefPtr<GUI::Button> m_reset_zoom_button;
RefPtr<GUI::Button> m_bookmark_button;
RefPtr<InspectorWidget> m_dom_inspector_widget;
RefPtr<ConsoleWidget> m_console_widget;