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?
|
||||
|
||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||
let wc = DatabaseWindowController()
|
||||
windowControllers.append(wc)
|
||||
wc.showWindow(nil)
|
||||
newWindow(mongoController: nil)
|
||||
}
|
||||
|
||||
func applicationWillTerminate(_ aNotification: Notification) {
|
||||
|
@ -31,7 +29,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
windowControllers.append(wc)
|
||||
|
||||
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.selectedWindow = wc.window!
|
||||
} else {
|
||||
|
|
|
@ -41,10 +41,14 @@ class DatabaseWindowController: NSWindowController {
|
|||
.receive(on: DispatchQueue.main)
|
||||
.sink { self.updateStatusText(manager: $0) }
|
||||
|
||||
if mongoController.client != nil {
|
||||
initializeUI()
|
||||
} else {
|
||||
connectionStatusChangeHandler = mongoController.$status
|
||||
.receive(on: DispatchQueue.main)
|
||||
.filter { $0 == .connected }
|
||||
.sink { (_) in self.initializeUI() }
|
||||
}
|
||||
|
||||
if setupMongo {
|
||||
mongoController.setup()
|
||||
|
@ -89,6 +93,8 @@ class DatabaseWindowController: NSWindowController {
|
|||
|
||||
private func initializeUI() {
|
||||
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
|
||||
|
||||
if let initialCollection = initialCollection {
|
||||
|
|
Loading…
Reference in New Issue