2015-07-16 23:53:53 +00:00
|
|
|
//
|
|
|
|
// AppDelegate.swift
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/07/2015.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2015 Thomas Harte. All rights reserved.
|
2015-07-16 23:53:53 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
|
|
@NSApplicationMain
|
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
|
2021-04-20 00:55:25 +00:00
|
|
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
|
|
|
// Check for at least one Metal-capable GPU; this check
|
|
|
|
// will become unnecessary if/when the minimum OS version
|
|
|
|
// that this project supports reascends to 10.14.
|
|
|
|
if (MTLCopyAllDevices().count == 0) {
|
|
|
|
let alert = NSAlert()
|
|
|
|
alert.messageText = "This application requires a Metal-capable GPU"
|
|
|
|
alert.addButton(withTitle: "Exit")
|
|
|
|
alert.runModal()
|
|
|
|
|
|
|
|
let application = notification.object as! NSApplication
|
|
|
|
application.terminate(self)
|
|
|
|
}
|
2015-07-16 23:53:53 +00:00
|
|
|
}
|
|
|
|
|
2019-09-22 17:59:31 +00:00
|
|
|
private var hasShownOpenDocument = false
|
2016-09-16 02:12:12 +00:00
|
|
|
func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {
|
2019-09-21 22:01:16 +00:00
|
|
|
// Decline to show the 'New...' selector by default; the 'Open...'
|
|
|
|
// dialogue has already been shown if this application was started
|
|
|
|
// without a file.
|
2019-08-05 01:34:30 +00:00
|
|
|
//
|
|
|
|
// Obiter: I dislike it when other applications do this for me, but it
|
|
|
|
// seems to be the new norm, and I've had user feedback that showing
|
|
|
|
// nothing is confusing. So here it is.
|
2019-09-22 17:59:31 +00:00
|
|
|
if !hasShownOpenDocument {
|
|
|
|
NSDocumentController.shared.openDocument(self)
|
|
|
|
hasShownOpenDocument = true
|
|
|
|
}
|
2016-01-07 02:09:49 +00:00
|
|
|
return false
|
|
|
|
}
|
2015-07-16 23:53:53 +00:00
|
|
|
}
|