diff options
| author | Grant Limberg <glimberg@gmail.com> | 2016-06-23 20:04:57 -0700 |
|---|---|---|
| committer | Grant Limberg <glimberg@gmail.com> | 2016-06-23 20:04:57 -0700 |
| commit | 35d1736c9726d3be8ab2cbc63b445d14b32c4d14 (patch) | |
| tree | 374a6525f1d332ffbb5f7644f3c0323a675c861d /ZeroTier One | |
| parent | 3c534abc9989719061dedd43a74221f73409357b (diff) | |
| download | infinitytier-35d1736c9726d3be8ab2cbc63b445d14b32c4d14.tar.gz infinitytier-35d1736c9726d3be8ab2cbc63b445d14b32c4d14.zip | |
add preferences view
not populated yet
Diffstat (limited to 'ZeroTier One')
| -rw-r--r-- | ZeroTier One/AppDelegate.swift | 27 | ||||
| -rw-r--r-- | ZeroTier One/JoinNetworkViewController.xib | 1 | ||||
| -rw-r--r-- | ZeroTier One/PreferencesViewController.swift | 18 | ||||
| -rw-r--r-- | ZeroTier One/PreferencesViewController.xib | 19 | ||||
| -rw-r--r-- | ZeroTier One/ShowNetworksViewController.xib | 1 |
5 files changed, 64 insertions, 2 deletions
diff --git a/ZeroTier One/AppDelegate.swift b/ZeroTier One/AppDelegate.swift index 0179780f..f37eba73 100644 --- a/ZeroTier One/AppDelegate.swift +++ b/ZeroTier One/AppDelegate.swift @@ -18,6 +18,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let networkListPopover = NSPopover() let joinNetworkPopover = NSPopover() + let preferencesPopover = NSPopover() var transientMonitor: AnyObject? = nil @@ -44,6 +45,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { networkListPopover.behavior = .Transient networkListPopover.appearance = NSAppearance(named: NSAppearanceNameAqua) + + preferencesPopover.contentViewController = PreferencesViewController( + nibName: "PreferencesViewController", bundle: nil) + preferencesPopover.behavior = .Transient + + preferencesPopover.appearance = NSAppearance(named: NSAppearanceNameAqua) } func applicationWillTerminate(aNotification: NSNotification) { @@ -86,6 +93,22 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } + func showPreferences() { + if let button = statusItem.button { + preferencesPopover.showRelativeToRect(button.bounds, ofView: button, preferredEdge: .MinY) + + if transientMonitor == nil { + transientMonitor = NSEvent.addGlobalMonitorForEventsMatchingMask( + [.LeftMouseDownMask, .RightMouseDownMask, .OtherMouseDownMask]) { (event: NSEvent) -> Void in + + NSEvent.removeMonitor(self.transientMonitor!) + self.transientMonitor = nil + self.preferencesPopover.close() + } + } + } + } + func quit() { NSApp.performSelector(#selector(NSApp.terminate(_:)), withObject: nil, afterDelay: 0.0) } @@ -134,6 +157,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem(NSMenuItem.separatorItem()) } + menu.addItem(NSMenuItem(title: "Preferences...", action: #selector(AppDelegate.showPreferences), keyEquivalent: ",")) + + menu.addItem(NSMenuItem.separatorItem()) + menu.addItem(NSMenuItem(title: "Quit ZeroTier One", action: #selector(AppDelegate.quit), keyEquivalent: "q")) statusItem.menu = menu diff --git a/ZeroTier One/JoinNetworkViewController.xib b/ZeroTier One/JoinNetworkViewController.xib index 7a2ffe70..625f1a3e 100644 --- a/ZeroTier One/JoinNetworkViewController.xib +++ b/ZeroTier One/JoinNetworkViewController.xib @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <dependencies> - <deployment identifier="macosx"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/> </dependencies> <objects> diff --git a/ZeroTier One/PreferencesViewController.swift b/ZeroTier One/PreferencesViewController.swift new file mode 100644 index 00000000..95d2d882 --- /dev/null +++ b/ZeroTier One/PreferencesViewController.swift @@ -0,0 +1,18 @@ +// +// PreferencesViewController.swift +// ZeroTier One +// +// Created by Grant Limberg on 6/23/16. +// Copyright © 2016 ZeroTier, Inc. All rights reserved. +// + +import Cocoa + +class PreferencesViewController: NSViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do view setup here. + } + +} diff --git a/ZeroTier One/PreferencesViewController.xib b/ZeroTier One/PreferencesViewController.xib new file mode 100644 index 00000000..2a80a43a --- /dev/null +++ b/ZeroTier One/PreferencesViewController.xib @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10101" systemVersion="15E32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> + <dependencies> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10101"/> + </dependencies> + <objects> + <customObject id="-2" userLabel="File's Owner" customClass="PreferencesViewController" customModuleProvider="target"> + <connections> + <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/> + </connections> + </customObject> + <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> + <customObject id="-3" userLabel="Application" customClass="NSObject"/> + <customView id="Hz6-mo-xeY"> + <rect key="frame" x="0.0" y="0.0" width="480" height="272"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> + </customView> + </objects> +</document> diff --git a/ZeroTier One/ShowNetworksViewController.xib b/ZeroTier One/ShowNetworksViewController.xib index 12f1ea3c..69120fc9 100644 --- a/ZeroTier One/ShowNetworksViewController.xib +++ b/ZeroTier One/ShowNetworksViewController.xib @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <dependencies> - <deployment identifier="macosx"/> <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/> </dependencies> <objects> |
