mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
50 lines
1.6 KiB
Swift
50 lines
1.6 KiB
Swift
//
|
|
// AppDelegate.swift
|
|
// MTMR
|
|
//
|
|
// Created by Anton Palgunov on 16/03/2018.
|
|
// Copyright © 2018 Anton Palgunov. All rights reserved.
|
|
//
|
|
|
|
import Cocoa
|
|
|
|
@NSApplicationMain
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
let statusItem = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength)
|
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
|
// Insert code here to initialize your application
|
|
TouchBarController.shared.setupControlStripPresence()
|
|
|
|
if let button = statusItem.button {
|
|
button.image = #imageLiteral(resourceName: "StatusImage")
|
|
}
|
|
createMenu()
|
|
}
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {
|
|
// Insert code here to tear down your application
|
|
}
|
|
|
|
@objc func testFn(_ sender: Any?) {
|
|
let quoteText = "You click on menu"
|
|
let task = Process()
|
|
let appSupportDirectory = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true).first!.appending("/MTMR")
|
|
let presetPath = appSupportDirectory.appending("/items.json")
|
|
task.launchPath = "/usr/bin/open"
|
|
task.arguments = [presetPath]
|
|
task.launch()
|
|
print(quoteText)
|
|
}
|
|
|
|
func createMenu() {
|
|
let menu = NSMenu()
|
|
menu.addItem(withTitle: "Preferences", action: #selector(testFn(_:)), keyEquivalent: ",")
|
|
menu.addItem(NSMenuItem.separator())
|
|
menu.addItem(withTitle: "Quit", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
|
statusItem.menu = menu
|
|
}
|
|
|
|
}
|
|
|