Fix #253 - Better honor --zoom option. (#347)

* When zooming in/out, start from the options zoom, not 1 (don't jump)
* Add 'Zoom Reset' feature bound to Ctrl+0, with indicative label for non-100% zoom value
This commit is contained in:
Ronan Jouchet 2017-04-19 07:47:54 -04:00 committed by GitHub
parent be4b9a7436
commit bbce1e88d4
2 changed files with 25 additions and 2 deletions

View File

@ -66,7 +66,7 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
fs.writeFileSync(path.join(__dirname, '..', 'nativefier.json'), JSON.stringify(options));
}
let currentZoom = 1;
let currentZoom = options.zoom;
const onZoomIn = () => {
currentZoom += ZOOM_INTERVAL;
@ -78,6 +78,10 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
mainWindow.webContents.send('change-zoom', currentZoom);
};
const onZoomReset = () => {
mainWindow.webContents.send('change-zoom', options.zoom);
};
const clearAppData = () => {
dialog.showMessageBox(mainWindow, {
type: 'warning',
@ -114,6 +118,8 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
appQuit: onAppQuit,
zoomIn: onZoomIn,
zoomOut: onZoomOut,
zoomReset: onZoomReset,
zoomBuildTimeValue: options.zoom,
goBack: onGoBack,
goForward: onGoForward,
getCurrentUrl: getCurrentUrl,

View File

@ -5,16 +5,21 @@ import {Menu, shell, clipboard} from 'electron';
* @param appQuit
* @param zoomIn
* @param zoomOut
* @param zoomReset
* @param zoomBuildTimeValue
* @param goBack
* @param goForward
* @param getCurrentUrl
* @param clearAppData
* @param disableDevTools
*/
function createMenu({nativefierVersion, appQuit, zoomIn, zoomOut, goBack, goForward, getCurrentUrl, clearAppData, disableDevTools}) {
function createMenu({nativefierVersion, appQuit, zoomIn, zoomOut, zoomReset, zoomBuildTimeValue, goBack, goForward, getCurrentUrl, clearAppData, disableDevTools}) {
if (Menu.getApplicationMenu()) {
return;
}
const zoomResetLabel = (zoomBuildTimeValue === 1.0) ?
'Reset Zoom' :
`Reset Zoom (to ${zoomBuildTimeValue * 100}%, set at build time)`;
const template = [
{
@ -136,6 +141,18 @@ function createMenu({nativefierVersion, appQuit, zoomIn, zoomOut, goBack, goForw
zoomOut();
}
},
{
label: zoomResetLabel,
accelerator: (() => {
if (process.platform === 'darwin') {
return 'Command+0';
}
return 'Ctrl+0';
})(),
click: () => {
zoomReset();
}
},
{
label: 'Toggle Developer Tools',
accelerator: (() => {