Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyboard shortcuts to titles #5857

Open
wants to merge 13 commits into
base: development
Choose a base branch
from

Conversation

kommunarr
Copy link
Collaborator

@kommunarr kommunarr commented Oct 13, 2024

Add keyboard shortcuts to titles

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

closes #1587

Description

  • Adds keyboard shortcut information to their button labels, e.g., Mute (m)
    • This includes the video player buttons, the feed refresh buttons, the side nav History/Settings titles, and the top nav HistoryForward/HistoryBackward/OpenNewWindow buttons, but NOT Electron context menu labels
  • Implementation note: To do this properly for the built-in Shaka controls that we don't modify in our code, this PR updates the base Shaka label localization values to include the shortcut whenever the Shaka locale is set.
  • Implementation note: Constants were added for the aforementioned keyboard shortcuts.

Screenshots

Screenshot_20241013_181816

Testing

  • Test that buttons with corresponding keyboard shortcuts have the shortcut referenced in the label, be they in "on" or "off" mode (e.g., Full screen (f) / Exit full screen (f)). See the official list of shortcuts for reference.

Desktop

  • OS: OpenSUSE
  • OS Version: TW

Additional context

The addition of the new constants should help make enhancements like #251 easier in the future.

@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Oct 13, 2024
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) October 13, 2024 23:32
src/constants.js Outdated Show resolved Hide resolved
src/constants.js Outdated Show resolved Hide resolved
@PikachuEXE
Copy link
Collaborator

Label for captions
image
image

@kommunarr
Copy link
Collaborator Author

kommunarr commented Oct 14, 2024

Another good catch; I wasn't testing with a video that had a captions option. Just fixed the issue and added logic preventing label modification if the Shaka localization key does not exist. Also note that this specific Captions label will be the only one with another parenthetical present. This is fine IMO.

Screenshot_20241014_080659

src/constants.js Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pressing c doesnt enable/disable captions

@kommunarr
Copy link
Collaborator Author

kommunarr commented Oct 14, 2024

Added localization of shortcuts & multi-key shortcuts and caught a dangling instance of the wrong constant name for CAPTIONS

@efb4f5ff-1298-471a-8973-3d47447115dc
Copy link
Member

efb4f5ff-1298-471a-8973-3d47447115dc commented Oct 14, 2024

Question: Navigating to the History tab and Settings tab also got shortcuts. Is there a reason those weren't added?

@kommunarr
Copy link
Collaborator Author

@efb4f5ff-1298-471a-8973-3d47447115dc I specifically added the shortcuts with corresponding button labels. The closest equivalent to those would be the corresponding side nav options, which I suppose would work. I can add those as well.

PikachuEXE
PikachuEXE previously approved these changes Oct 15, 2024
Copy link
Collaborator

@PikachuEXE PikachuEXE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested video player, sidebar, top nav button labels, refresh button

Only on MacOS though

@absidue absidue added the DO NOT MERGE UNTIL AFTER RELEASE Do not merge before the next release as this is not a bug fix label Oct 16, 2024
@kommunarr
Copy link
Collaborator Author

kommunarr commented Oct 20, 2024

Still on the fence about whether we should use the Mac key symbols for darwin (⌘/⇧/⌥/etc.)

Edit: did it. I used the version of the arrow icons that are used in Mac context menus, but it is worth noting that FF for Mac uses the more standard-looking ←→↑↓. I'm also open to using the arrow icons for non-Mac systems; I just went with the text version of those from looking at FF for Linux.

@efb4f5ff-1298-471a-8973-3d47447115dc

Still on the fence about whether we should use the Mac key symbols for darwin (⌘/⇧/⌥/etc.)

Edit: did it. I used the version of the arrow icons that are used in Mac context menus, but it is worth noting that FF for Mac uses the more standard-looking ←→↑↓. I'm also open to using the arrow icons for non-Mac systems; I just went with the text version of those from looking at FF for Linux.

@PikachuEXE what do you think of the change in the latest commit

@PikachuEXE
Copy link
Collaborator

PikachuEXE commented Oct 23, 2024

I think there is no need to use short form on labels
The places I see short forms are app menu bar & keymap menus with limited spaces
Even short forms should be used the arrows chars should be ←→↑↓ at least
I haven't checked how this looks on Windows yet

Update 1: Checked windows version

  • MacOS only symbol: prefer text, probably fine with symbol too if someone else want it
  • Arrow: Just use text

Zen Browser
image
RubyMine
image
Vivaldi
image

@kommunarr
Copy link
Collaborator Author

I can change the arrow symbols. I'm not sure if we have other active contributors who are Mac users to provide additional opinions, but maybe if any users have any thoughts

@kommunarr
Copy link
Collaborator Author

Updated the arrow icons for Mac:

Screenshot 2024-10-23 at 8 24 31 AM

@ChunkyProgrammer ChunkyProgrammer removed the DO NOT MERGE UNTIL AFTER RELEASE Do not merge before the next release as this is not a bug fix label Oct 27, 2024
Comment on lines +1006 to +1025
// Add the keyboard shortcut to the label for the default Shaka controls

const shakaControlKeysToShortcutLocalizations = new Map()
Object.entries(shakaControlKeysToShortcuts).forEach(([shakaControlKey, shortcut]) => {
const originalLocalization = localization.resolve(shakaControlKey)
if (originalLocalization === '') {
// e.g., A Shaka localization key in shakaControlKeysToShortcuts has fallen out of date and need to be updated
console.error('Mising Shaka localization key "%s"', shakaControlKey)
return
}

const localizationWithShortcut = addKeyboardShortcutToActionTitle(
originalLocalization,
shortcut
)

shakaControlKeysToShortcutLocalizations.set(shakaControlKey, localizationWithShortcut)
})

localization.insert(shakaLocale, shakaControlKeysToShortcutLocalizations)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: For locales that shaka-player doesn't pre-bundle (so the ones loaded by the code above), we call .insert() twice, once to add the strings and the second time to overwrite them with the shortcuts text. So in the future it might be worth considering having two separate code paths, the current one would be used for locales that are pre-bundled and a second one that combines the fetching and modifications in a single step so we only need to insert the strings once.

@absidue
Copy link
Member

absidue commented Oct 28, 2024

I preferred the stats button before this pull request a lot more as it matched the appearance of the other controls, now it looks out of place in the player.

Before:

before

After:
after

Other controls:
other-controls

@kommunarr
Copy link
Collaborator Author

Ah, for the stats button, you're referring to the text content? I noticed that the labels we were setting for it weren't being used, so I thought that was an error. I can change that back if desired.

I can also look into removing the shortcuts from the overflow menu if that is desired as well. My only concern with that is that I'm not sure if we will be adding more shortcuts or moving more controls to a default overflow menu in the future.

Copy link
Member

@efb4f5ff-1298-471a-8973-3d47447115dc efb4f5ff-1298-471a-8973-3d47447115dc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fullwinodow doesnt show shortcut key in overflow menu

@kommunarr
Copy link
Collaborator Author

Sorry, I'm still a bit confused on what is being asked to be changed. Just fixing full window to have the shortcut show in the overflow menu? @absidue @efb4f5ff-1298-471a-8973-3d47447115dc

@github-actions github-actions bot added PR: merge conflicts / rebase needed and removed PR: waiting for review For PRs that are complete, tested, and ready for review labels Nov 2, 2024
Copy link
Contributor

github-actions bot commented Nov 2, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@efb4f5ff-1298-471a-8973-3d47447115dc

Just fixing full window to have the shortcut show in the overflow menu?

correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show on hover if icon has shortcut
5 participants