Reopen the Inspector window at launch if it was open on quit.
This commit is contained in:
parent
a7a2eabf78
commit
5a75d39b7c
|
@ -138,6 +138,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
self.unreadCount = AccountManager.shared.unreadCount
|
||||
}
|
||||
|
||||
if InspectorWindowController.shouldOpenAtStartup {
|
||||
DispatchQueue.main.async {
|
||||
self.toggleInspectorWindow(self)
|
||||
}
|
||||
}
|
||||
|
||||
#if RELEASE
|
||||
DispatchQueue.main.async {
|
||||
self.refreshAll(self)
|
||||
|
@ -159,6 +165,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
RSMultiLineRenderer.emptyCache()
|
||||
TimelineCellData.emptyCache()
|
||||
timelineEmptyCaches()
|
||||
|
||||
saveState()
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ notification: Notification) {
|
||||
|
||||
saveState()
|
||||
}
|
||||
|
||||
// MARK: GetURL Apple Event
|
||||
|
@ -444,4 +457,11 @@ private extension AppDelegate {
|
|||
}
|
||||
return windowController.selectedObjectsInSidebar()
|
||||
}
|
||||
|
||||
func saveState() {
|
||||
|
||||
if let inspectorWindowController = inspectorWindowController {
|
||||
inspectorWindowController.saveState()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,23 @@ typealias InspectorViewController = Inspector & NSViewController
|
|||
|
||||
final class InspectorWindowController: NSWindowController {
|
||||
|
||||
class var shouldOpenAtStartup: Bool {
|
||||
return UserDefaults.standard.bool(forKey: DefaultsKey.windowIsOpen)
|
||||
}
|
||||
|
||||
var objects: [Any]? {
|
||||
didSet {
|
||||
let _ = window
|
||||
currentInspector = inspector(for: objects)
|
||||
}
|
||||
}
|
||||
|
||||
var isOpen: Bool {
|
||||
get {
|
||||
return isWindowLoaded && window!.isVisible
|
||||
}
|
||||
}
|
||||
|
||||
private var inspectors: [InspectorViewController]!
|
||||
|
||||
private var currentInspector: InspectorViewController! {
|
||||
|
@ -40,17 +57,9 @@ final class InspectorWindowController: NSWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
var objects: [Any]? {
|
||||
didSet {
|
||||
let _ = window
|
||||
currentInspector = inspector(for: objects)
|
||||
}
|
||||
}
|
||||
|
||||
var isOpen: Bool {
|
||||
get {
|
||||
return isWindowLoaded && window!.isVisible
|
||||
}
|
||||
private struct DefaultsKey {
|
||||
static let windowIsOpen = "FloatingInspectorIsOpen"
|
||||
static let windowOrigin = "FloatingInspectorOrigin"
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
|
@ -83,6 +92,14 @@ final class InspectorWindowController: NSWindowController {
|
|||
|
||||
return fallbackInspector!
|
||||
}
|
||||
|
||||
func saveState() {
|
||||
|
||||
UserDefaults.standard.set(isOpen, forKey: DefaultsKey.windowIsOpen)
|
||||
if isOpen, let window = window, let flippedOrigin = window.flippedOrigin {
|
||||
UserDefaults.standard.set(NSStringFromPoint(flippedOrigin), forKey: DefaultsKey.windowOrigin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension InspectorWindowController {
|
||||
|
|
Loading…
Reference in New Issue