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

Key bindings for IINA commands: clean up & remove redundant code #5012

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

svobs
Copy link
Contributor

@svobs svobs commented Jun 22, 2024


Description:

Now that the fix for #4567 has been merged, it's clear that a lot of code for handling key bindings for IINA commands is now redundant because most of them are now being mapped to hidden menu items. This became apparent while examining PR #5005, which is adding a new command.

To be specific, of all the commands enumerated in IINACommand.swift, I found that nearly all of them are already being mapped to menu items in MenuController.updateKeyEquivalentsFrom(), so the checks for these can be simply deleted from PlayerWindowController.handleIINACommand() and its overrides; they will never be used. I handled the remaining 5 commands as follows:

  • flip, mirror: I migrated handling for these to updateKeyEquivalentsFrom. It was easy because all the objects were already created and easily referenced there.
  • openFile and openURL: I tried migrating these to updateKeyEquivalentsFrom, but for some reason, the Option key was being added to their equivalents. Did not dig into why this was happening; just decided to leave them in handleIINACommand instead.
  • deleteCurrentFileHard: this is a less-used command, and it didn't have an NSMenuItem object in MenuController, so it would have required more code to migrate. I did move it up from MainWindowController to PlayerWindowController so that it can also be recognized in music mode. I'm assuming that was an oversight when that feature was created.

Note that this should be considered lower-priority and not merged too close to a release.

Changes:
• Remove redundant handling of IINA commands via handleIINACommand() in
  PlayerWindowController & its subclasses (no longer needed, now that
  hidden menu items are being created in MenuController).
• Move "flip" & "mirror IINA command handling into MenuController's
  updateKeyEquivalentsFrom()
• Move handling of "deleteCurrentFileHard" command from MainWindow
  into PlayerWindow so that it will also work in music mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant