mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Add device name to Insert from iPhone actions
This commit is contained in:
parent
f841cf8705
commit
8169243a30
@ -5,6 +5,11 @@ Change Log
|
||||
4.7.0-beta.2 (unreleased)
|
||||
--------------------------
|
||||
|
||||
### Improvements
|
||||
|
||||
- [beta][trivial] Add device name to quick actions related to Continuity Camera.
|
||||
|
||||
|
||||
### Fixes
|
||||
|
||||
- [beta] Fix an issue that disabled menu items were listed as the quick action candidates.
|
||||
|
@ -112,7 +112,7 @@ extension NSMenuItem {
|
||||
|
||||
} else if self.isEnabled, !self.isHidden, let action = self.action, !ActionCommand.unsupportedActions.contains(action) {
|
||||
[ActionCommand(kind: (action == #selector(ScriptManager.launchScript)) ? .script : .command,
|
||||
title: self.title, paths: [], shortcut: self.shortcut, action: action, tag: self.tag, representedObject: self.representedObject)]
|
||||
title: self.actionTitle, paths: [], shortcut: self.shortcut, action: action, tag: self.tag, representedObject: self.representedObject)]
|
||||
|
||||
} else {
|
||||
[]
|
||||
@ -129,14 +129,29 @@ extension NSMenuItem {
|
||||
else { return }
|
||||
|
||||
switch validator {
|
||||
case let validator as any NSMenuItemValidation:
|
||||
validator.validateMenuItem(self)
|
||||
case let validator as any NSUserInterfaceValidations:
|
||||
validator.validateUserInterfaceItem(self)
|
||||
case let validator as any NSMenuItemValidation:
|
||||
validator.validateMenuItem(self)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// The title for command action.
|
||||
private var actionTitle: String {
|
||||
|
||||
// append the device name to the title for "Insert from iPhone/iPad" actions
|
||||
guard
|
||||
self.action == Selector(("importFromDevice:")),
|
||||
let siblings = self.menu?.items,
|
||||
let index = siblings.firstIndex(of: self),
|
||||
let deviceNameItem = siblings[0..<index].last(where: { !$0.isEnabled && $0.action == Selector(("_importFromDeviceText:")) })
|
||||
else { return self.title }
|
||||
|
||||
return "\(self.title) (\(deviceNameItem.title))"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user