mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Merge pull request #2100 from Wevah/open-in-background-inversion
Make shift key invert the "open in background" preference
This commit is contained in:
@@ -193,7 +193,9 @@ extension DetailWebViewController: WKNavigationDelegate {
|
||||
public func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||
if navigationAction.navigationType == .linkActivated {
|
||||
if let url = navigationAction.request.url {
|
||||
Browser.open(url.absoluteString)
|
||||
let flags = navigationAction.modifierFlags
|
||||
let invert = flags.contains(.shift) || flags.contains(.command)
|
||||
Browser.open(url.absoluteString, invertPreference: invert)
|
||||
}
|
||||
decisionHandler(.cancel)
|
||||
return
|
||||
|
||||
@@ -179,6 +179,10 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
public func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||
|
||||
if item.action == #selector(openArticleInBrowser(_:)) {
|
||||
if let item = item as? NSMenuItem, item.keyEquivalentModifierMask.contains(.shift) {
|
||||
item.title = Browser.titleForOpenInBrowserInverted
|
||||
}
|
||||
|
||||
return currentLink != nil
|
||||
}
|
||||
|
||||
@@ -261,7 +265,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
|
||||
@IBAction func openArticleInBrowser(_ sender: Any?) {
|
||||
if let link = currentLink {
|
||||
Browser.open(link)
|
||||
Browser.open(link, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ protocol SidebarDelegate: class {
|
||||
guard let feed = singleSelectedWebFeed, let homePageURL = feed.homePageURL else {
|
||||
return
|
||||
}
|
||||
Browser.open(homePageURL)
|
||||
Browser.open(homePageURL, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
|
||||
}
|
||||
|
||||
@IBAction func gotoToday(_ sender: Any?) {
|
||||
|
||||
@@ -297,7 +297,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
|
||||
@objc func openArticleInBrowser(_ sender: Any?) {
|
||||
if let link = oneSelectedArticle?.preferredLink {
|
||||
Browser.open(link)
|
||||
Browser.open(link, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,6 +725,10 @@ extension TimelineViewController: NSUserInterfaceValidations {
|
||||
|
||||
func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||
if item.action == #selector(openArticleInBrowser(_:)) {
|
||||
if let item = item as? NSMenuItem, item.keyEquivalentModifierMask.contains(.shift) {
|
||||
item.title = Browser.titleForOpenInBrowserInverted
|
||||
}
|
||||
|
||||
let currentLink = oneSelectedArticle?.preferredLink
|
||||
return currentLink != nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user