iina icon indicating copy to clipboard operation
iina copied to clipboard

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

Open svobs opened this issue 8 months ago • 0 comments


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.

svobs avatar Jun 22 '24 05:06 svobs