Merge pull request #2403 from AngeloStavrow/2354-match-window-title-to-inspector

Set window title based on type of Inspector being shown
This commit is contained in:
Maurice Parker 2020-09-08 13:08:37 -05:00 committed by GitHub
commit fae8394791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 2 deletions

View File

@ -26,6 +26,7 @@ final class BuiltinSmartFeedInspectorViewController: NSViewController, Inspector
updateSmartFeed()
}
}
var windowTitle: String = NSLocalizedString("Smart Feed Inspector", comment: "Smart Feed Inspector window title")
func canInspect(_ objects: [Any]) -> Bool {
@ -62,5 +63,6 @@ private extension BuiltinSmartFeedInspectorViewController {
func updateUI() {
nameTextField?.stringValue = smartFeed?.nameForDisplay ?? ""
windowTitle = smartFeed?.nameForDisplay ?? NSLocalizedString("Smart Feed Inspector", comment: "Smart Feed Inspector window title")
}
}

View File

@ -30,6 +30,7 @@ final class FolderInspectorViewController: NSViewController, Inspector {
updateFolder()
}
}
var windowTitle: String = NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title")
func canInspect(_ objects: [Any]) -> Bool {
@ -103,5 +104,6 @@ private extension FolderInspectorViewController {
if nameTextField.stringValue != name {
nameTextField.stringValue = name
}
windowTitle = folder?.nameForDisplay ?? NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title")
}
}

View File

@ -12,6 +12,7 @@ protocol Inspector: class {
var objects: [Any]? { get set }
var isFallbackInspector: Bool { get } // Can handle nothing-to-inspect or unexpected type of objects.
var windowTitle: String { get }
func canInspect(_ objects: [Any]) -> Bool
}
@ -62,6 +63,7 @@ final class InspectorWindowController: NSWindowController {
inspectors = [feedInspector, folderInspector, builtinSmartFeedInspector, nothingInspector]
currentInspector = nothingInspector
window?.title = currentInspector.windowTitle
if let savedOrigin = originFromDefaults() {
window?.setFlippedOriginAdjustingForScreen(savedOrigin)
@ -108,7 +110,11 @@ private extension InspectorWindowController {
guard let window = window else {
return
}
DispatchQueue.main.async {
window.title = inspector.windowTitle
}
let flippedOrigin = window.flippedOrigin
if window.contentViewController != inspector {

View File

@ -19,6 +19,7 @@ final class NothingInspectorViewController: NSViewController, Inspector {
updateTextFields()
}
}
var windowTitle: String = NSLocalizedString("Inspector", comment: "Inspector window title")
func canInspect(_ objects: [Any]) -> Bool {

View File

@ -38,6 +38,7 @@ final class WebFeedInspectorViewController: NSViewController, Inspector {
updateFeed()
}
}
var windowTitle: String = NSLocalizedString("Feed Inspector", comment: "Feed Inspector window title")
func canInspect(_ objects: [Any]) -> Bool {
return objects.count == 1 && objects.first is WebFeed
@ -112,6 +113,7 @@ extension WebFeedInspectorViewController: NSTextFieldDelegate {
return
}
feed.editedName = nameTextField.stringValue
windowTitle = feed.editedName ?? NSLocalizedString("Feed Inspector", comment: "Feed Inspector window title")
}
}
@ -133,7 +135,7 @@ private extension WebFeedInspectorViewController {
updateFeedURL()
updateNotifyAboutNewArticles()
updateIsReaderViewAlwaysOn()
windowTitle = feed?.nameForDisplay ?? NSLocalizedString("Feed Inspector", comment: "Feed Inspector window title")
view.needsLayout = true
}