mirror of
https://github.com/MonitorControl/MonitorControl.git
synced 2026-05-16 14:15:55 -06:00
Co-authored-by: Joni Van Roost <joni.VR@hotmail.com> Co-authored-by: Rayan Khan <rayankhan04@iCloud.com> Co-authored-by: Guillaume B <the0neyouseek@users.noreply.github.com>
71 lines
2.4 KiB
Swift
71 lines
2.4 KiB
Swift
import Cocoa
|
|
import Preferences
|
|
import ServiceManagement
|
|
|
|
class AboutPrefsViewController: NSViewController, PreferencePane {
|
|
let preferencePaneIdentifier = Preferences.PaneIdentifier.about
|
|
let preferencePaneTitle: String = NSLocalizedString("About", comment: "Shown in the main prefs window")
|
|
|
|
var toolbarItemIcon: NSImage {
|
|
if #available(macOS 11.0, *) {
|
|
return NSImage(systemSymbolName: "info.circle", accessibilityDescription: "About")!
|
|
} else {
|
|
// Fallback on earlier versions
|
|
return NSImage(named: NSImage.infoName)!
|
|
}
|
|
}
|
|
|
|
@IBOutlet var versionLabel: NSTextField!
|
|
@IBOutlet var copyrightLabel: NSTextField!
|
|
@IBOutlet var openContributorsButton: NSButton!
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
self.setAppInfo()
|
|
self.setCopyrightInfo()
|
|
}
|
|
|
|
@available(macOS, deprecated: 10.10)
|
|
override func viewWillAppear() {
|
|
super.viewWillAppear()
|
|
}
|
|
|
|
@IBAction func openDonate(_: NSButton) {
|
|
if let url = URL(string: "https://opencollective.com/monitorcontrol/donate") {
|
|
NSWorkspace.shared.open(url)
|
|
}
|
|
}
|
|
|
|
@IBAction func openWebPage(_: NSButton) {
|
|
if let url = URL(string: "https://monitorcontrol.app") {
|
|
NSWorkspace.shared.open(url)
|
|
}
|
|
}
|
|
|
|
@IBAction func openContributorsPage(_: NSButton) {
|
|
if let url = URL(string: "https://github.com/MonitorControl/MonitorControl/graphs/contributors") {
|
|
NSWorkspace.shared.open(url)
|
|
}
|
|
}
|
|
|
|
func setAppInfo() {
|
|
let versionName = NSLocalizedString("Version", comment: "Version")
|
|
let buildName = NSLocalizedString("Build", comment: "Build")
|
|
let versionNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "error"
|
|
let buildNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") ?? "error"
|
|
|
|
#if arch(arm64)
|
|
let arch: String = NSLocalizedString("Apple Silicon", comment: "Apple Silicon designation (shown after the version number in Preferences)")
|
|
#else
|
|
let arch: String = NSLocalizedString("Intel", comment: "Intel designation (shown after the version number in Preferences)")
|
|
#endif
|
|
|
|
self.versionLabel.stringValue = "\(versionName) \(versionNumber) \(buildName) \(buildNumber) - \(arch)"
|
|
}
|
|
|
|
func setCopyrightInfo() {
|
|
let copyright = NSLocalizedString("Copyright Ⓒ MonitorControl, ", comment: "Version")
|
|
let year = Calendar.current.component(.year, from: Date())
|
|
self.copyrightLabel.stringValue = "\(copyright) \(year)"
|
|
}
|
|
}
|