Make shift key invert the "open in background" preference
- Also add an appropriate menu item.
This commit is contained in:
parent
314df88e12
commit
e79cafc82e
@ -496,6 +496,12 @@
|
|||||||
<action selector="openArticleInBrowser:" target="Ady-hI-5gd" id="KeH-ES-fpo"/>
|
<action selector="openArticleInBrowser:" target="Ady-hI-5gd" id="KeH-ES-fpo"/>
|
||||||
</connections>
|
</connections>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
|
<menuItem title="Open in Browser Inverted" alternate="YES" keyEquivalent="" id="EjD-X9-Pjf">
|
||||||
|
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="openArticleInBrowser:" target="Ady-hI-5gd" id="Frq-Uo-DQs"/>
|
||||||
|
</connections>
|
||||||
|
</menuItem>
|
||||||
</items>
|
</items>
|
||||||
</menu>
|
</menu>
|
||||||
</menuItem>
|
</menuItem>
|
||||||
|
@ -6,14 +6,16 @@
|
|||||||
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import AppKit
|
||||||
import RSWeb
|
import RSWeb
|
||||||
|
|
||||||
struct Browser {
|
struct Browser {
|
||||||
|
|
||||||
static func open(_ urlString: String) {
|
static func open(_ urlString: String) {
|
||||||
|
let shouldInvertPreference = NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false
|
||||||
|
|
||||||
// Opens according to prefs.
|
// Opens according to prefs.
|
||||||
open(urlString, inBackground: AppDefaults.openInBrowserInBackground)
|
open(urlString, inBackground: shouldInvertPreference ? !AppDefaults.openInBrowserInBackground : AppDefaults.openInBrowserInBackground)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func open(_ urlString: String, inBackground: Bool) {
|
static func open(_ urlString: String, inBackground: Bool) {
|
||||||
@ -23,3 +25,13 @@ struct Browser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension Browser {
|
||||||
|
|
||||||
|
static var titleForOpenInBrowserInverted: String {
|
||||||
|
let openInBackgroundPref = AppDefaults.openInBrowserInBackground
|
||||||
|
|
||||||
|
return openInBackgroundPref ?
|
||||||
|
NSLocalizedString("Open in Browser in Foreground", comment: "Open in Browser in Foreground menu item title") :
|
||||||
|
NSLocalizedString("Open in Browser in Background", comment: "Open in Browser in Background menu item title")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -179,6 +179,10 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
public func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
public func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||||
|
|
||||||
if item.action == #selector(openArticleInBrowser(_:)) {
|
if item.action == #selector(openArticleInBrowser(_:)) {
|
||||||
|
if let item = item as? NSMenuItem, item.keyEquivalentModifierMask.contains(.shift) {
|
||||||
|
item.title = Browser.titleForOpenInBrowserInverted
|
||||||
|
}
|
||||||
|
|
||||||
return currentLink != nil
|
return currentLink != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,6 +725,10 @@ extension TimelineViewController: NSUserInterfaceValidations {
|
|||||||
|
|
||||||
func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||||
if item.action == #selector(openArticleInBrowser(_:)) {
|
if item.action == #selector(openArticleInBrowser(_:)) {
|
||||||
|
if let item = item as? NSMenuItem, item.keyEquivalentModifierMask.contains(.shift) {
|
||||||
|
item.title = Browser.titleForOpenInBrowserInverted
|
||||||
|
}
|
||||||
|
|
||||||
let currentLink = oneSelectedArticle?.preferredLink
|
let currentLink = oneSelectedArticle?.preferredLink
|
||||||
return currentLink != nil
|
return currentLink != nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user