Merge pull request #1269 from sbenmoussati/SDA-3381

SDA-3381 Zoom capabilities added for numpad on Windows
This commit is contained in:
Johan Kwarnmark 2021-10-12 09:55:52 +02:00 committed by GitHub
commit d3b5b2046e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 14 deletions

View File

@ -61,6 +61,7 @@ import {
monitorNetworkInterception,
preventWindowNavigation,
reloadWindow,
resetZoomLevel,
windowExists,
zoomIn,
zoomOut,
@ -1846,16 +1847,15 @@ export class WindowHandler {
this.switchClient(ClientSwitchType.CLIENT_2_0_DAILY),
);
}
globalShortcut.register('CmdOrCtrl+=', zoomIn);
globalShortcut.register('CmdOrCtrl+-', zoomOut);
if (isMac) {
globalShortcut.register('CmdOrCtrl+Plus', zoomIn);
globalShortcut.register('CmdOrCtrl+=', zoomIn);
if (this.isMana) {
globalShortcut.register('CmdOrCtrl+-', zoomOut);
}
} else if (this.isMana && (isWindowsOS || isLinux)) {
} else if (isWindowsOS || isLinux) {
globalShortcut.register('Ctrl+=', zoomIn);
globalShortcut.register('Ctrl+-', zoomOut);
globalShortcut.register('Ctrl+numadd', zoomIn);
globalShortcut.register('Ctrl+numsub', zoomOut);
globalShortcut.register('Ctrl+num0', resetZoomLevel);
}
}
@ -1867,15 +1867,14 @@ export class WindowHandler {
globalShortcut.unregister(isMac ? 'Cmd+Alt+I' : 'Ctrl+Shift+I');
globalShortcut.unregister('CmdOrCtrl+R');
globalShortcut.unregister('CmdOrCtrl+=');
globalShortcut.unregister('CmdOrCtrl+-');
if (isMac) {
globalShortcut.unregister('CmdOrCtrl+Plus');
globalShortcut.unregister('CmdOrCtrl+=');
if (this.isMana) {
globalShortcut.unregister('CmdOrCtrl+-');
}
} else if (this.isMana && (isWindowsOS || isLinux)) {
globalShortcut.unregister('Ctrl+=');
globalShortcut.unregister('Ctrl+-');
} else if (isWindowsOS || isLinux) {
globalShortcut.unregister('Ctrl+numadd');
globalShortcut.unregister('Ctrl+numsub');
globalShortcut.unregister('Ctrl+num0');
}
// Unregister shortcuts related to client switch
if (this.url && this.url.startsWith('https://corporate.symphony.com')) {

View File

@ -767,8 +767,24 @@ export const zoomOut = () => {
webContents.setZoomFactor(0.7);
}
}
} else {
const currentZoomLevel = focusedWindow.webContents.getZoomLevel();
focusedWindow.webContents.setZoomLevel(currentZoomLevel - 0.5);
}
};
/**
* Reset zoom level.
* @returns void
*/
export const resetZoomLevel = () => {
const focusedWindow = BrowserWindow.getFocusedWindow();
if (!focusedWindow || !windowExists(focusedWindow)) {
return;
}
focusedWindow.webContents.setZoomLevel(0);
};
/**
* Verifies if window exists and restores/focuses the window
*