X-Git-Url: https://git.r.bdr.sh/rbdr/captura/blobdiff_plain/8e9321304ca80e9ada7ac01058a5f4603cb37fab..377442f2f1f0f08bc525393c9bd1c84f159c5159:/Captura/CapturaApp.swift diff --git a/Captura/CapturaApp.swift b/Captura/CapturaApp.swift index eb6f02e..c6ec9f0 100644 --- a/Captura/CapturaApp.swift +++ b/Captura/CapturaApp.swift @@ -39,6 +39,8 @@ class CapturaAppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { var remoteFiles: [CapturaRemoteFile] = [] var captureSessionConfiguration: CaptureSessionConfiguration = CaptureSessionConfiguration() + @objc var scriptedPreferences: ScriptedPreferences? + func applicationDidFinishLaunching(_ notification: Notification) { setupStatusBar() NotificationCenter.default.addObserver( @@ -48,6 +50,8 @@ class CapturaAppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { object: nil) closeWindow() fetchRemoteItems() + + scriptedPreferences = ScriptedPreferences() } // MARK: - Setup Functions @@ -108,7 +112,10 @@ class CapturaAppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { case let .configure(config): CapturaSettings.apply(config) case let .record(config): - captureSessionConfiguration = CaptureSessionConfiguration(from: config) + let config = CaptureSessionConfiguration(from: config) + NotificationCenter.default.post(name: .startAreaSelection, object: nil, userInfo: [ + "config": config + ]) NotificationCenter.default.post(name: .startAreaSelection, object: nil, userInfo: nil) } } @@ -196,6 +203,14 @@ class CapturaAppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { if let frame = notification.userInfo?["frame"] { receivedFrame(frame as! CVImageBuffer) } + case .reloadConfiguration: + reloadConfiguration() + case .setCaptureSessionConfiguration: + if let userInfo = notification.userInfo { + if let config = userInfo["config"] as? RecordAction { + setCaptureSessionConfiguration(config) + } + } case .NSManagedObjectContextObjectsDidChange: DispatchQueue.main.async { self.fetchRemoteItems() @@ -324,6 +339,14 @@ class CapturaAppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate { } } + func reloadConfiguration() { + self.captureSessionConfiguration = CaptureSessionConfiguration() + } + + func setCaptureSessionConfiguration(_ config: RecordAction) { + self.captureSessionConfiguration = CaptureSessionConfiguration(from: config) + } + // MARK: - CoreData private func fetchRemoteItems() {