diff --git a/Evergreen/AppDelegate.swift b/Evergreen/AppDelegate.swift index 1c9567e92..9ac432399 100644 --- a/Evergreen/AppDelegate.swift +++ b/Evergreen/AppDelegate.swift @@ -101,6 +101,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, addFolderWindowController!.runSheetOnWindow(window) } + func showAddFeedSheetOnWindow(_ window: NSWindow, urlString: String?, name: String?) { + + addFeedController = AddFeedController(hostWindow: window) + addFeedController?.showAddFeedSheet(urlString, name) + } + // MARK: - NSApplicationDelegate func applicationDidFinishLaunching(_ note: Notification) { @@ -275,8 +281,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, return } - addFeedController = AddFeedController(hostWindow: mainWindowController!.window!) - addFeedController?.showAddFeedSheet(urlString, name) + showAddFeedSheetOnWindow(mainWindowController!.window!, urlString: urlString, name: name) } // MARK: - Actions diff --git a/Evergreen/MainWindow/ContextualMenus/MainWindowController+ContextualMenus.swift b/Evergreen/MainWindow/ContextualMenus/MainWindowController+ContextualMenus.swift index 4a0a99885..2f6253210 100644 --- a/Evergreen/MainWindow/ContextualMenus/MainWindowController+ContextualMenus.swift +++ b/Evergreen/MainWindow/ContextualMenus/MainWindowController+ContextualMenus.swift @@ -16,7 +16,7 @@ extension MainWindowController { func menu(for objects: [Any]?) -> NSMenu? { guard let objects = objects, objects.count > 0 else { - return nil + return menuForNoSelection() } if objects.count == 1 { @@ -55,6 +55,7 @@ extension MainWindowController { @objc func markObjectsReadFromContextualMenu(_ sender: Any?) { + } @objc func deleteFromContextualMenu(_ sender: Any?) { @@ -92,6 +93,16 @@ extension MainWindowController: RenameWindowControllerDelegate { 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? { let menu = NSMenu(title: "") diff --git a/Evergreen/MainWindow/MainWindowController.swift b/Evergreen/MainWindow/MainWindowController.swift index 654a8f115..cd9c5402d 100644 --- a/Evergreen/MainWindow/MainWindowController.swift +++ b/Evergreen/MainWindow/MainWindowController.swift @@ -177,7 +177,12 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { appDelegate.showAddFolderSheetOnWindow(window!) } - + + @IBAction func showAddFeedWindow(_ sender: Any) { + + appDelegate.showAddFeedSheetOnWindow(window!, urlString: nil, name: nil) + } + @IBAction func openArticleInBrowser(_ sender: Any?) { if let link = currentLink {