Disable commands to add a feed or add a folder if the window is already displaying a sheet. Fix #319.
This commit is contained in:
parent
9fce370967
commit
e7ce12869c
@ -249,15 +249,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
|
|
||||||
func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||||
|
|
||||||
|
let isDisplayingSheet = mainWindowController?.isDisplayingSheet ?? false
|
||||||
|
|
||||||
if item.action == #selector(refreshAll(_:)) {
|
if item.action == #selector(refreshAll(_:)) {
|
||||||
return !AccountManager.shared.refreshInProgress
|
return !AccountManager.shared.refreshInProgress
|
||||||
}
|
}
|
||||||
if item.action == #selector(addAppNews(_:)) {
|
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(_:)) {
|
if item.action == #selector(sortByNewestArticleOnTop(_:)) || item.action == #selector(sortByOldestArticleOnTop(_:)) {
|
||||||
return mainWindowController?.isOpen ?? false
|
return mainWindowController?.isOpen ?? false
|
||||||
}
|
}
|
||||||
|
if item.action == #selector(showAddFeedWindow(_:)) || item.action == #selector(showAddFolderWindow(_:)) {
|
||||||
|
return !isDisplayingSheet
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,6 +271,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
func addFeed(_ urlString: String?, _ name: String? = nil) {
|
func addFeed(_ urlString: String?, _ name: String? = nil) {
|
||||||
|
|
||||||
createAndShowMainWindow()
|
createAndShowMainWindow()
|
||||||
|
if mainWindowController!.isDisplayingSheet {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
addFeedController = AddFeedController(hostWindow: mainWindowController!.window!)
|
addFeedController = AddFeedController(hostWindow: mainWindowController!.window!)
|
||||||
addFeedController?.showAddFeedSheet(urlString, name)
|
addFeedController?.showAddFeedSheet(urlString, name)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14087.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14087.3"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<scenes>
|
<scenes>
|
||||||
|
@ -18,6 +18,13 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
return isWindowLoaded && window!.isVisible
|
return isWindowLoaded && window!.isVisible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isDisplayingSheet: Bool {
|
||||||
|
if let _ = window?.attachedSheet {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: NSWindowController
|
// MARK: NSWindowController
|
||||||
|
|
||||||
private let windowAutosaveName = NSWindow.FrameAutosaveName(rawValue: kWindowFrameKey)
|
private let windowAutosaveName = NSWindow.FrameAutosaveName(rawValue: kWindowFrameKey)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user