Merge 671b73a7ab
into 018e445b34
This commit is contained in:
commit
1acbadc2a6
|
@ -3,3 +3,4 @@
|
|||
"keyboard_shortcut_used_by_menu_item" = "This keyboard shortcut cannot be used as it’s already used by the “%@” menu item.";
|
||||
"keyboard_shortcut_used_by_system" = "This keyboard shortcut cannot be used as it’s already a system-wide keyboard shortcut.";
|
||||
"keyboard_shortcuts_can_be_changed" = "Most system-wide keyboard shortcuts can be changed in “System Settings › Keyboard › Keyboard Shortcuts”.";
|
||||
"force_use_shortcut" = "Use Anyway";
|
|
@ -249,19 +249,27 @@ extension KeyboardShortcuts {
|
|||
return nil
|
||||
}
|
||||
|
||||
guard !shortcut.isTakenBySystem else {
|
||||
if shortcut.isTakenBySystem {
|
||||
self.blur()
|
||||
|
||||
NSAlert.showModal(
|
||||
let modalResponse = NSAlert.showModal(
|
||||
for: self.window,
|
||||
title: "keyboard_shortcut_used_by_system".localized,
|
||||
// TODO: Add button to offer to open the relevant system settings pane for the user.
|
||||
message: "keyboard_shortcuts_can_be_changed".localized
|
||||
message: "keyboard_shortcuts_can_be_changed".localized,
|
||||
buttonTitles: [
|
||||
"force_use_shortcut".localized,
|
||||
"Cancel"
|
||||
]
|
||||
)
|
||||
|
||||
self.focus()
|
||||
|
||||
return nil
|
||||
// first button returned from alert means user wants to continue setting this
|
||||
// shortcut despite it being used by system.
|
||||
guard modalResponse == .alertFirstButtonReturn else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
self.stringValue = "\(shortcut)"
|
||||
|
|
|
@ -142,13 +142,15 @@ extension NSAlert {
|
|||
title: String,
|
||||
message: String? = nil,
|
||||
style: Style = .warning,
|
||||
icon: NSImage? = nil
|
||||
icon: NSImage? = nil,
|
||||
buttonTitles: [String] = []
|
||||
) -> NSApplication.ModalResponse {
|
||||
NSAlert(
|
||||
title: title,
|
||||
message: message,
|
||||
style: style,
|
||||
icon: icon
|
||||
icon: icon,
|
||||
buttonTitles: buttonTitles
|
||||
).runModal(for: window)
|
||||
}
|
||||
|
||||
|
@ -156,12 +158,17 @@ extension NSAlert {
|
|||
title: String,
|
||||
message: String? = nil,
|
||||
style: Style = .warning,
|
||||
icon: NSImage? = nil
|
||||
icon: NSImage? = nil,
|
||||
buttonTitles: [String] = []
|
||||
) {
|
||||
self.init()
|
||||
self.messageText = title
|
||||
self.alertStyle = style
|
||||
self.icon = icon
|
||||
|
||||
for buttonTitle in buttonTitles {
|
||||
self.addButton(withTitle: buttonTitle)
|
||||
}
|
||||
|
||||
if let message {
|
||||
self.informativeText = message
|
||||
|
|
Loading…
Reference in New Issue