-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Double click in the input config table to rename a config (+ bug fixes) #4960
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
Conversation
- Eliminated duplicate code - Fix existing config file cannot be shown in Finder - Remove the ability to remove existing config file - Changed the alert text to reflect the changes
- Changed some wordings
7208cac
to
3765a80
Compare
- Make `userConfigNames` a computed property - Stablize the default input config files by using `KeyValuePairs`
3765a80
to
feea96d
Compare
When I saw the commit comment "don't maintain userConfigNames manually" I got excited. It would be better if |
In the latest commit, I removed |
24eed5c
to
8fb983c
Compare
} | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also remove the file deletion code because maybe its too dangerous to remove user files with "OK" or an enter hit in a seemingly unrelated alert window (the user want to create a config, but end up with deleting their file), let alone that part of code was never been executed before due to the erroneous usage.
At least we should tell the user how to delete this file (where it is) in the dialog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default action (OK button or enter) will bring up the Finder and show the conflicting config file
|
||
} | ||
|
||
@IBAction func configFileListDoubleAction(_ sender: NSTableView) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I think when double clicking a table row people should expect the cell become editable, rather than a pop-up dialog. It's fine though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I wanted to implement this way, however, I noticed that if the renaming fails, it would be messy to bring up another dialog window to give the user info on why the action failed. So I just used the alert window as other actions (new, duplicate) in this window.
@@ -434,11 +384,11 @@ extension PrefKeyBindingViewController: NSTableViewDelegate, NSTableViewDataSour | |||
} | |||
|
|||
func tableViewSelectionDidChange(_ notification: Notification) { | |||
guard !isLoading else { return } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that isLoading
's only usage is to filter out didChange notifications when calling loadConfigFile
? If so, it's better to add a parameter like loadConfigFile(_, reloadTable:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isLoading
is preventing infinite loops, since we call loadConfigFile
in tableViewSelectionDidChange
, and we also call reloadData
in loadConfigFile
, which will cause another tableViewSelectionDidChange
, thus causing an infinite loop.
Very much appreciate the update! And yes @lhc70000 is right about the performance issue when checking the file system each time. IMHO it's still a good improvement to do a lazy property for now. Later (or hopefully sooner) a good way to do a live update of the list would be to make a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed the latest commit fixes the issue with the bindings not being drawn when the panel first comes up.
I would think it would be better to follow the conventions of Finder
where you press return and the name becomes editable. Finder
also has to deal with the case where the file can't be renamed, like when you make the directory read only. Finder
puts up an alert when that happens.
We can make this happen in another PR |
Description:
This PR:
KeyValuePairs
Besides, this PR also fixes the usage of the
Utility.quickAskPanel
:iina/iina/PrefKeyBindingViewController.swift
Lines 177 to 188 in 94176bb
Previously it used the return value of the
quickAskPanel
, however, if thequickAskPanel
is provided with the sheet window, it will always returnfalse
immediately without waiting for user input in theNSAlert
panel. So 1) the "delete file" part of code could never be called, and 2) it always shows the existing file in Finder after theNSAlert
is initiated (instead of after the user clicking the cancel button).This PR changes the logic to show the existing file when clicking on OK, and do nothing when clicking on cancel. And also change the wording from "This should not happen..." to "A config file with the same filename already exists..."
I also remove the file deletion code because maybe its too dangerous to remove user files with "OK" or an enter hit in a seemingly unrelated alert window (the user want to create a config, but end up with deleting their file), let alone that part of code was never been executed before due to the erroneous usage.