mirror of https://github.com/keeweb/keeweb.git
fix #565: global shortcut to open KeeWeb
This commit is contained in:
parent
cc9e369b6f
commit
5a8927b547
|
@ -24,7 +24,8 @@ const globalShortcuts = {
|
||||||
copyUser: { mac: 'Ctrl+Alt+B', all: 'Shift+Alt+B' },
|
copyUser: { mac: 'Ctrl+Alt+B', all: 'Shift+Alt+B' },
|
||||||
copyUrl: { mac: 'Ctrl+Alt+U', all: 'Shift+Alt+U' },
|
copyUrl: { mac: 'Ctrl+Alt+U', all: 'Shift+Alt+U' },
|
||||||
copyOtp: {},
|
copyOtp: {},
|
||||||
autoType: { mac: 'Ctrl+Alt+T', all: 'Shift+Alt+T' }
|
autoType: { mac: 'Ctrl+Alt+T', all: 'Shift+Alt+T' },
|
||||||
|
restoreApp: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Shortcuts = {
|
const Shortcuts = {
|
||||||
|
|
|
@ -43,7 +43,8 @@ class SettingsShortcutsView extends View {
|
||||||
copyPassword: Shortcuts.globalShortcutText('copyPassword', true),
|
copyPassword: Shortcuts.globalShortcutText('copyPassword', true),
|
||||||
copyUser: Shortcuts.globalShortcutText('copyUser', true),
|
copyUser: Shortcuts.globalShortcutText('copyUser', true),
|
||||||
copyUrl: Shortcuts.globalShortcutText('copyUrl', true),
|
copyUrl: Shortcuts.globalShortcutText('copyUrl', true),
|
||||||
copyOtp: Shortcuts.globalShortcutText('copyOtp', true)
|
copyOtp: Shortcuts.globalShortcutText('copyOtp', true),
|
||||||
|
restoreApp: Shortcuts.globalShortcutText('restoreApp', true)
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,5 +30,7 @@
|
||||||
data-shortcut="copyUrl">{{{globalShortcuts.copyUrl}}}</button> {{res 'setShCopyUrlGlobal'}}</div>
|
data-shortcut="copyUrl">{{{globalShortcuts.copyUrl}}}</button> {{res 'setShCopyUrlGlobal'}}</div>
|
||||||
<div><button class="shortcut btn-silent {{#if globalIsLarge}}shortcut-large{{/if}}"
|
<div><button class="shortcut btn-silent {{#if globalIsLarge}}shortcut-large{{/if}}"
|
||||||
data-shortcut="copyOtp">{{{globalShortcuts.copyOtp}}}</button> {{res 'setShCopyOtpGlobal'}}</div>
|
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}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -402,17 +402,22 @@ function setGlobalShortcuts(appSettings) {
|
||||||
CopyPassword: { shortcut: defaultShortcutModifiers + 'C', event: 'copy-password' },
|
CopyPassword: { shortcut: defaultShortcutModifiers + 'C', event: 'copy-password' },
|
||||||
CopyUser: { shortcut: defaultShortcutModifiers + 'B', event: 'copy-user' },
|
CopyUser: { shortcut: defaultShortcutModifiers + 'B', event: 'copy-user' },
|
||||||
CopyUrl: { shortcut: defaultShortcutModifiers + 'U', event: 'copy-url' },
|
CopyUrl: { shortcut: defaultShortcutModifiers + 'U', event: 'copy-url' },
|
||||||
CopyOtp: { event: 'copy-otp' }
|
CopyOtp: { event: 'copy-otp' },
|
||||||
|
RestoreApp: { action: restoreMainWindow }
|
||||||
};
|
};
|
||||||
electron.globalShortcut.unregisterAll();
|
electron.globalShortcut.unregisterAll();
|
||||||
for (const [key, shortcutDef] of Object.entries(defaultShortcuts)) {
|
for (const [key, shortcutDef] of Object.entries(defaultShortcuts)) {
|
||||||
const fromSettings = appSettings[`globalShortcut${key}`];
|
const fromSettings = appSettings[`globalShortcut${key}`];
|
||||||
const shortcut = fromSettings || shortcutDef.shortcut;
|
const shortcut = fromSettings || shortcutDef.shortcut;
|
||||||
const eventName = shortcutDef.event;
|
|
||||||
if (shortcut) {
|
if (shortcut) {
|
||||||
try {
|
try {
|
||||||
electron.globalShortcut.register(shortcut, () => {
|
electron.globalShortcut.register(shortcut, () => {
|
||||||
emitRemoteEvent(eventName);
|
if (shortcutDef.event) {
|
||||||
|
emitRemoteEvent(shortcutDef.event);
|
||||||
|
}
|
||||||
|
if (shortcutDef.action) {
|
||||||
|
shortcutDef.action();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ Release notes
|
||||||
`-` #1022: fuzzy search
|
`-` #1022: fuzzy search
|
||||||
`+` #1108: setting for running in an iframe
|
`+` #1108: setting for running in an iframe
|
||||||
`+` #963: keyboard shortcut to copy OTP in background
|
`+` #963: keyboard shortcut to copy OTP in background
|
||||||
|
`+` #565: global shortcut to open KeeWeb
|
||||||
`-` fix #1273: untranslated menu items
|
`-` fix #1273: untranslated menu items
|
||||||
|
|
||||||
##### v1.11.6 (2019-10-04)
|
##### v1.11.6 (2019-10-04)
|
||||||
|
|
Loading…
Reference in New Issue