diff --git a/src/app/core-ui/shortcut/shortcut.service.ts b/src/app/core-ui/shortcut/shortcut.service.ts index f418613dce..9cdc675243 100644 --- a/src/app/core-ui/shortcut/shortcut.service.ts +++ b/src/app/core-ui/shortcut/shortcut.service.ts @@ -119,7 +119,29 @@ export class ShortcutService { if (IS_ELECTRON) { if (checkKeyCombo(ev, 'Ctrl+Shift+J')) { window.ipcRenderer.send('TOGGLE_DEV_TOOLS'); + } else if (checkKeyCombo(ev, keys.zoomIn)) { + this._zoom(0.05); + } else if (checkKeyCombo(ev, keys.zoomOut)) { + this._zoom(-0.05); + } else if (checkKeyCombo(ev, keys.zoomDefault)) { + this._zoom(0); } } } + + private _zoom(zoomDelta: number) { + const webFrame = this._electronService.webFrame; + let zoomFactor = webFrame.getZoomFactor(); + zoomFactor += zoomDelta; + zoomFactor = Math.min(Math.max(zoomFactor, 0.1), 4); + + if (zoomDelta === 0) { + webFrame.setZoomFactor(1); + } else { + webFrame.setZoomFactor(zoomFactor); + } + this._configService.updateSection('_uiHelper', { + _zoomFactor: zoomFactor + }); + } } diff --git a/src/app/features/config/config.model.ts b/src/app/features/config/config.model.ts index ffcfced785..8aaf1d8c5e 100644 --- a/src/app/features/config/config.model.ts +++ b/src/app/features/config/config.model.ts @@ -14,6 +14,9 @@ export type KeyboardConfig = Readonly<{ openProjectNotes: string, toggleBookmarks: string; openDistractionPanel: string, + zoomIn: string, + zoomOut: string, + zoomDefault: string, focusLastActiveTask: string, taskEditTitle: string, taskToggleAdditionalInfoOpen: string, diff --git a/src/app/features/config/default-config.const.ts b/src/app/features/config/default-config.const.ts index ec55b62cf5..d944980e6d 100644 --- a/src/app/features/config/default-config.const.ts +++ b/src/app/features/config/default-config.const.ts @@ -43,6 +43,9 @@ export const DEFAULT_CFG: GlobalConfig = { goToFocusMode: 'Shift+F', goToSettings: '', focusLastActiveTask: 'f', + zoomIn: 'Ctrl++', + zoomOut: 'Ctrl+-', + zoomDefault: 'Ctrl+0', taskEditTitle: 'e', taskToggleAdditionalInfoOpen: 'i', taskOpenEstimationDialog: 't', diff --git a/src/app/features/config/form-cfgs/keyboard-form.const.ts b/src/app/features/config/form-cfgs/keyboard-form.const.ts index cf2b9bc1fe..3c73ca3523 100644 --- a/src/app/features/config/form-cfgs/keyboard-form.const.ts +++ b/src/app/features/config/form-cfgs/keyboard-form.const.ts @@ -122,6 +122,27 @@ export const KEYBOARD_SETTINGS_FORM_CFG: ConfigFormSection = { label: 'Focus last active task', }, }, + { + key: 'zoomIn', + type: 'keyboard', + templateOptions: { + label: 'Zoom in (Desktop only)', + }, + }, + { + key: 'zoomOut', + type: 'keyboard', + templateOptions: { + label: 'Zoom out (Desktop only)', + }, + }, + { + key: 'zoomDefault', + type: 'keyboard', + templateOptions: { + label: 'Zoom default (Desktop only)', + }, + }, // TASKS { className: 'tpl', diff --git a/src/app/util/check-key-combo.ts b/src/app/util/check-key-combo.ts index e09c120a92..cab85ba578 100644 --- a/src/app/util/check-key-combo.ts +++ b/src/app/util/check-key-combo.ts @@ -4,6 +4,7 @@ const isSpecialKeyExactlyRight = (isKeyRequired: boolean, isKeyPressed: boolean) export const checkKeyCombo = (ev: KeyboardEvent, comboToTest: string) => { if (comboToTest) { + const isPlusKey = comboToTest.includes('++'); const comboKeys: string[] = comboToTest.split('+'); const standardKey: string = comboKeys[comboKeys.length - 1]; const sk = comboKeys.splice(0); @@ -13,7 +14,7 @@ export const checkKeyCombo = (ev: KeyboardEvent, comboToTest: string) => { && isSpecialKeyExactlyRight(sk.includes('Alt'), ev.altKey) && isSpecialKeyExactlyRight(sk.includes('Meta'), ev.metaKey) && (!(sk.includes('Shift')) || ev.shiftKey === true) - && ev.key === standardKey; + && (ev.key === standardKey || isPlusKey && ev.key === '+'); } else { return null; }