Remove testing pasteboard code.
This commit is contained in:
@@ -2,41 +2,6 @@ import Cocoa
|
|||||||
import Carbon
|
import Carbon
|
||||||
import ServiceManagement
|
import ServiceManagement
|
||||||
|
|
||||||
class ClipboardMonitor {
|
|
||||||
private var timer: Timer?
|
|
||||||
private var lastChangeCount: Int = NSPasteboard.general.changeCount
|
|
||||||
|
|
||||||
func startMonitoring(interval: TimeInterval = 0.5) {
|
|
||||||
timer = Timer.scheduledTimer(withTimeInterval: interval, repeats: true) { [weak self] _ in
|
|
||||||
print("CALLED")
|
|
||||||
self?.checkForChanges()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func stopMonitoring() {
|
|
||||||
timer?.invalidate()
|
|
||||||
timer = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
private func checkForChanges() {
|
|
||||||
print("CHECKING")
|
|
||||||
let pasteboard = NSPasteboard.general
|
|
||||||
if pasteboard.changeCount != lastChangeCount {
|
|
||||||
lastChangeCount = pasteboard.changeCount
|
|
||||||
handlePasteboardChange(pasteboard)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func handlePasteboardChange(_ pasteboard: NSPasteboard) {
|
|
||||||
if let copiedString = pasteboard.string(forType: .string) {
|
|
||||||
print("Clipboard changed: \(copiedString)")
|
|
||||||
} else {
|
|
||||||
print("Clipboard changed (non-string content)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
|
class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
|
||||||
let fileManager = FileManager.default
|
let fileManager = FileManager.default
|
||||||
|
|
||||||
@@ -45,19 +10,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate {
|
|||||||
MenulessWindow(viewController: SettingsViewController())
|
MenulessWindow(viewController: SettingsViewController())
|
||||||
let aboutWindow = MenulessWindow(viewController: AboutViewController())
|
let aboutWindow = MenulessWindow(viewController: AboutViewController())
|
||||||
|
|
||||||
var monitor: ClipboardMonitor?
|
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||||
|
|
||||||
|
|
||||||
monitor = ClipboardMonitor()
|
|
||||||
monitor?.startMonitoring()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
settingsWindow.title = "Settings"
|
settingsWindow.title = "Settings"
|
||||||
aboutWindow.level = .statusBar
|
aboutWindow.level = .statusBar
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user