mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-09 00:21:10 +00:00
* 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:
parent
be4b9a7436
commit
bbce1e88d4
@ -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,
|
||||
|
@ -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: (() => {
|
||||
|
Loading…
Reference in New Issue
Block a user