Add Panic Button UI.

This commit is contained in:
Brent Simmons 2017-11-16 18:23:07 -08:00
parent 5150e7af95
commit c459bd1a4e
6 changed files with 201 additions and 2 deletions

View File

@ -67,6 +67,8 @@
849C64761ED37A5D003D8FC0 /* EvergreenTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849C64751ED37A5D003D8FC0 /* EvergreenTests.swift */; };
84A6B6941FB8D43C006754AC /* DinosaursWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84A6B6931FB8D43C006754AC /* DinosaursWindow.xib */; };
84A6B6961FB8DBD2006754AC /* DinosaursWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84A6B6951FB8DBD2006754AC /* DinosaursWindowController.swift */; };
84AFBB3C1FBE76D800BA41CF /* PanicButtonWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AFBB3B1FBE76D800BA41CF /* PanicButtonWindowController.swift */; };
84AFBB3E1FBE770200BA41CF /* PanicButtonWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84AFBB3D1FBE770200BA41CF /* PanicButtonWindow.xib */; };
84B06FAE1ED37DBD00F0B54B /* RSCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B06FA91ED37DAD00F0B54B /* RSCore.framework */; };
84B06FAF1ED37DBD00F0B54B /* RSCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 84B06FA91ED37DAD00F0B54B /* RSCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
84B06FB21ED37DBD00F0B54B /* RSDatabase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B06F9D1ED37DA000F0B54B /* RSDatabase.framework */; };
@ -449,6 +451,8 @@
849C64771ED37A5D003D8FC0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
84A6B6931FB8D43C006754AC /* DinosaursWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DinosaursWindow.xib; sourceTree = "<group>"; };
84A6B6951FB8DBD2006754AC /* DinosaursWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DinosaursWindowController.swift; sourceTree = "<group>"; };
84AFBB3B1FBE76D800BA41CF /* PanicButtonWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanicButtonWindowController.swift; sourceTree = "<group>"; };
84AFBB3D1FBE770200BA41CF /* PanicButtonWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PanicButtonWindow.xib; sourceTree = "<group>"; };
84B06F961ED37DA000F0B54B /* RSDatabase.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSDatabase.xcodeproj; path = Frameworks/RSDatabase/RSDatabase.xcodeproj; sourceTree = "<group>"; };
84B06FA21ED37DAC00F0B54B /* RSCore.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSCore.xcodeproj; path = Frameworks/RSCore/RSCore.xcodeproj; sourceTree = "<group>"; };
84B06FB61ED37E8B00F0B54B /* RSWeb.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSWeb.xcodeproj; path = Frameworks/RSWeb/RSWeb.xcodeproj; sourceTree = "<group>"; };
@ -525,6 +529,7 @@
849A97811ED9EC63007D329B /* Status Bar */,
849A97551ED9EAC3007D329B /* Add Feed */,
849A97411ED9EAA9007D329B /* Add Folder */,
84AFBB3A1FBE76D800BA41CF /* PanicButton */,
);
name = MainWindow;
path = Evergreen/MainWindow;
@ -779,6 +784,15 @@
path = Evergreen/Dinosaurs;
sourceTree = "<group>";
};
84AFBB3A1FBE76D800BA41CF /* PanicButton */ = {
isa = PBXGroup;
children = (
84AFBB3D1FBE770200BA41CF /* PanicButtonWindow.xib */,
84AFBB3B1FBE76D800BA41CF /* PanicButtonWindowController.swift */,
);
path = PanicButton;
sourceTree = "<group>";
};
84B06F971ED37DA000F0B54B /* Products */ = {
isa = PBXGroup;
children = (
@ -1208,6 +1222,7 @@
849A978F1ED9EE72007D329B /* DefaultFeeds.plist in Resources */,
849A979D1ED9EFEB007D329B /* template.html in Resources */,
849A97A91ED9F9AA007D329B /* AddFeedSheet.xib in Resources */,
84AFBB3E1FBE770200BA41CF /* PanicButtonWindow.xib in Resources */,
842E45E71ED8C747000A8B52 /* DB5.plist in Resources */,
849A97AC1ED9F9BC007D329B /* AddFolderSheet.xib in Resources */,
849A97AF1ED9FA08007D329B /* FeedList.storyboard in Resources */,
@ -1252,6 +1267,7 @@
849A979F1ED9F130007D329B /* SidebarCell.swift in Sources */,
849A97651ED9EB96007D329B /* SidebarTreeControllerDelegate.swift in Sources */,
849A97671ED9EB96007D329B /* UnreadCountView.swift in Sources */,
84AFBB3C1FBE76D800BA41CF /* PanicButtonWindowController.swift in Sources */,
84E95D241FB1087500552D99 /* ArticlePasteboardWriter.swift in Sources */,
84A6B6961FB8DBD2006754AC /* DinosaursWindowController.swift in Sources */,
849A975B1ED9EB0D007D329B /* ArticleUtilities.swift in Sources */,

View File

@ -33,6 +33,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
var keyboardShortcutsWindowController: WebViewWindowController?
var inspectorWindowController: InspectorWindowController?
var logWindowController: LogWindowController?
var panicButtonWindowController: PanicButtonWindowController?
let log = Log()
let themeLoader = VSThemeLoader()
private let appNewsURLString = "https://ranchero.com/evergreen/feed.json"
@ -75,6 +77,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
addFolderWindowController!.runSheetOnWindow(window)
}
func hitPanicButton(with window: NSWindow) {
panicButtonWindowController = PanicButtonWindowController()
panicButtonWindowController!.runSheetOnWindow(window)
}
// MARK: - NSApplicationDelegate
func applicationDidFinishLaunching(_ note: Notification) {
@ -355,6 +363,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations {
Browser.open("https://ranchero.com/evergreen/help/1.0/", inBackground: false)
}
@IBAction func hitPanicButton(_ sender: Any?) {
createAndShowMainWindow()
hitPanicButton(with: mainWindowController!.window!)
}
}
private extension AppDelegate {

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13770" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13526" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13770"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13526"/>
</dependencies>
<scenes>
<!--Application-->
@ -426,6 +426,12 @@
<action selector="markAllAsRead:" target="Ady-hI-5gd" id="154-2D-ONk"/>
</connections>
</menuItem>
<menuItem title="Hit Panic Button…" id="ilK-aW-oAO">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="hitPanicButton:" target="Ady-hI-5gd" id="Y12-ll-3qL"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="qgr-Gl-Xhw"/>
<menuItem title="Open in Browser" keyEquivalent="" id="4iQ-1v-dTa">
<connections>

View File

@ -158,6 +158,11 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
splitViewController!.toggleSidebar(sender)
}
@IBAction func hitPanicButton(_ sender: Any?) {
appDelegate.hitPanicButton(with: window!)
}
}
// MARK: - Private

View File

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13526" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13526"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="PanicButtonWindowController" customModule="Evergreen" customModuleProvider="target">
<connections>
<outlet property="window" destination="QvC-M9-y7g" id="Wap-SV-du3"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Panic Button" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="312" height="154"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="312" height="159"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Ode-W8-yv9">
<rect key="frame" x="18" y="120" width="276" height="19"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Mark as read all articles older than:" id="SJM-bW-FQa">
<font key="font" metaFont="systemBold" size="16"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="K4S-qc-mF1">
<rect key="frame" x="18" y="88" width="277" height="26"/>
<popUpButtonCell key="cell" type="push" title="Today" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="vQJ-dr-QTR" id="t0a-rZ-E6n">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="hYC-dE-D9W">
<items>
<menuItem title="Today" id="vQJ-dr-QTR"/>
<menuItem title="Yesterday" id="CzD-fs-1pk"/>
<menuItem title="Two weeks" id="50m-a0-Pq1"/>
<menuItem title="One month" id="cfI-Uu-C7Q"/>
<menuItem title="Two months" id="C0t-0J-lGc"/>
<menuItem title="Six months" id="8hi-Xr-7TE"/>
</items>
</menu>
</popUpButtonCell>
</popUpButton>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dod-yG-835">
<rect key="frame" x="18" y="49" width="276" height="34"/>
<textFieldCell key="cell" allowsUndo="NO" sendsActionOnEndEditing="YES" title="This will mark older articles everywhere as read, not just selected articles." id="aVk-QT-g09">
<font key="font" metaFont="system"/>
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ePr-Wl-khT">
<rect key="frame" x="134" y="13" width="82" height="32"/>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="lXW-en-9Cq">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
Gw
</string>
</buttonCell>
<connections>
<action selector="cancel:" target="-2" id="qsE-qW-4YY"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wcO-KR-YAV">
<rect key="frame" x="216" y="13" width="82" height="32"/>
<buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="F8H-bo-vL9">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
DQ
</string>
</buttonCell>
<connections>
<action selector="performPanic:" target="-2" id="lKT-ae-Grv"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="K53-ff-yBH">
<rect key="frame" x="6" y="25" width="138" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="This doesnt work yet." id="6Kn-qd-351">
<font key="font" metaFont="system"/>
<color key="textColor" name="systemRedColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="wcO-KR-YAV" firstAttribute="bottom" secondItem="ePr-Wl-khT" secondAttribute="bottom" id="799-aJ-02m"/>
<constraint firstItem="dod-yG-835" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="20" symbolic="YES" id="BUx-cq-8jk"/>
<constraint firstItem="K4S-qc-mF1" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="20" symbolic="YES" id="Quv-Zo-RmQ"/>
<constraint firstAttribute="bottom" secondItem="wcO-KR-YAV" secondAttribute="bottom" constant="20" symbolic="YES" id="Rdb-Q2-xMP"/>
<constraint firstAttribute="trailing" secondItem="wcO-KR-YAV" secondAttribute="trailing" constant="20" symbolic="YES" id="WiX-Z0-HbZ"/>
<constraint firstItem="ePr-Wl-khT" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="128" id="cIZ-AF-Wbi"/>
<constraint firstItem="dod-yG-835" firstAttribute="top" secondItem="K4S-qc-mF1" secondAttribute="bottom" constant="8" symbolic="YES" id="dQc-nk-1ko"/>
<constraint firstItem="wcO-KR-YAV" firstAttribute="top" secondItem="dod-yG-835" secondAttribute="bottom" constant="8" symbolic="YES" id="f7E-hd-FvR"/>
<constraint firstAttribute="trailing" secondItem="Ode-W8-yv9" secondAttribute="trailing" constant="20" symbolic="YES" id="fYe-e2-q2M"/>
<constraint firstItem="Ode-W8-yv9" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" constant="20" symbolic="YES" id="fxX-Xh-pRL"/>
<constraint firstItem="Ode-W8-yv9" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" constant="20" symbolic="YES" id="k8j-dV-9vN"/>
<constraint firstItem="wcO-KR-YAV" firstAttribute="leading" secondItem="ePr-Wl-khT" secondAttribute="trailing" constant="12" symbolic="YES" id="lkE-WG-4n9"/>
<constraint firstItem="wcO-KR-YAV" firstAttribute="width" secondItem="ePr-Wl-khT" secondAttribute="width" id="rjw-ZT-cDy"/>
<constraint firstAttribute="trailing" secondItem="dod-yG-835" secondAttribute="trailing" constant="20" symbolic="YES" id="vqu-wC-Wdx"/>
<constraint firstItem="K4S-qc-mF1" firstAttribute="top" secondItem="Ode-W8-yv9" secondAttribute="bottom" constant="8" symbolic="YES" id="w5M-sz-xBb"/>
<constraint firstAttribute="trailing" secondItem="K4S-qc-mF1" secondAttribute="trailing" constant="20" symbolic="YES" id="wjo-GM-Gn9"/>
</constraints>
</view>
<point key="canvasLocation" x="248" y="82"/>
</window>
</objects>
</document>

View File

@ -0,0 +1,43 @@
//
// PanicButtonWindowController.swift
// Evergreen
//
// Created by Brent Simmons on 11/16/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Cocoa
final class PanicButtonWindowController: NSWindowController {
var hostWindow: NSWindow?
convenience init() {
self.init(windowNibName: NSNib.Name(rawValue: "PanicButtonWindow"))
}
func runSheetOnWindow(_ w: NSWindow) {
hostWindow = w
hostWindow!.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) -> Void in
}
}
private func closeSheet(_ response: NSApplication.ModalResponse) {
hostWindow!.endSheet(window!, returnCode: response)
}
// MARK: - Actions
@IBAction func cancel(_ sender: AnyObject) {
closeSheet(.cancel)
}
@IBAction func performPanic(_ sender: AnyObject) {
closeSheet(.OK)
}
}