Skip to content

feat(browser): persist zoom level across restarts#1930

Open
xevrion wants to merge 1 commit into
zealdocs:mainfrom
xevrion:feat/persist-zoom-level
Open

feat(browser): persist zoom level across restarts#1930
xevrion wants to merge 1 commit into
zealdocs:mainfrom
xevrion:feat/persist-zoom-level

Conversation

@xevrion

@xevrion xevrion commented Jul 18, 2026

Copy link
Copy Markdown

The document browser always starts at the default zoom level, so a preferred zoom has to be set again after every launch.

The current level is now stored in the content settings group and applied when a WebView is created. It is kept as an index into WebView::availableZoomLevels(), with a negative value meaning unset so that Core does not need to know about the zoom level table owned by Browser.

Saving is debounced by one second, since zooming can be triggered repeatedly via the mouse wheel and Settings::save() rewrites the whole configuration file.

Fixes #1335.

Summary by CodeRabbit

  • New Features

    • Added a configurable Default zoom level option in the Settings dialog.
    • The selected default zoom is saved and restored on startup.
  • Improvements

    • New web views now start with the saved default zoom, and the zoom updates automatically when settings change.
    • Zoom reset now also returns to the configured default zoom (falling back safely when needed).

@xevrion
xevrion requested a review from trollixx as a code owner July 18, 2026 06:58
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4df21b4e-ec07-4545-b07e-3fc2acb66c95

📥 Commits

Reviewing files that changed from the base of the PR and between 20aef60 and 1184150.

📒 Files selected for processing (6)
  • src/libs/browser/webview.cpp
  • src/libs/browser/webview.h
  • src/libs/core/settings.cpp
  • src/libs/core/settings.h
  • src/libs/ui/settingsdialog.cpp
  • src/libs/ui/settingsdialog.ui

Walkthrough

Changes

The settings system persists a default zoom factor, the settings dialog edits it using available WebView zoom levels, and WebView applies it during construction, settings updates, and zoom resets.

Default zoom configuration

Layer / File(s) Summary
Default zoom setting storage
src/libs/core/settings.h, src/libs/core/settings.cpp
Adds defaultZoomFactor and loads or saves it using the default_zoom_factor key.
Default zoom settings control
src/libs/ui/settingsdialog.ui, src/libs/ui/settingsdialog.cpp
Adds a zoom combo box populated from WebView zoom factors and synchronizes it with application settings.
WebView default zoom application
src/libs/browser/webview.h, src/libs/browser/webview.cpp
Maps the configured factor to an available zoom level, applies a fallback, and reapplies the setting when settings change.

Suggested reviewers: trollixx

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the zoom persistence feature.
Linked Issues check ✅ Passed The changes persist the browser's zoom preference in settings and reapply it on startup, matching #1335.
Out of Scope Changes check ✅ Passed The added settings UI and persistence logic are directly related to the zoom-level persistence feature.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/libs/browser/webview.cpp`:
- Around line 75-77: Update setZoomLevel so it compares level with
settings()->defaultZoomLevel before assigning the setting or starting
m_zoomPersistTimer; only perform both operations when the value actually
changes.

In `@src/libs/browser/webview.h`:
- Around line 48-49: Initialize WebView’s m_zoomLevel to -1 instead of 0 so the
first setZoomLevel call cannot return early and always applies the saved zoom
setting, including level 0; leave m_zoomPersistTimer unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 84440774-4690-438b-a25a-2f5b32984bf6

📥 Commits

Reviewing files that changed from the base of the PR and between 19cad78 and 4b8afaa.

📒 Files selected for processing (4)
  • src/libs/browser/webview.cpp
  • src/libs/browser/webview.h
  • src/libs/core/settings.cpp
  • src/libs/core/settings.h

Comment thread src/libs/browser/webview.cpp Outdated
Comment thread src/libs/browser/webview.h Outdated
@trollixx

Copy link
Copy Markdown
Member

Thanks for the contribution! I think the feature is useful, but constantly saving zoom on every change would likely annoy many users, who only wanted to zoom in once and never needed it to persist. A better approach would be to add a "default zoom level" setting like most browsers already do.

@xevrion

xevrion commented Jul 18, 2026

Copy link
Copy Markdown
Author

thanks for the feedback, I'll push an update when I implement it.

@xevrion
xevrion force-pushed the feat/persist-zoom-level branch from c8d1f5d to 20aef60 Compare July 18, 2026 13:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/libs/browser/webview.cpp`:
- Around line 36-38: Remove the Settings::updated connection that invokes
applyDefaultZoomLevel() in the webview initialization, so unrelated settings
saves do not reset existing tabs’ custom zoom levels; retain default zoom
application for newly created tabs through the existing creation path.
- Around line 53-59: Update WebView::resetZoom() to call applyDefaultZoomLevel()
instead of directly setting defaultZoomLevel(), ensuring user-initiated resets
honor the configured defaultZoomFactor while preserving the existing reset
behavior.

In `@src/libs/ui/settingsdialog.cpp`:
- Line 197: Update the default zoom initialization around defaultZoomComboBox
and availableZoomLevels to handle findData returning -1 for missing or invalid
settings->defaultZoomFactor. Select the established valid default zoom entry as
a fallback, ensuring the combo box never remains unselected and does not save an
invalid value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 55180653-af2f-4aa3-b789-cc81740e68c2

📥 Commits

Reviewing files that changed from the base of the PR and between c8d1f5d and 20aef60.

📒 Files selected for processing (6)
  • src/libs/browser/webview.cpp
  • src/libs/browser/webview.h
  • src/libs/core/settings.cpp
  • src/libs/core/settings.h
  • src/libs/ui/settingsdialog.cpp
  • src/libs/ui/settingsdialog.ui

Comment on lines +36 to +38
connect(Core::Application::instance()->settings(), &Core::Settings::updated, this, [this]() {
applyDefaultZoomLevel();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Avoid unconditionally resetting per-tab zoom on unrelated settings saves.

When Settings::updated is emitted (which occurs when the user clicks OK or Apply for any setting change, such as editing a proxy or modifying a font), applyDefaultZoomLevel() is invoked indiscriminately for all open tabs. This will immediately overwrite any per-tab custom zoom level the user might be actively using.

Consider removing this connection so the default zoom applies only to newly created tabs, or track whether the tab is currently using a user-customized zoom before applying the reset.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/libs/browser/webview.cpp` around lines 36 - 38, Remove the
Settings::updated connection that invokes applyDefaultZoomLevel() in the webview
initialization, so unrelated settings saves do not reset existing tabs’ custom
zoom levels; retain default zoom application for newly created tabs through the
existing creation path.

Comment thread src/libs/browser/webview.cpp
Comment thread src/libs/ui/settingsdialog.cpp Outdated
The document browser always started at 100%, so a preferred zoom had to
be set again after every launch.

Add a default zoom level to Settings > Content. The value applies to
open views and to newly created ones, and is stored as a zoom percentage
so it stays readable in the configuration file and survives changes to
WebView::availableZoomLevels().

Reset Zoom now returns to the configured level rather than 100%.
m_zoomLevel starts at an invalid index so that a default of 30%, which
is index 0, is not skipped by the equality check in setZoomLevel().

Refs zealdocs#1335.
@xevrion
xevrion force-pushed the feat/persist-zoom-level branch from 20aef60 to 1184150 Compare July 18, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Persist the zoom level for the document browser

2 participants