]> git.r.bdr.sh - rbdr/captura/blobdiff - Captura/CapturaApp.swift
Add resize, keyboard shortcuts, menu items
[rbdr/captura] / Captura / CapturaApp.swift
index 4dc65a478d25a7c8bea47f22a12ed51dbe09fca2..933e00bb4d601d84682d2f4ea01cac989f5dad9e 100644 (file)
@@ -45,10 +45,17 @@ class CapturaAppDelegate: NSObject, NSApplicationDelegate {
       statusItem.isVisible = true
       statusItem.menu = NSMenu()
       
-      let recordItem = NSMenuItem(title: "record", action: #selector(CapturaAppDelegate.onClickStartRecording), keyEquivalent: "6")
+      let recordItem = NSMenuItem(title: "Record", action: #selector(CapturaAppDelegate.onClickStartRecording), keyEquivalent: "6")
       recordItem.keyEquivalentModifierMask = [.command, .shift]
       
       statusItem.menu?.addItem(recordItem)
+      statusItem.menu?.addItem(NSMenuItem.separator())
+      
+      let preferencesItem = NSMenuItem(title: "Preferences", action: #selector(CapturaAppDelegate.onOpenPreferences), keyEquivalent: "")
+      statusItem.menu?.addItem(preferencesItem)
+      
+      let quitItem = NSMenuItem(title: "Quit", action: #selector(CapturaAppDelegate.onQuit), keyEquivalent: "")
+      statusItem.menu?.addItem(quitItem)
     }
   
     private func closeWindow() {
@@ -63,6 +70,14 @@ class CapturaAppDelegate: NSObject, NSApplicationDelegate {
       NotificationCenter.default.post(name: .startAreaSelection, object: nil, userInfo: nil)
     }
   
+    @objc private func onOpenPreferences() {
+      print("Preferences pressed")
+    }
+  
+    @objc private func onQuit() {
+      NSApplication.shared.terminate(self)
+    }
+  
   
     // MARK: - App State Event Listeners
   
@@ -93,7 +108,6 @@ class CapturaAppDelegate: NSObject, NSApplicationDelegate {
       if captureState != .selectingArea {
         captureState = .selectingArea
         recordingWindow = RecordingWindow()
-        print("Recording")
       }
     }
   
@@ -111,5 +125,7 @@ class CapturaAppDelegate: NSObject, NSApplicationDelegate {
   
     func reset() {
       captureState = .idle
+      recordingWindow?.close()
+      self.recordingWindow = nil
     }
 }