Add new-feed and new-folder commands to the sidebar gear menu when there’s no selection.
This commit is contained in:
parent
68d0885b0d
commit
27c5ffa5eb
@ -101,6 +101,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
addFolderWindowController!.runSheetOnWindow(window)
|
addFolderWindowController!.runSheetOnWindow(window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func showAddFeedSheetOnWindow(_ window: NSWindow, urlString: String?, name: String?) {
|
||||||
|
|
||||||
|
addFeedController = AddFeedController(hostWindow: window)
|
||||||
|
addFeedController?.showAddFeedSheet(urlString, name)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - NSApplicationDelegate
|
// MARK: - NSApplicationDelegate
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ note: Notification) {
|
func applicationDidFinishLaunching(_ note: Notification) {
|
||||||
@ -275,8 +281,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
addFeedController = AddFeedController(hostWindow: mainWindowController!.window!)
|
showAddFeedSheetOnWindow(mainWindowController!.window!, urlString: urlString, name: name)
|
||||||
addFeedController?.showAddFeedSheet(urlString, name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Actions
|
// MARK: - Actions
|
||||||
|
@ -16,7 +16,7 @@ extension MainWindowController {
|
|||||||
func menu(for objects: [Any]?) -> NSMenu? {
|
func menu(for objects: [Any]?) -> NSMenu? {
|
||||||
|
|
||||||
guard let objects = objects, objects.count > 0 else {
|
guard let objects = objects, objects.count > 0 else {
|
||||||
return nil
|
return menuForNoSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
if objects.count == 1 {
|
if objects.count == 1 {
|
||||||
@ -55,6 +55,7 @@ extension MainWindowController {
|
|||||||
|
|
||||||
@objc func markObjectsReadFromContextualMenu(_ sender: Any?) {
|
@objc func markObjectsReadFromContextualMenu(_ sender: Any?) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func deleteFromContextualMenu(_ sender: Any?) {
|
@objc func deleteFromContextualMenu(_ sender: Any?) {
|
||||||
@ -92,6 +93,16 @@ extension MainWindowController: RenameWindowControllerDelegate {
|
|||||||
|
|
||||||
private extension MainWindowController {
|
private extension MainWindowController {
|
||||||
|
|
||||||
|
func menuForNoSelection() -> NSMenu {
|
||||||
|
|
||||||
|
let menu = NSMenu(title: "")
|
||||||
|
|
||||||
|
menu.addItem(withTitle: NSLocalizedString("New Feed", comment: "Command"), action: #selector(showAddFeedWindow(_:)), keyEquivalent: "")
|
||||||
|
menu.addItem(withTitle: NSLocalizedString("New Folder", comment: "Command"), action: #selector(showAddFolderWindow(_:)), keyEquivalent: "")
|
||||||
|
|
||||||
|
return menu
|
||||||
|
}
|
||||||
|
|
||||||
func menuForFeed(_ feed: Feed) -> NSMenu? {
|
func menuForFeed(_ feed: Feed) -> NSMenu? {
|
||||||
|
|
||||||
let menu = NSMenu(title: "")
|
let menu = NSMenu(title: "")
|
||||||
|
@ -178,6 +178,11 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
appDelegate.showAddFolderSheetOnWindow(window!)
|
appDelegate.showAddFolderSheetOnWindow(window!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func showAddFeedWindow(_ sender: Any) {
|
||||||
|
|
||||||
|
appDelegate.showAddFeedSheetOnWindow(window!, urlString: nil, name: nil)
|
||||||
|
}
|
||||||
|
|
||||||
@IBAction func openArticleInBrowser(_ sender: Any?) {
|
@IBAction func openArticleInBrowser(_ sender: Any?) {
|
||||||
|
|
||||||
if let link = currentLink {
|
if let link = currentLink {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user