mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Support opening multiple articles in browser from main menu
Move openArticleURLs() to MainWindowController.
This commit is contained in:
@@ -340,10 +340,36 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
}
|
||||
}
|
||||
|
||||
func openArticleURLs(_ urlStrings: [String]) {
|
||||
func doOpenURLs() {
|
||||
for urlString in urlStrings {
|
||||
Browser.open(urlString, inBackground: false)
|
||||
}
|
||||
}
|
||||
|
||||
if urlStrings.count > 20 {
|
||||
let alert = NSAlert()
|
||||
let messageFormat = NSLocalizedString("Are you sure you want to open %ld articles in your browser?", comment: "")
|
||||
alert.messageText = String.localizedStringWithFormat(messageFormat, urlStrings.count)
|
||||
alert.addButton(withTitle: NSLocalizedString("Open", comment: ""))
|
||||
alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
|
||||
|
||||
guard let window = self.window else { return }
|
||||
|
||||
alert.beginSheetModal(for: window) { response in
|
||||
if response == .alertFirstButtonReturn {
|
||||
doOpenURLs()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
doOpenURLs()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func openArticleInBrowser(_ sender: Any?) {
|
||||
if let link = currentLink {
|
||||
Browser.open(link, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
|
||||
}
|
||||
guard let selectedArticles else { return }
|
||||
let urlStrings = selectedArticles.compactMap { $0.preferredLink }
|
||||
openArticleURLs(urlStrings)
|
||||
}
|
||||
|
||||
@IBAction func openInBrowser(_ sender: Any?) {
|
||||
|
||||
Reference in New Issue
Block a user