-
-
Notifications
You must be signed in to change notification settings - Fork 726
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,16 @@ function onNavigate (tabId, url, isInPlace, isMainFrame, frameProcessId, frameRo | |
} | ||
} | ||
|
||
// set default zoom level for tab | ||
function setTabDefaultZoomLevel (tabId) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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) |
||
const defaultZoomLevel = parseFloat( settings.get('defaultZoomLevel') || '1' ); // Use setting or default value | ||
webviews.callAsync(tabId, 'setZoomFactor', [defaultZoomLevel], function(err) { | ||
if (err) { | ||
console.error(`Failed to set zoom factor for tab ${tabId}: ${err}`); | ||
} | ||
}); | ||
} | ||
|
||
// called whenever the page finishes loading | ||
function onPageLoad (tabId) { | ||
// capture a preview image if a new page has been loaded | ||
|
@@ -188,6 +198,10 @@ const webviews = { | |
setAudioMutedOnCreate(tabId, tabData.muted) | ||
} | ||
|
||
if (!existingViewId) { | ||
setTabDefaultZoomLevel(tabId); | ||
} | ||
|
||
// if the tab is private, we want to partition it. See http://electron.atom.io/docs/v0.34.0/api/web-view-tag/#partition | ||
// since tab IDs are unique, we can use them as partition names | ||
if (tabData.private === true) { | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -159,6 +159,7 @@ | |||||
"settingsUserscriptsToggle": "Enable user scripts", | ||||||
"settingsShowDividerToggle": "Show divider between tabs", | ||||||
"settingsLanguageSelection": "Language: ", | ||||||
"settingsDefaultZoomLevel": "Default zoom", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"settingsSeparateTitlebarToggle": "Use separate title bar", | ||||||
"settingsAutoplayToggle": "Enable Autoplay", | ||||||
"settingsOpenTabsInForegroundToggle": "Open new tabs in the foreground", | ||||||
|
There was a problem hiding this comment.
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.