-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathAppDelegate.swift
More file actions
60 lines (44 loc) · 1.83 KB
/
AppDelegate.swift
File metadata and controls
60 lines (44 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// AppDelegate.swift
// BuildTimeAnalyzer
//
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var projectSelectionMenuItem: NSMenuItem!
@IBOutlet weak var buildTimesMenuItem: NSMenuItem!
@IBOutlet weak var alwaysInFrontMenuItem: NSMenuItem!
@objc var canExport: Bool = false
var viewController: ViewController? {
return NSApplication.shared.mainWindow?.contentViewController as? ViewController
}
func applicationDidFinishLaunching(_ notification: Notification) {
alwaysInFrontMenuItem.state = UserSettings.windowShouldBeTopMost ? .on : .off
}
func configureMenuItems(showBuildTimesMenuItem: Bool) {
projectSelectionMenuItem.isEnabled = !showBuildTimesMenuItem
buildTimesMenuItem.isEnabled = showBuildTimesMenuItem
}
// MARK: Actions
@IBAction func navigateToProjectSelection(_ sender: NSMenuItem) {
configureMenuItems(showBuildTimesMenuItem: true)
viewController?.cancelProcessing()
viewController?.showInstructions(true)
}
@IBAction func navigateToBuildTimes(_ sender: NSMenuItem) {
configureMenuItems(showBuildTimesMenuItem: false)
viewController?.showInstructions(false)
}
@IBAction func visitGitHubPage(_ sender: AnyObject) {
let path = "https://github.com/RobertGummesson/BuildTimeAnalyzer-for-Xcode"
if let url = URL(string: path) {
NSWorkspace.shared.open(url)
}
}
@IBAction func toggleAlwaysInFront(_ sender: NSMenuItem) {
let alwaysInFront = sender.state == .off
sender.state = alwaysInFront ? .on : .off
UserSettings.windowShouldBeTopMost = alwaysInFront
viewController?.makeWindowTopMost(topMost: alwaysInFront)
}
}