Update status label color immediately

This commit is contained in:
1024jp 2019-10-27 13:08:39 +09:00
parent e956d1167d
commit a478851781
2 changed files with 22 additions and 0 deletions

View File

@ -2,6 +2,15 @@
Change Log
==========================
3.8.5 (unreleased)
--------------------------
### Fixes
- Fix an issue where the label color in the status bar was sometimes not updated immediately after switching window apperance.
3.8.4 (381)
--------------------------

View File

@ -32,6 +32,9 @@ final class StatusBarController: NSViewController {
private var defaultsObservers: [UserDefaultsObservation] = []
private let byteCountFormatter = ByteCountFormatter()
@available(macOS, deprecated: 10.15)
private var appearanceObserver: NSKeyValueObservation?
@objc private dynamic var editorStatus: NSAttributedString?
@objc private dynamic var documentStatus: NSAttributedString?
@objc private dynamic var showsReadOnly = false
@ -43,6 +46,7 @@ final class StatusBarController: NSViewController {
deinit {
self.defaultsObservers.forEach { $0.invalidate() }
self.appearanceObserver?.invalidate()
}
@ -95,6 +99,13 @@ final class StatusBarController: NSViewController {
self.documentAnalyzer?.needsUpdateStatusEditorInfo = true
self.documentAnalyzer?.invalidateEditorInfo()
if #available(macOS 10.15, *) { } else {
self.appearanceObserver?.invalidate()
self.appearanceObserver = self.view.observe(\.effectiveAppearance) { [weak self] (_, _) in
self?.updateEditorStatus()
}
}
}
@ -104,6 +115,8 @@ final class StatusBarController: NSViewController {
super.viewDidDisappear()
self.documentAnalyzer?.needsUpdateStatusEditorInfo = false
self.appearanceObserver?.invalidate()
}