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) }
|
||||||
|
|
||||||
|
if mongoController.client != nil {
|
||||||
|
initializeUI()
|
||||||
|
} else {
|
||||||
connectionStatusChangeHandler = mongoController.$status
|
connectionStatusChangeHandler = mongoController.$status
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.filter { $0 == .connected }
|
.filter { $0 == .connected }
|
||||||
.sink { (_) in self.initializeUI() }
|
.sink { (_) in self.initializeUI() }
|
||||||
|
}
|
||||||
|
|
||||||
if setupMongo {
|
if setupMongo {
|
||||||
mongoController.setup()
|
mongoController.setup()
|
||||||
|
@ -89,6 +93,8 @@ 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 {
|
||||||
|
|
Loading…
Reference in New Issue