add preferences view

not populated yet
This commit is contained in:
Grant Limberg 2016-06-23 20:04:57 -07:00
parent 3c534abc99
commit 35d1736c97
6 changed files with 72 additions and 2 deletions

View File

@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
932D472D1D138B0C004BCFE2 /* NetworkMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */; };
932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */; };
932D47321D1CD861004BCFE2 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */; };
932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */; };
9330F1351CEAB4C400687EC8 /* ServiceCom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1341CEAB4C400687EC8 /* ServiceCom.swift */; };
9330F1371CEBF87200687EC8 /* Network.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F1361CEBF87200687EC8 /* Network.swift */; };
9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */; };
@ -25,6 +27,8 @@
/* Begin PBXFileReference section */
932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkMonitor.swift; sourceTree = "<group>"; };
932D472E1D1CD499004BCFE2 /* ZeroTierIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ZeroTierIcon.icns; sourceTree = "<group>"; };
932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesViewController.swift; sourceTree = "<group>"; };
932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreferencesViewController.xib; sourceTree = "<group>"; };
9330F1341CEAB4C400687EC8 /* ServiceCom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ServiceCom.swift; sourceTree = "<group>"; };
9330F1361CEBF87200687EC8 /* Network.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = "<group>"; };
9330F13A1CF534E500687EC8 /* NetworkInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkInfoCell.swift; sourceTree = "<group>"; };
@ -88,6 +92,8 @@
93DAFE4C1CFE53DA00547CC4 /* AuthtokenCopy.h */,
93DAFE491CFE53C900547CC4 /* ZeroTier One-Bridging-Header.h */,
932D472C1D138B0C004BCFE2 /* NetworkMonitor.swift */,
932D47301D1CD861004BCFE2 /* PreferencesViewController.swift */,
932D47311D1CD861004BCFE2 /* PreferencesViewController.xib */,
);
path = "ZeroTier One";
sourceTree = "<group>";
@ -155,6 +161,7 @@
93326BDE1CE7C816005CA2AC /* Assets.xcassets in Resources */,
93326BE11CE7C816005CA2AC /* MainMenu.xib in Resources */,
932D472F1D1CD499004BCFE2 /* ZeroTierIcon.icns in Resources */,
932D47331D1CD861004BCFE2 /* PreferencesViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -167,6 +174,7 @@
files = (
9330F1371CEBF87200687EC8 /* Network.swift in Sources */,
932D472D1D138B0C004BCFE2 /* NetworkMonitor.swift in Sources */,
932D47321D1CD861004BCFE2 /* PreferencesViewController.swift in Sources */,
93326BDC1CE7C816005CA2AC /* AppDelegate.swift in Sources */,
93DAFE4B1CFE53CA00547CC4 /* AuthtokenCopy.m in Sources */,
9330F13B1CF534E500687EC8 /* NetworkInfoCell.swift in Sources */,

View File

@ -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

View File

@ -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>

View File

@ -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.
}
}

View File

@ -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>

View File

@ -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>