Fix "Reset Zoom" menu item (fix #1241) (PR #1243)

This commit is contained in:
Adam Weeden 2021-06-25 16:05:23 -04:00 committed by GitHub
parent dc0e6cb68f
commit a6c1dcf952
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 11 deletions

View File

@ -38,7 +38,7 @@ describe('generateMenu', () => {
const menu = generateMenu(
{
nativefierVersion: '1.0.0',
zoomBuildTimeValue: 1.0,
zoom: 1.0,
disableDevTools: false,
},
window,
@ -65,7 +65,7 @@ describe('generateMenu', () => {
const menu = generateMenu(
{
nativefierVersion: '1.0.0',
zoomBuildTimeValue: 1.0,
zoom: 1.0,
disableDevTools: false,
},
window,
@ -95,7 +95,7 @@ describe('generateMenu', () => {
const menu = generateMenu(
{
nativefierVersion: '1.0.0',
zoomBuildTimeValue: 1.0,
zoom: 1.0,
disableDevTools: false,
},
window,
@ -131,7 +131,7 @@ describe('generateMenu', () => {
const menu = generateMenu(
{
nativefierVersion: '1.0.0',
zoomBuildTimeValue: 1.0,
zoom: 1.0,
disableDevTools: false,
},
window,

View File

@ -54,11 +54,11 @@ export function generateMenu(
options,
mainWindow: BrowserWindow,
): MenuItemConstructorOptions[] {
const { nativefierVersion, zoomBuildTimeValue, disableDevTools } = options;
const { nativefierVersion, zoom, disableDevTools } = options;
const zoomResetLabel =
zoomBuildTimeValue === 1.0
!zoom || zoom === 1.0
? 'Reset Zoom'
: `Reset Zoom (to ${zoomBuildTimeValue * 100}%, set at build time)`;
: `Reset Zoom (to ${(zoom * 100).toFixed(1)}%, set at build time)`;
const editMenu: MenuItemConstructorOptions = {
label: '&Edit',
@ -210,14 +210,14 @@ export function generateMenu(
{
label: zoomResetLabel,
accelerator: 'CmdOrCtrl+0',
click: zoomReset,
click: (): void => zoomReset(options),
},
{
label: 'ZoomResetAdditionalShortcut',
visible: false,
acceleratorWorksWhenHidden: true,
accelerator: 'CmdOrCtrl+num0',
click: zoomReset,
click: (): void => zoomReset(options),
},
],
};

View File

@ -1,7 +1,7 @@
import {
dialog,
BrowserWindow,
BrowserWindowConstructorOptions,
dialog,
HeadersReceivedResponse,
IpcMainEvent,
MessageBoxReturnValue,
@ -331,7 +331,7 @@ export function zoomOut(): void {
export function zoomReset(options): void {
log.debug('zoomReset');
withFocusedWindow((focusedWindow) => {
focusedWindow.webContents.zoomFactor = options.zoom;
focusedWindow.webContents.zoomFactor = options.zoom ?? 1.0;
});
}