fix #565: global shortcut to open KeeWeb

This commit is contained in:
antelle 2019-10-06 12:27:18 +02:00
parent cc9e369b6f
commit 5a8927b547
5 changed files with 15 additions and 5 deletions

View File

@ -24,7 +24,8 @@ const globalShortcuts = {
copyUser: { mac: 'Ctrl+Alt+B', all: 'Shift+Alt+B' },
copyUrl: { mac: 'Ctrl+Alt+U', all: 'Shift+Alt+U' },
copyOtp: {},
autoType: { mac: 'Ctrl+Alt+T', all: 'Shift+Alt+T' }
autoType: { mac: 'Ctrl+Alt+T', all: 'Shift+Alt+T' },
restoreApp: {}
};
const Shortcuts = {

View File

@ -43,7 +43,8 @@ class SettingsShortcutsView extends View {
copyPassword: Shortcuts.globalShortcutText('copyPassword', true),
copyUser: Shortcuts.globalShortcutText('copyUser', true),
copyUrl: Shortcuts.globalShortcutText('copyUrl', true),
copyOtp: Shortcuts.globalShortcutText('copyOtp', true)
copyOtp: Shortcuts.globalShortcutText('copyOtp', true),
restoreApp: Shortcuts.globalShortcutText('restoreApp', true)
}
: undefined
});

View File

@ -30,5 +30,7 @@
data-shortcut="copyUrl">{{{globalShortcuts.copyUrl}}}</button> {{res 'setShCopyUrlGlobal'}}</div>
<div><button class="shortcut btn-silent {{#if globalIsLarge}}shortcut-large{{/if}}"
data-shortcut="copyOtp">{{{globalShortcuts.copyOtp}}}</button> {{res 'setShCopyOtpGlobal'}}</div>
<div><button class="shortcut btn-silent {{#if globalIsLarge}}shortcut-large{{/if}}"
data-shortcut="restoreApp">{{{globalShortcuts.restoreApp}}}</button> {{#res 'menuRestoreApp'}}KeeWeb{{/res}}</div>
{{/if}}
</div>

View File

@ -402,17 +402,22 @@ function setGlobalShortcuts(appSettings) {
CopyPassword: { shortcut: defaultShortcutModifiers + 'C', event: 'copy-password' },
CopyUser: { shortcut: defaultShortcutModifiers + 'B', event: 'copy-user' },
CopyUrl: { shortcut: defaultShortcutModifiers + 'U', event: 'copy-url' },
CopyOtp: { event: 'copy-otp' }
CopyOtp: { event: 'copy-otp' },
RestoreApp: { action: restoreMainWindow }
};
electron.globalShortcut.unregisterAll();
for (const [key, shortcutDef] of Object.entries(defaultShortcuts)) {
const fromSettings = appSettings[`globalShortcut${key}`];
const shortcut = fromSettings || shortcutDef.shortcut;
const eventName = shortcutDef.event;
if (shortcut) {
try {
electron.globalShortcut.register(shortcut, () => {
emitRemoteEvent(eventName);
if (shortcutDef.event) {
emitRemoteEvent(shortcutDef.event);
}
if (shortcutDef.action) {
shortcutDef.action();
}
});
} catch (e) {}
}

View File

@ -4,6 +4,7 @@ Release notes
`-` #1022: fuzzy search
`+` #1108: setting for running in an iframe
`+` #963: keyboard shortcut to copy OTP in background
`+` #565: global shortcut to open KeeWeb
`-` fix #1273: untranslated menu items
##### v1.11.6 (2019-10-04)