-
Notifications
You must be signed in to change notification settings - Fork 398
Expand file tree
/
Copy pathMainWindow.swift
More file actions
45 lines (36 loc) · 1.09 KB
/
MainWindow.swift
File metadata and controls
45 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// MainWindow.swift
// Postgres
//
// Created by Chris on 22/06/16.
// Copyright © 2016 postgresapp. All rights reserved.
//
import Cocoa
class MainWindowController: NSWindowController, NSWindowDelegate {
@objc dynamic var mainWindowModel: MainWindowModel! {
didSet {
func propagate(_ mainWindowModel: MainWindowModel, toChildrenOf parent: NSViewController) {
if var consumer = parent as? MainWindowModelConsumer {
consumer.mainWindowModel = mainWindowModel
}
for child in parent.children {
propagate(mainWindowModel, toChildrenOf: child)
}
}
propagate(mainWindowModel, toChildrenOf: self.contentViewController!)
}
}
override func windowDidLoad() {
super.windowDidLoad()
guard let window = self.window else { return }
window.titleVisibility = .hidden
window.styleMask = [window.styleMask, .fullSizeContentView]
window.titlebarAppearsTransparent = true
window.isMovableByWindowBackground = true
let model = MainWindowModel()
mainWindowModel = model
}
func windowWillClose(_ notification: Notification) {
NSApp.terminate(nil)
}
}