zoom - removed from settings, added to window menu

This commit is contained in:
Jan Prochazka
2022-02-24 17:05:19 +01:00
parent 1afbf6049e
commit f384ddfb1f
6 changed files with 42 additions and 27 deletions

View File

@@ -212,6 +212,15 @@ ipcMain.on('window-action', async (event, arg) => {
case 'reload': case 'reload':
mainWindow.webContents.reloadIgnoringCache(); mainWindow.webContents.reloadIgnoringCache();
break; 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', titleBarStyle: useNativeMenu ? undefined : 'hidden',
...bounds, ...bounds,
icon: os.platform() == 'win32' ? 'icon.ico' : path.resolve(__dirname, '../icon.png'), icon: os.platform() == 'win32' ? 'icon.ico' : path.resolve(__dirname, '../icon.png'),
partition: 'persist:dbgate',
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
contextIsolation: false, contextIsolation: false,

View File

@@ -24,6 +24,10 @@ module.exports = [
submenu: [ submenu: [
{ command: 'tabs.closeTab', hideDisabled: true }, { command: 'tabs.closeTab', hideDisabled: true },
{ command: 'tabs.closeAll', hideDisabled: true }, { command: 'tabs.closeAll', hideDisabled: true },
{ divider: true },
{ command: 'app.zoomIn', hideDisabled: true },
{ command: 'app.zoomOut', hideDisabled: true },
{ command: 'app.zoomReset', hideDisabled: true },
], ],
}, },

View File

@@ -11,8 +11,6 @@
if (e.altKey) keyText += 'Alt+'; if (e.altKey) keyText += 'Alt+';
keyText += e.key; keyText += e.key;
// console.log('keyText', keyText);
const commandsValue = get(commandsCustomized); const commandsValue = get(commandsCustomized);
const commandsFiltered: any = Object.values(commandsValue).filter( const commandsFiltered: any = Object.values(commandsValue).filter(
(x: any) => (x: any) =>

View File

@@ -387,7 +387,6 @@ registerCommand({
const keys = [ const keys = [
'leftPanelWidth', 'leftPanelWidth',
'visibleToolbar', 'visibleToolbar',
'zoomKoef',
'selectedWidget', 'selectedWidget',
'currentTheme', 'currentTheme',
@@ -643,6 +642,33 @@ registerCommand({
onClick: () => openWebLink('https://opencollective.com/dbgate'), 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(); const electron = getElectron();
if (electron) { if (electron) {
electron.addEventListener('run-command', (e, commandId) => runCommand(commandId)); electron.addEventListener('run-command', (e, commandId) => runCommand(commandId));

View File

@@ -25,7 +25,6 @@
_.omitBy(e.detail, (v, k) => k.startsWith(':')) _.omitBy(e.detail, (v, k) => k.startsWith(':'))
); );
visibleToolbar.set(!!e.detail[':visibleToolbar']); visibleToolbar.set(!!e.detail[':visibleToolbar']);
zoomKoef.set(e.detail[':zoomKoef']);
if (electron && !getTitleBarVisibility() != !!e.detail[':useNativeMenu']) { if (electron && !getTitleBarVisibility() != !!e.detail[':useNativeMenu']) {
electron.send('set-use-native-menu', !!e.detail[':useNativeMenu']); electron.send('set-use-native-menu', !!e.detail[':useNativeMenu']);
showSnackbarInfo('Native menu settings will be applied after app restart'); showSnackbarInfo('Native menu settings will be applied after app restart');
@@ -40,7 +39,6 @@
initialValues={{ initialValues={{
...getCurrentSettings(), ...getCurrentSettings(),
':visibleToolbar': getVisibleToolbar(), ':visibleToolbar': getVisibleToolbar(),
':zoomKoef': getZoomKoef(),
':useNativeMenu': !getTitleBarVisibility(), ':useNativeMenu': !getTitleBarVisibility(),
}} }}
> >
@@ -48,23 +46,10 @@
<div slot="header">Settings</div> <div slot="header">Settings</div>
<FormValues let:values> <FormValues let:values>
<div class="heading">Appearance</div>
<!-- <FormCheckboxField name=":visibleToolbar" label="Show toolbar" defaultValue={true} /> -->
{#if electron} {#if electron}
<div class="heading">Appearance</div>
<FormCheckboxField name=":useNativeMenu" label="Use system native menu" /> <FormCheckboxField name=":useNativeMenu" label="Use system native menu" />
{/if} {/if}
<FormSelectField
name=":zoomKoef"
label="Zoom"
defaultValue="1"
options={[
{ label: '60%', value: '0.6' },
{ label: '80%', value: '0.8' },
{ label: '100%', value: '1' },
{ label: '120%', value: '1.2' },
{ label: '140%', value: '1.4' },
]}
/>
<div class="heading">Data grid</div> <div class="heading">Data grid</div>
<FormTextField <FormTextField

View File

@@ -58,7 +58,6 @@ export const commandsCustomized = derived([commands, commandsSettings], ([$comma
// export const visibleToolbar = writableWithStorage(true, 'visibleToolbar'); // export const visibleToolbar = writableWithStorage(true, 'visibleToolbar');
export const visibleToolbar = writable(false); export const visibleToolbar = writable(false);
export const zoomKoef = writableWithStorage(1, 'zoomKoef');
export const leftPanelWidth = writableWithStorage(300, 'leftPanelWidth'); export const leftPanelWidth = writableWithStorage(300, 'leftPanelWidth');
export const currentDropDownMenu = writable(null); export const currentDropDownMenu = writable(null);
export const openedModals = writable([]); export const openedModals = writable([]);
@@ -102,13 +101,6 @@ visibleToolbar.subscribe(value => {
}); });
export const getVisibleToolbar = () => visibleToolbarValue; export const getVisibleToolbar = () => visibleToolbarValue;
let zommKoefValue = null;
zoomKoef.subscribe(value => {
zommKoefValue = value;
document.body.style.setProperty('zoom', zommKoefValue);
});
export const getZoomKoef = () => zommKoefValue;
let openedTabsValue = null; let openedTabsValue = null;
openedTabs.subscribe(value => { openedTabs.subscribe(value => {
openedTabsValue = value; openedTabsValue = value;