Fix window size resetting on new tab
This commit is contained in:
parent
31962b43a3
commit
1ab9d53006
|
@ -16,9 +16,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
var serverConnectWindowController: ServerConnectWindowController?
|
var serverConnectWindowController: ServerConnectWindowController?
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
let wc = DatabaseWindowController()
|
newWindow(mongoController: nil)
|
||||||
windowControllers.append(wc)
|
|
||||||
wc.showWindow(nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func applicationWillTerminate(_ aNotification: Notification) {
|
func applicationWillTerminate(_ aNotification: Notification) {
|
||||||
|
@ -31,7 +29,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
windowControllers.append(wc)
|
windowControllers.append(wc)
|
||||||
|
|
||||||
if addToTabGroup,
|
if addToTabGroup,
|
||||||
let tabGroup = windowControllers.first(where: { $0.window!.isKeyWindow })?.window?.tabGroup {
|
let existing = windowControllers.first(where: { $0.window!.isKeyWindow })?.window,
|
||||||
|
let tabGroup = existing.tabGroup {
|
||||||
tabGroup.addWindow(wc.window!)
|
tabGroup.addWindow(wc.window!)
|
||||||
tabGroup.selectedWindow = wc.window!
|
tabGroup.selectedWindow = wc.window!
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -41,10 +41,14 @@ class DatabaseWindowController: NSWindowController {
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.sink { self.updateStatusText(manager: $0) }
|
.sink { self.updateStatusText(manager: $0) }
|
||||||
|
|
||||||
connectionStatusChangeHandler = mongoController.$status
|
if mongoController.client != nil {
|
||||||
.receive(on: DispatchQueue.main)
|
initializeUI()
|
||||||
.filter { $0 == .connected }
|
} else {
|
||||||
.sink { (_) in self.initializeUI() }
|
connectionStatusChangeHandler = mongoController.$status
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.filter { $0 == .connected }
|
||||||
|
.sink { (_) in self.initializeUI() }
|
||||||
|
}
|
||||||
|
|
||||||
if setupMongo {
|
if setupMongo {
|
||||||
mongoController.setup()
|
mongoController.setup()
|
||||||
|
@ -89,8 +93,10 @@ class DatabaseWindowController: NSWindowController {
|
||||||
|
|
||||||
private func initializeUI() {
|
private func initializeUI() {
|
||||||
databaseViewController = DatabaseViewController(mongoController: mongoController)
|
databaseViewController = DatabaseViewController(mongoController: mongoController)
|
||||||
|
// otherwise the VC size uses the size from the nib, potentially changing the window size
|
||||||
|
databaseViewController.view.frame = CGRect(origin: .zero, size: window!.frame.size)
|
||||||
contentViewController = databaseViewController
|
contentViewController = databaseViewController
|
||||||
|
|
||||||
if let initialCollection = initialCollection {
|
if let initialCollection = initialCollection {
|
||||||
databaseViewController.showCollection(initialCollection)
|
databaseViewController.showCollection(initialCollection)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue