mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
💄 Adds images to sidebar menu items
This commit is contained in:
@@ -76,6 +76,14 @@ struct AppAssets {
|
||||
static var cleanUpImage: RSImage = {
|
||||
return NSImage(systemSymbolName: "wind", accessibilityDescription: nil)!
|
||||
}()
|
||||
|
||||
static var copyImage: RSImage = {
|
||||
return NSImage(systemSymbolName: "document.on.document", accessibilityDescription: nil)!
|
||||
}()
|
||||
|
||||
static var deleteImage: RSImage = {
|
||||
return NSImage(systemSymbolName: "xmark.bin", accessibilityDescription: nil)!
|
||||
}()
|
||||
|
||||
static var marsEditIcon: RSImage = {
|
||||
return RSImage(named: "MarsEditIcon")!
|
||||
@@ -143,8 +151,15 @@ struct AppAssets {
|
||||
return IconImage(image, isSymbol: true, isBackgroundSuppressed: true, preferredColor: preferredColor.cgColor)
|
||||
}
|
||||
|
||||
|
||||
static var markAllAsReadMenuImage: RSImage = {
|
||||
let image = RSImage(named: "markAllAsRead")
|
||||
return image!
|
||||
}()
|
||||
|
||||
static var markAllAsReadImage: RSImage = {
|
||||
return RSImage(named: "markAllAsRead")!
|
||||
let image = RSImage(named: "markAllAsRead")
|
||||
return image!
|
||||
}()
|
||||
|
||||
|
||||
@@ -152,6 +167,9 @@ struct AppAssets {
|
||||
return NSImage(systemSymbolName: "chevron.down.circle", accessibilityDescription: nil)!
|
||||
}()
|
||||
|
||||
static var notificationImage: RSImage = {
|
||||
return NSImage(systemSymbolName: "bell.badge", accessibilityDescription: nil)!
|
||||
}()
|
||||
|
||||
static var openInBrowserImage: RSImage = {
|
||||
return NSImage(systemSymbolName: "safari", accessibilityDescription: nil)!
|
||||
@@ -184,6 +202,10 @@ struct AppAssets {
|
||||
return NSImage(systemSymbolName: "arrow.clockwise", accessibilityDescription: nil)!
|
||||
}()
|
||||
|
||||
static var renameImage: RSImage = {
|
||||
return NSImage(systemSymbolName: "pencil", accessibilityDescription: nil)!
|
||||
}()
|
||||
|
||||
static var searchFeedImage: IconImage = {
|
||||
return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isSymbol: true, isBackgroundSuppressed: true)
|
||||
}()
|
||||
|
||||
@@ -216,23 +216,23 @@ private extension SidebarViewController {
|
||||
}
|
||||
|
||||
if let homePageURL = webFeed.homePageURL, let _ = URL(string: homePageURL) {
|
||||
let item = menuItem(NSLocalizedString("Open Home Page", comment: "Command"), #selector(openHomePageFromContextualMenu(_:)), homePageURL)
|
||||
let item = menuItem(NSLocalizedString("Open Home Page", comment: "Command"), #selector(openHomePageFromContextualMenu(_:)), homePageURL, image: AppAssets.openInBrowserImage)
|
||||
menu.addItem(item)
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
}
|
||||
|
||||
let copyFeedURLItem = menuItem(NSLocalizedString("Copy Feed URL", comment: "Command"), #selector(copyURLFromContextualMenu(_:)), webFeed.url)
|
||||
let copyFeedURLItem = menuItem(NSLocalizedString("Copy Feed URL", comment: "Command"), #selector(copyURLFromContextualMenu(_:)), webFeed.url, image: AppAssets.copyImage)
|
||||
menu.addItem(copyFeedURLItem)
|
||||
|
||||
if let homePageURL = webFeed.homePageURL {
|
||||
let item = menuItem(NSLocalizedString("Copy Home Page URL", comment: "Command"), #selector(copyURLFromContextualMenu(_:)), homePageURL)
|
||||
let item = menuItem(NSLocalizedString("Copy Home Page URL", comment: "Command"), #selector(copyURLFromContextualMenu(_:)), homePageURL, image: AppAssets.copyImage)
|
||||
menu.addItem(item)
|
||||
}
|
||||
menu.addItem(NSMenuItem.separator())
|
||||
|
||||
let notificationText = webFeed.notificationDisplayName.capitalized
|
||||
|
||||
let notificationMenuItem = menuItem(notificationText, #selector(toggleNotificationsFromContextMenu(_:)), webFeed)
|
||||
let notificationMenuItem = menuItem(notificationText, #selector(toggleNotificationsFromContextMenu(_:)), webFeed, image: AppAssets.notificationImage)
|
||||
if webFeed.isNotifyAboutNewArticles == nil || webFeed.isNotifyAboutNewArticles! == false {
|
||||
notificationMenuItem.state = .off
|
||||
} else {
|
||||
@@ -241,7 +241,7 @@ private extension SidebarViewController {
|
||||
menu.addItem(notificationMenuItem)
|
||||
|
||||
let articleExtractorText = NSLocalizedString("Always Use Reader View", comment: "Always Use Reader View")
|
||||
let articleExtractorMenuItem = menuItem(articleExtractorText, #selector(toggleArticleExtractorFromContextMenu(_:)), webFeed)
|
||||
let articleExtractorMenuItem = menuItem(articleExtractorText, #selector(toggleArticleExtractorFromContextMenu(_:)), webFeed, image: AppAssets.articleExtractorOff)
|
||||
|
||||
if webFeed.isArticleExtractorAlwaysOn == nil || webFeed.isArticleExtractorAlwaysOn! == false {
|
||||
articleExtractorMenuItem.state = .off
|
||||
@@ -301,17 +301,17 @@ private extension SidebarViewController {
|
||||
|
||||
func markAllReadMenuItem(_ objects: [Any]) -> NSMenuItem {
|
||||
|
||||
return menuItem(NSLocalizedString("Mark All as Read", comment: "Command"), #selector(markObjectsReadFromContextualMenu(_:)), objects)
|
||||
return menuItem(NSLocalizedString("Mark All as Read", comment: "Command"), #selector(markObjectsReadFromContextualMenu(_:)), objects, image: AppAssets.markAllAsReadMenuImage)
|
||||
}
|
||||
|
||||
func deleteMenuItem(_ objects: [Any]) -> NSMenuItem {
|
||||
|
||||
return menuItem(NSLocalizedString("Delete", comment: "Command"), #selector(deleteFromContextualMenu(_:)), objects)
|
||||
return menuItem(NSLocalizedString("Delete", comment: "Command"), #selector(deleteFromContextualMenu(_:)), objects, image: AppAssets.deleteImage)
|
||||
}
|
||||
|
||||
func renameMenuItem(_ object: Any) -> NSMenuItem {
|
||||
|
||||
return menuItem(NSLocalizedString("Rename", comment: "Command"), #selector(renameFromContextualMenu(_:)), object)
|
||||
return menuItem(NSLocalizedString("Rename", comment: "Command"), #selector(renameFromContextualMenu(_:)), object, image: AppAssets.renameImage)
|
||||
}
|
||||
|
||||
func anyObjectInArrayHasNonZeroUnreadCount(_ objects: [Any]) -> Bool {
|
||||
@@ -341,11 +341,14 @@ private extension SidebarViewController {
|
||||
return object is WebFeed || object is Folder
|
||||
}
|
||||
|
||||
func menuItem(_ title: String, _ action: Selector, _ representedObject: Any) -> NSMenuItem {
|
||||
func menuItem(_ title: String, _ action: Selector, _ representedObject: Any, image: RSImage?) -> NSMenuItem {
|
||||
|
||||
let item = NSMenuItem(title: title, action: action, keyEquivalent: "")
|
||||
item.representedObject = representedObject
|
||||
item.target = self
|
||||
if let image {
|
||||
item.image = image
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user