Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a default zoom level setting for new tabs #2490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

romantelychko
Copy link

@romantelychko romantelychko commented Sep 5, 2024

Added a default zoom level setting for new tabs.
Fixed some IDs on the settings.html page.

@romantelychko romantelychko changed the title Added a default zoom level for setting up new tabs Added a default zoom level setting for new tabs Sep 5, 2024
@@ -39,7 +40,8 @@ var webviewGestures = {
return this.zoomWebviewBy(tabId, -0.2)
},
resetWebviewZoom: function (tabId) {
webviews.callAsync(tabId, 'zoomFactor', 1.0)
const defaultZoomLevel = parseFloat( settings.get('defaultZoomLevel') || '1' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be possible to store the setting value directly as a number, so we wouldn't need to parse the string.

@@ -51,6 +51,16 @@ function onNavigate (tabId, url, isInPlace, isMainFrame, frameProcessId, frameRo
}
}

// set default zoom level for tab
function setTabDefaultZoomLevel (tabId) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't working for me. I think the issue is that when it's called from webviews.add, the view object hasn't been created in the main process yet, so calling view.setZoomFactor isn't doing anything.

Another thing to consider is how this interacts with user-set zoom levels. For example, right now, if I open Github and zoom it to 150%, Electron will remember that and set the zoom to 150% on my next visit. It seems like this would reset that back to my default zoom level, which seems undesirable.

It looks like webPreferences has a zoomFactor option that can be used to do this instead: https://www.electronjs.org/docs/latest/api/structures/web-preferences. That might work better with custom zoom levels.

(the webPreferences object is created in viewManager.js)

@@ -159,6 +159,7 @@
"settingsUserscriptsToggle": "Enable user scripts",
"settingsShowDividerToggle": "Show divider between tabs",
"settingsLanguageSelection": "Language: ",
"settingsDefaultZoomLevel": "Default zoom",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"settingsDefaultZoomLevel": "Default zoom",
"settingsDefaultZoomLevel": "Default zoom:",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants