mirror of
https://github.com/MonitorControl/MonitorControl.git
synced 2026-05-16 14:15:55 -06:00
* Update to Swift 5.0 and run `swiftformat`. * Refactor `MediaKeyTap` start/restart. * Remove useless comments. * Reorder files. * Add German translation. * Switch to Carthage. * Use `DDC.swift`. * Add `NSScreen` extension. * Simplify menu layout. * Hide the display’s built-in OSD. * Fix launch at login helper. * Fix `quitClicked` connection. * Refactor build phases. * Use `os_log` instead of `print`. * Use more specific check for `minReplyDelay`. * Add whitelist.
29 lines
699 B
Swift
29 lines
699 B
Swift
import Cocoa
|
|
import os.log
|
|
|
|
class ButtonCellView: NSTableCellView {
|
|
@IBOutlet var button: NSButton!
|
|
var display: Display?
|
|
let prefs = UserDefaults.standard
|
|
|
|
override func draw(_ dirtyRect: NSRect) {
|
|
super.draw(dirtyRect)
|
|
}
|
|
|
|
@IBAction func buttonToggled(_ sender: NSButton) {
|
|
if let display = display {
|
|
switch sender.state {
|
|
case .on:
|
|
self.prefs.set(true, forKey: "\(display.identifier)-state")
|
|
case .off:
|
|
self.prefs.set(false, forKey: "\(display.identifier)-state")
|
|
default:
|
|
break
|
|
}
|
|
|
|
#if DEBUG
|
|
os_log("Toggle enabled display state: %@", type: .info, sender.state == .on ? "on" : "off")
|
|
#endif
|
|
}
|
|
}
|
|
}
|