mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-24 07:38:36 +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));
|
fs.writeFileSync(path.join(__dirname, '..', 'nativefier.json'), JSON.stringify(options));
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentZoom = 1;
|
let currentZoom = options.zoom;
|
||||||
|
|
||||||
const onZoomIn = () => {
|
const onZoomIn = () => {
|
||||||
currentZoom += ZOOM_INTERVAL;
|
currentZoom += ZOOM_INTERVAL;
|
||||||
@ -78,6 +78,10 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
|||||||
mainWindow.webContents.send('change-zoom', currentZoom);
|
mainWindow.webContents.send('change-zoom', currentZoom);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onZoomReset = () => {
|
||||||
|
mainWindow.webContents.send('change-zoom', options.zoom);
|
||||||
|
};
|
||||||
|
|
||||||
const clearAppData = () => {
|
const clearAppData = () => {
|
||||||
dialog.showMessageBox(mainWindow, {
|
dialog.showMessageBox(mainWindow, {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
@ -114,6 +118,8 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
|||||||
appQuit: onAppQuit,
|
appQuit: onAppQuit,
|
||||||
zoomIn: onZoomIn,
|
zoomIn: onZoomIn,
|
||||||
zoomOut: onZoomOut,
|
zoomOut: onZoomOut,
|
||||||
|
zoomReset: onZoomReset,
|
||||||
|
zoomBuildTimeValue: options.zoom,
|
||||||
goBack: onGoBack,
|
goBack: onGoBack,
|
||||||
goForward: onGoForward,
|
goForward: onGoForward,
|
||||||
getCurrentUrl: getCurrentUrl,
|
getCurrentUrl: getCurrentUrl,
|
||||||
|
@ -5,16 +5,21 @@ import {Menu, shell, clipboard} from 'electron';
|
|||||||
* @param appQuit
|
* @param appQuit
|
||||||
* @param zoomIn
|
* @param zoomIn
|
||||||
* @param zoomOut
|
* @param zoomOut
|
||||||
|
* @param zoomReset
|
||||||
|
* @param zoomBuildTimeValue
|
||||||
* @param goBack
|
* @param goBack
|
||||||
* @param goForward
|
* @param goForward
|
||||||
* @param getCurrentUrl
|
* @param getCurrentUrl
|
||||||
* @param clearAppData
|
* @param clearAppData
|
||||||
* @param disableDevTools
|
* @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()) {
|
if (Menu.getApplicationMenu()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const zoomResetLabel = (zoomBuildTimeValue === 1.0) ?
|
||||||
|
'Reset Zoom' :
|
||||||
|
`Reset Zoom (to ${zoomBuildTimeValue * 100}%, set at build time)`;
|
||||||
|
|
||||||
const template = [
|
const template = [
|
||||||
{
|
{
|
||||||
@ -136,6 +141,18 @@ function createMenu({nativefierVersion, appQuit, zoomIn, zoomOut, goBack, goForw
|
|||||||
zoomOut();
|
zoomOut();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: zoomResetLabel,
|
||||||
|
accelerator: (() => {
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
return 'Command+0';
|
||||||
|
}
|
||||||
|
return 'Ctrl+0';
|
||||||
|
})(),
|
||||||
|
click: () => {
|
||||||
|
zoomReset();
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Toggle Developer Tools',
|
label: 'Toggle Developer Tools',
|
||||||
accelerator: (() => {
|
accelerator: (() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user