Add Mark All as Read contextual menu item. Issue #657
This commit is contained in:
parent
af19b6dee0
commit
0da916fa68
|
@ -7,6 +7,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import RSCore
|
||||||
import Articles
|
import Articles
|
||||||
import Account
|
import Account
|
||||||
|
|
||||||
|
@ -84,6 +85,10 @@ extension TimelineViewController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func markAllAsRead(_ sender: Any?) {
|
||||||
|
markAllAsRead()
|
||||||
|
}
|
||||||
|
|
||||||
@objc func openInBrowserFromContextualMenu(_ sender: Any?) {
|
@objc func openInBrowserFromContextualMenu(_ sender: Any?) {
|
||||||
|
|
||||||
guard let menuItem = sender as? NSMenuItem, let urlString = menuItem.representedObject as? String else {
|
guard let menuItem = sender as? NSMenuItem, let urlString = menuItem.representedObject as? String else {
|
||||||
|
@ -162,7 +167,11 @@ private extension TimelineViewController {
|
||||||
menu.addSeparatorIfNeeded()
|
menu.addSeparatorIfNeeded()
|
||||||
|
|
||||||
if articles.count == 1, let feed = articles.first!.feed {
|
if articles.count == 1, let feed = articles.first!.feed {
|
||||||
menu.addItem(selectFeedInSidebar(feed))
|
menu.addItem(selectFeedInSidebarMenuItem(feed))
|
||||||
|
}
|
||||||
|
|
||||||
|
if let markAllMenuItem = markAllAsReadMenuItem() {
|
||||||
|
menu.addItem(markAllMenuItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
if articles.count == 1, let link = articles.first!.preferredLink {
|
if articles.count == 1, let link = articles.first!.preferredLink {
|
||||||
|
@ -231,9 +240,26 @@ private extension TimelineViewController {
|
||||||
return menuItem(NSLocalizedString("Mark Older as Read", comment: "Command"), #selector(markOlderArticlesReadFromContextualMenu(_:)), articles)
|
return menuItem(NSLocalizedString("Mark Older as Read", comment: "Command"), #selector(markOlderArticlesReadFromContextualMenu(_:)), articles)
|
||||||
}
|
}
|
||||||
|
|
||||||
func selectFeedInSidebar(_ feed: Feed) -> NSMenuItem {
|
func selectFeedInSidebarMenuItem(_ feed: Feed) -> NSMenuItem {
|
||||||
let menuText = "Select “\(feed.nameForDisplay)” in Sidebar"
|
let localizedMenuText = NSLocalizedString("Select \"%@\" in Sidebar", comment: "Command")
|
||||||
return menuItem(NSLocalizedString(menuText, comment: "Command"), #selector(selectFeedInSidebarFromContextualMenu(_:)), feed)
|
let formattedMenuText = NSString.localizedStringWithFormat(localizedMenuText as NSString, feed.nameForDisplay)
|
||||||
|
return menuItem(formattedMenuText as String, #selector(selectFeedInSidebarFromContextualMenu(_:)), feed)
|
||||||
|
}
|
||||||
|
|
||||||
|
func markAllAsReadMenuItem() -> NSMenuItem? {
|
||||||
|
guard canMarkAllAsRead() else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
let menuText: String
|
||||||
|
if representedObjects?.count == 1, let nameProvider = representedObjects!.first! as? DisplayNameProvider {
|
||||||
|
let localizedMenuText = NSLocalizedString("Mark All as Read in \"%@\"", comment: "Command")
|
||||||
|
menuText = NSString.localizedStringWithFormat(localizedMenuText as NSString, nameProvider.nameForDisplay) as String
|
||||||
|
} else {
|
||||||
|
menuText = NSLocalizedString("Mark All as Read in Timeline", comment: "Command")
|
||||||
|
}
|
||||||
|
|
||||||
|
return menuItem(menuText, #selector(markAllAsRead(_:)), representedObjects as Any)
|
||||||
}
|
}
|
||||||
|
|
||||||
func openInBrowserMenuItem(_ urlString: String) -> NSMenuItem {
|
func openInBrowserMenuItem(_ urlString: String) -> NSMenuItem {
|
||||||
|
|
Loading…
Reference in New Issue