From e7ce12869c0a15d0bdaa67e7c0b7c1da0ec399d3 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 3 Feb 2018 10:56:12 -0800 Subject: [PATCH] Disable commands to add a feed or add a folder if the window is already displaying a sheet. Fix #319. --- Evergreen/AppDelegate.swift | 10 +++++++++- Evergreen/Base.lproj/MainWindow.storyboard | 4 ++-- Evergreen/MainWindow/MainWindowController.swift | 7 +++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Evergreen/AppDelegate.swift b/Evergreen/AppDelegate.swift index 36f04da16..1c9567e92 100644 --- a/Evergreen/AppDelegate.swift +++ b/Evergreen/AppDelegate.swift @@ -249,15 +249,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool { + let isDisplayingSheet = mainWindowController?.isDisplayingSheet ?? false + if item.action == #selector(refreshAll(_:)) { return !AccountManager.shared.refreshInProgress } if item.action == #selector(addAppNews(_:)) { - return !AccountManager.shared.anyAccountHasFeedWithURL(appNewsURLString) + return !isDisplayingSheet && !AccountManager.shared.anyAccountHasFeedWithURL(appNewsURLString) } if item.action == #selector(sortByNewestArticleOnTop(_:)) || item.action == #selector(sortByOldestArticleOnTop(_:)) { return mainWindowController?.isOpen ?? false } + if item.action == #selector(showAddFeedWindow(_:)) || item.action == #selector(showAddFolderWindow(_:)) { + return !isDisplayingSheet + } return true } @@ -266,6 +271,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, func addFeed(_ urlString: String?, _ name: String? = nil) { createAndShowMainWindow() + if mainWindowController!.isDisplayingSheet { + return + } addFeedController = AddFeedController(hostWindow: mainWindowController!.window!) addFeedController?.showAddFeedSheet(urlString, name) diff --git a/Evergreen/Base.lproj/MainWindow.storyboard b/Evergreen/Base.lproj/MainWindow.storyboard index 49801d380..a2232733d 100644 --- a/Evergreen/Base.lproj/MainWindow.storyboard +++ b/Evergreen/Base.lproj/MainWindow.storyboard @@ -1,7 +1,7 @@ - + - + diff --git a/Evergreen/MainWindow/MainWindowController.swift b/Evergreen/MainWindow/MainWindowController.swift index c31e811d2..fc3710bef 100644 --- a/Evergreen/MainWindow/MainWindowController.swift +++ b/Evergreen/MainWindow/MainWindowController.swift @@ -18,6 +18,13 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { return isWindowLoaded && window!.isVisible } + var isDisplayingSheet: Bool { + if let _ = window?.attachedSheet { + return true + } + return false + } + // MARK: NSWindowController private let windowAutosaveName = NSWindow.FrameAutosaveName(rawValue: kWindowFrameKey)