diff --git a/app/src/electron.js b/app/src/electron.js index d835f91d..43c5981d 100644 --- a/app/src/electron.js +++ b/app/src/electron.js @@ -212,6 +212,15 @@ ipcMain.on('window-action', async (event, arg) => { case 'reload': mainWindow.webContents.reloadIgnoringCache(); break; + case 'zoomin': + mainWindow.webContents.zoomLevel += 0.5; + break; + case 'zoomout': + mainWindow.webContents.zoomLevel -= 0.5; + break; + case 'zoomreset': + mainWindow.webContents.zoomLevel = 0; + break; } }); @@ -253,6 +262,7 @@ function createWindow() { titleBarStyle: useNativeMenu ? undefined : 'hidden', ...bounds, icon: os.platform() == 'win32' ? 'icon.ico' : path.resolve(__dirname, '../icon.png'), + partition: 'persist:dbgate', webPreferences: { nodeIntegration: true, contextIsolation: false, diff --git a/app/src/mainMenuDefinition.js b/app/src/mainMenuDefinition.js index 54b44fe2..a02ea051 100644 --- a/app/src/mainMenuDefinition.js +++ b/app/src/mainMenuDefinition.js @@ -24,6 +24,10 @@ module.exports = [ submenu: [ { command: 'tabs.closeTab', hideDisabled: true }, { command: 'tabs.closeAll', hideDisabled: true }, + { divider: true }, + { command: 'app.zoomIn', hideDisabled: true }, + { command: 'app.zoomOut', hideDisabled: true }, + { command: 'app.zoomReset', hideDisabled: true }, ], }, diff --git a/packages/web/src/commands/CommandListener.svelte b/packages/web/src/commands/CommandListener.svelte index 7e0a8a2c..492b1940 100644 --- a/packages/web/src/commands/CommandListener.svelte +++ b/packages/web/src/commands/CommandListener.svelte @@ -11,8 +11,6 @@ if (e.altKey) keyText += 'Alt+'; keyText += e.key; - // console.log('keyText', keyText); - const commandsValue = get(commandsCustomized); const commandsFiltered: any = Object.values(commandsValue).filter( (x: any) => diff --git a/packages/web/src/commands/stdCommands.ts b/packages/web/src/commands/stdCommands.ts index cfec076d..2935d664 100644 --- a/packages/web/src/commands/stdCommands.ts +++ b/packages/web/src/commands/stdCommands.ts @@ -387,7 +387,6 @@ registerCommand({ const keys = [ 'leftPanelWidth', 'visibleToolbar', - 'zoomKoef', 'selectedWidget', 'currentTheme', @@ -643,6 +642,33 @@ registerCommand({ onClick: () => openWebLink('https://opencollective.com/dbgate'), }); + +registerCommand({ + id: 'app.zoomIn', + category: 'Application', + name: 'Zoom in', + keyText: 'Ctrl+=', + testEnabled: () => getElectron() != null, + onClick: () => getElectron().send('window-action', 'zoomin'), +}); + +registerCommand({ + id: 'app.zoomOut', + category: 'Application', + name: 'Zoom out', + keyText: 'Ctrl+-', + testEnabled: () => getElectron() != null, + onClick: () => getElectron().send('window-action', 'zoomout'), +}); + +registerCommand({ + id: 'app.zoomReset', + category: 'Application', + name: 'Reset zoom', + testEnabled: () => getElectron() != null, + onClick: () => getElectron().send('window-action', 'zoomreset'), +}); + const electron = getElectron(); if (electron) { electron.addEventListener('run-command', (e, commandId) => runCommand(commandId)); diff --git a/packages/web/src/settings/SettingsModal.svelte b/packages/web/src/settings/SettingsModal.svelte index 38d42028..679eb6cc 100644 --- a/packages/web/src/settings/SettingsModal.svelte +++ b/packages/web/src/settings/SettingsModal.svelte @@ -25,7 +25,6 @@ _.omitBy(e.detail, (v, k) => k.startsWith(':')) ); visibleToolbar.set(!!e.detail[':visibleToolbar']); - zoomKoef.set(e.detail[':zoomKoef']); if (electron && !getTitleBarVisibility() != !!e.detail[':useNativeMenu']) { electron.send('set-use-native-menu', !!e.detail[':useNativeMenu']); showSnackbarInfo('Native menu settings will be applied after app restart'); @@ -40,7 +39,6 @@ initialValues={{ ...getCurrentSettings(), ':visibleToolbar': getVisibleToolbar(), - ':zoomKoef': getZoomKoef(), ':useNativeMenu': !getTitleBarVisibility(), }} > @@ -48,23 +46,10 @@