Browse Source

Add keyboard shortcut for lyrics (#3824)

* Add keyboard shortcut for lyrics

* Fix linter issues
fix
jackyboygood 11 months ago
committed by GitHub
parent
commit
e136c70b13
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/main/features/core/keyboardShortcuts.js
  2. 1
      src/renderer/ui/components/settings/HotkeyInput.js
  3. 1
      src/renderer/ui/components/settings/tabs/HotkeyTab.js

7
src/main/features/core/keyboardShortcuts.js

@ -39,6 +39,7 @@ const customHotkeysTemplate = {
infoTrack: null,
imFeelingLucky: null,
toggleRepeat: null,
showLyrics: null,
};
const userHotkeys = Settings.get('hotkeys', {});
@ -59,7 +60,11 @@ const _registerHotkeyIfSet = (accelerator, action) => {
if (accelerator) {
try {
const success = globalShortcut.register(accelerator, () => {
Emitter.sendToGooglePlayMusic(`playback:${action}`);
if (action === 'showLyrics') {
Emitter.sendToAll('lyrics:show');
} else {
Emitter.sendToGooglePlayMusic(`playback:${action}`);
}
});
if (!success) {
Logger.error('Failed to register hotkey.', { accelerator, action });

1
src/renderer/ui/components/settings/HotkeyInput.js

@ -39,6 +39,7 @@ class HotkeyInput extends Component {
'infoTrack',
'imFeelingLucky',
'toggleRepeat',
'showLyrics',
]).isRequired,
hotkeys: PropTypes.object.isRequired,
setSetting: PropTypes.func.isRequired,

1
src/renderer/ui/components/settings/tabs/HotkeyTab.js

@ -19,6 +19,7 @@ export default class HotkeyTab extends Component {
<HotkeyInput label={TranslationProvider.query('playback-label-volume-up')} hotkeyAction="increaseVolume" />
<HotkeyInput label={TranslationProvider.query('playback-label-info-track')} hotkeyAction="infoTrack" />
<HotkeyInput label={TranslationProvider.query('playback-label-im-feeling-lucky')} hotkeyAction="imFeelingLucky" />
<HotkeyInput label={TranslationProvider.query('label-show-lyrics')} hotkeyAction="showLyrics" />
</SettingsTabWrapper>
);
}

Loading…
Cancel
Save