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 18 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

PikachuEXE
PikachuEXE previously approved these changes Oct 28, 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

Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

PikachuEXE
PikachuEXE previously approved these changes Nov 24, 2024
@@ -0,0 +1,108 @@
import { defineComponent } from 'vue'
Copy link
Member

Choose a reason for hiding this comment

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

This file no longer exists in dev and was migrated to Popular.vue (composition api)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, I missed this on resolving the merge conflict. Updated now

@ChunkyProgrammer ChunkyProgrammer added the PR: waiting for review For PRs that are complete, tested, and ready for review label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: waiting for review For PRs that are complete, tested, and ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show on hover if icon has shortcut
5 participants