Skip to content

Commit aa69384

Browse files
committed
* Show one action per shortcut action with N shortcuts
1 parent 98d8e39 commit aa69384

File tree

1 file changed

+62
-65
lines changed

1 file changed

+62
-65
lines changed

src/renderer/components/FtKeyboardShortcutPrompt/FtKeyboardShortcutPrompt.vue

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -110,64 +110,60 @@ const primarySections = computed(() => [
110110
111111
const isMac = process.platform === 'darwin'
112112
113-
const localizedShortcutNameDictionary = computed(() => {
113+
const localizedShortcutNameToShortcutsMap = computed(() => {
114114
return new Map([
115-
['SHOW_SHORTCUTS', t('KeyboardShortcutPrompt.Show Keyboard Shortcuts')],
116-
['HISTORY_BACKWARD', t('KeyboardShortcutPrompt.History Backward')],
117-
['HISTORY_FORWARD', t('KeyboardShortcutPrompt.History Forward')],
118-
...(
119-
isMac
120-
? [
121-
['HISTORY_BACKWARD_ALT_MAC', t('KeyboardShortcutPrompt.History Backward (Mac only)')],
122-
['HISTORY_FORWARD_ALT_MAC', t('KeyboardShortcutPrompt.History Forward (Mac only)')],
123-
]
124-
: []
125-
),
126-
['FULLSCREEN', t('KeyboardShortcutPrompt.Fullscreen')],
127-
['NAVIGATE_TO_SETTINGS', t('KeyboardShortcutPrompt.Navigate to Settings')],
128-
(
129-
isMac
130-
? ['NAVIGATE_TO_HISTORY_MAC', t('KeyboardShortcutPrompt.Navigate to History')]
131-
: ['NAVIGATE_TO_HISTORY', t('KeyboardShortcutPrompt.Navigate to History')]
132-
),
133-
['NEW_WINDOW', t('KeyboardShortcutPrompt.New Window')],
134-
['MINIMIZE_WINDOW', t('KeyboardShortcutPrompt.Minimize Window')],
135-
['CLOSE_WINDOW', t('KeyboardShortcutPrompt.Close Window')],
136-
['RESTART_WINDOW', t('KeyboardShortcutPrompt.Restart Window')],
137-
['FORCE_RESTART_WINDOW', t('KeyboardShortcutPrompt.Force Restart Window')],
138-
['TOGGLE_DEVTOOLS', t('KeyboardShortcutPrompt.Toggle Developer Tools')],
139-
['RESET_ZOOM', t('KeyboardShortcutPrompt.Reset Zoom')],
140-
['ZOOM_IN', t('KeyboardShortcutPrompt.Zoom In')],
141-
['ZOOM_OUT', t('KeyboardShortcutPrompt.Zoom Out')],
142-
['FOCUS_SEARCH', t('KeyboardShortcutPrompt.Focus Search')],
143-
['SEARCH_IN_NEW_WINDOW', t('KeyboardShortcutPrompt.Search in New Window')],
144-
145-
['REFRESH', t('KeyboardShortcutPrompt.Refresh')],
146-
['FOCUS_SECONDARY_SEARCH', t('KeyboardShortcutPrompt.Focus Secondary Search')],
147-
148-
['CAPTIONS', t('KeyboardShortcutPrompt.Captions')],
149-
['THEATRE_MODE', t('KeyboardShortcutPrompt.Theatre Mode')],
150-
['FULLSCREEN', t('KeyboardShortcutPrompt.Fullscreen')],
151-
['FULLWINDOW', t('KeyboardShortcutPrompt.Full Window')],
152-
['PICTURE_IN_PICTURE', t('KeyboardShortcutPrompt.Picture in Picture')],
153-
['MUTE', t('KeyboardShortcutPrompt.Mute')],
154-
['VOLUME_UP', t('KeyboardShortcutPrompt.Volume Up')],
155-
['VOLUME_DOWN', t('KeyboardShortcutPrompt.Volume Down')],
156-
['TAKE_SCREENSHOT', t('KeyboardShortcutPrompt.Take Screenshot')],
157-
['STATS', t('KeyboardShortcutPrompt.Stats')],
158-
159-
['PLAY', t('KeyboardShortcutPrompt.Play')],
160-
['LARGE_REWIND', t('KeyboardShortcutPrompt.Large Rewind')],
161-
['LARGE_FAST_FORWARD', t('KeyboardShortcutPrompt.Large Fast Forward')],
162-
['SMALL_REWIND', t('KeyboardShortcutPrompt.Small Rewind')],
163-
['SMALL_FAST_FORWARD', t('KeyboardShortcutPrompt.Small Fast Forward')],
164-
['DECREASE_VIDEO_SPEED', t('KeyboardShortcutPrompt.Decrease Video Speed')],
165-
['INCREASE_VIDEO_SPEED', t('KeyboardShortcutPrompt.Increase Video Speed')],
166-
['SKIP_N_TENTHS', t('KeyboardShortcutPrompt.Skip by Tenths')],
167-
['LAST_CHAPTER', t('KeyboardShortcutPrompt.Last Chapter')],
168-
['NEXT_CHAPTER', t('KeyboardShortcutPrompt.Next Chapter')],
169-
['LAST_FRAME', t('KeyboardShortcutPrompt.Last Frame')],
170-
['NEXT_FRAME', t('KeyboardShortcutPrompt.Next Frame')],
115+
[t('KeyboardShortcutPrompt.Show Keyboard Shortcuts'), ['SHOW_SHORTCUTS']],
116+
[t('KeyboardShortcutPrompt.History Backward'), [
117+
'HISTORY_BACKWARD',
118+
...isMac ? ['HISTORY_BACKWARD_ALT_MAC'] : [],
119+
]],
120+
[t('KeyboardShortcutPrompt.History Forward'), [
121+
'HISTORY_FORWARD',
122+
...isMac ? ['HISTORY_FORWARD_ALT_MAC'] : [],
123+
]],
124+
[t('KeyboardShortcutPrompt.Fullscreen'), ['FULLSCREEN']],
125+
[t('KeyboardShortcutPrompt.Navigate to Settings'), ['NAVIGATE_TO_SETTINGS']],
126+
[t('KeyboardShortcutPrompt.Navigate to History'), [
127+
isMac ? 'NAVIGATE_TO_HISTORY_MAC' : 'NAVIGATE_TO_HISTORY',
128+
]],
129+
[t('KeyboardShortcutPrompt.New Window'), ['NEW_WINDOW']],
130+
[t('KeyboardShortcutPrompt.Minimize Window'), ['MINIMIZE_WINDOW']],
131+
[t('KeyboardShortcutPrompt.Close Window'), ['CLOSE_WINDOW']],
132+
[t('KeyboardShortcutPrompt.Restart Window'), ['RESTART_WINDOW']],
133+
[t('KeyboardShortcutPrompt.Force Restart Window'), ['FORCE_RESTART_WINDOW']],
134+
[t('KeyboardShortcutPrompt.Toggle Developer Tools'), ['TOGGLE_DEVTOOLS']],
135+
[t('KeyboardShortcutPrompt.Reset Zoom'), ['RESET_ZOOM']],
136+
[t('KeyboardShortcutPrompt.Zoom In'), ['ZOOM_IN']],
137+
[t('KeyboardShortcutPrompt.Zoom Out'), ['ZOOM_OUT']],
138+
[t('KeyboardShortcutPrompt.Focus Search'), ['FOCUS_SEARCH']],
139+
[t('KeyboardShortcutPrompt.Search in New Window'), ['SEARCH_IN_NEW_WINDOW']],
140+
141+
[t('KeyboardShortcutPrompt.Refresh'), ['REFRESH']],
142+
[t('KeyboardShortcutPrompt.Focus Secondary Search'), ['FOCUS_SECONDARY_SEARCH']],
143+
144+
[t('KeyboardShortcutPrompt.Captions'), ['CAPTIONS']],
145+
[t('KeyboardShortcutPrompt.Theatre Mode'), ['THEATRE_MODE']],
146+
[t('KeyboardShortcutPrompt.Fullscreen'), ['FULLSCREEN']],
147+
[t('KeyboardShortcutPrompt.Full Window'), ['FULLWINDOW']],
148+
[t('KeyboardShortcutPrompt.Picture in Picture'), ['PICTURE_IN_PICTURE']],
149+
[t('KeyboardShortcutPrompt.Mute'), ['MUTE']],
150+
[t('KeyboardShortcutPrompt.Volume Up'), ['VOLUME_UP']],
151+
[t('KeyboardShortcutPrompt.Volume Down'), ['VOLUME_DOWN']],
152+
[t('KeyboardShortcutPrompt.Take Screenshot'), ['TAKE_SCREENSHOT']],
153+
[t('KeyboardShortcutPrompt.Stats'), ['STATS']],
154+
155+
[t('KeyboardShortcutPrompt.Play'), ['PLAY']],
156+
[t('KeyboardShortcutPrompt.Large Rewind'), ['LARGE_REWIND']],
157+
[t('KeyboardShortcutPrompt.Large Fast Forward'), ['LARGE_FAST_FORWARD']],
158+
[t('KeyboardShortcutPrompt.Small Rewind'), ['SMALL_REWIND']],
159+
[t('KeyboardShortcutPrompt.Small Fast Forward'), ['SMALL_FAST_FORWARD']],
160+
[t('KeyboardShortcutPrompt.Decrease Video Speed'), ['DECREASE_VIDEO_SPEED']],
161+
[t('KeyboardShortcutPrompt.Increase Video Speed'), ['INCREASE_VIDEO_SPEED']],
162+
[t('KeyboardShortcutPrompt.Skip by Tenths'), ['SKIP_N_TENTHS']],
163+
[t('KeyboardShortcutPrompt.Last Chapter'), ['LAST_CHAPTER']],
164+
[t('KeyboardShortcutPrompt.Next Chapter'), ['NEXT_CHAPTER']],
165+
[t('KeyboardShortcutPrompt.Last Frame'), ['LAST_FRAME']],
166+
[t('KeyboardShortcutPrompt.Next Frame'), ['NEXT_FRAME']],
171167
])
172168
})
173169
@@ -176,15 +172,16 @@ function hideKeyboardShortcutPrompt() {
176172
}
177173
178174
function getLocalizedShortcutNamesAndValues(dictionary) {
179-
const localizedDictionary = localizedShortcutNameDictionary.value
180-
return Object.entries(dictionary)
181-
.filter(([key]) =>
182-
localizedDictionary.has(key)
175+
const shortcutNameToShortcutsMap = localizedShortcutNameToShortcutsMap.value
176+
const shortcutLabelSeparator = t('shortcutLabelSeparator')
177+
178+
return shortcutNameToShortcutsMap.entries()
179+
.filter(([_localizedShortcutName, shortcutCodes]) =>
180+
shortcutCodes.some(shortcutCode => Object.hasOwn(dictionary, shortcutCode))
183181
)
184-
.map(([shortcutNameKey, shortcut]) => {
185-
const localizedShortcutName = localizedDictionary.get(shortcutNameKey)
186-
const localizedShortcut = getLocalizedShortcut(shortcut)
187-
return [localizedShortcutName, localizedShortcut]
182+
.map(([localizedShortcutName, shortcutCodes]) => {
183+
const localizedShortcuts = shortcutCodes.map(code => getLocalizedShortcut(dictionary[code]))
184+
return [localizedShortcutName, localizedShortcuts.join(shortcutLabelSeparator)]
188185
})
189186
}
190187

0 commit comments

Comments
 (0)