Change account delete to use a standard alert dialog.
This commit is contained in:
parent
75fbd9e3eb
commit
a7d1014d5b
|
@ -1,92 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
|
||||||
<dependencies>
|
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
|
||||||
</dependencies>
|
|
||||||
<objects>
|
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="AccountsDeleteWindowController" customModule="NetNewsWire" customModuleProvider="target">
|
|
||||||
<connections>
|
|
||||||
<outlet property="deleteLabel" destination="Fce-kc-b0h" id="7ZU-DV-MZC"/>
|
|
||||||
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
|
|
||||||
</connections>
|
|
||||||
</customObject>
|
|
||||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
|
||||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
|
||||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
|
|
||||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
|
||||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
|
||||||
<rect key="contentRect" x="196" y="240" width="388" height="241"/>
|
|
||||||
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
|
|
||||||
<view key="contentView" id="se5-gp-TjO">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="399" height="130"/>
|
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
|
||||||
<subviews>
|
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Fce-kc-b0h">
|
|
||||||
<rect key="frame" x="18" y="81" width="163" height="29"/>
|
|
||||||
<textFieldCell key="cell" lineBreakMode="clipping" title="Delete Account" id="Avt-GJ-nM5">
|
|
||||||
<font key="font" metaFont="system" size="24"/>
|
|
||||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
</textFieldCell>
|
|
||||||
</textField>
|
|
||||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ATn-Px-oM3">
|
|
||||||
<rect key="frame" x="18" y="39" width="363" height="34"/>
|
|
||||||
<constraints>
|
|
||||||
<constraint firstAttribute="height" constant="34" id="TPx-9h-Nlb"/>
|
|
||||||
</constraints>
|
|
||||||
<textFieldCell key="cell" lineBreakMode="charWrapping" id="g3o-wP-P50">
|
|
||||||
<font key="font" metaFont="system"/>
|
|
||||||
<string key="title">Are you sure you want to permanently delete this account?
|
|
||||||
This cannot be undone.</string>
|
|
||||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
|
||||||
</textFieldCell>
|
|
||||||
</textField>
|
|
||||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="jaZ-f1-UDg">
|
|
||||||
<rect key="frame" x="305" y="13" width="80" height="32"/>
|
|
||||||
<buttonCell key="cell" type="push" title="Delete" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="XJH-E2-zim">
|
|
||||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
|
||||||
<font key="font" metaFont="system"/>
|
|
||||||
<string key="keyEquivalent" base64-UTF8="YES">
|
|
||||||
Aw
|
|
||||||
</string>
|
|
||||||
</buttonCell>
|
|
||||||
<connections>
|
|
||||||
<action selector="delete:" target="-2" id="5zX-jC-oWO"/>
|
|
||||||
</connections>
|
|
||||||
</button>
|
|
||||||
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="v9D-u4-Ucr">
|
|
||||||
<rect key="frame" x="223" y="13" width="82" height="32"/>
|
|
||||||
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="tmJ-aM-Z1c">
|
|
||||||
<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="Zo3-sa-7b3"/>
|
|
||||||
</connections>
|
|
||||||
</button>
|
|
||||||
</subviews>
|
|
||||||
<constraints>
|
|
||||||
<constraint firstItem="ATn-Px-oM3" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="2SQ-Jm-kaA"/>
|
|
||||||
<constraint firstAttribute="bottom" secondItem="jaZ-f1-UDg" secondAttribute="bottom" constant="20" id="9GB-yz-aIT"/>
|
|
||||||
<constraint firstItem="jaZ-f1-UDg" firstAttribute="leading" secondItem="v9D-u4-Ucr" secondAttribute="trailing" constant="12" symbolic="YES" id="BH5-Ed-OFG"/>
|
|
||||||
<constraint firstItem="Fce-kc-b0h" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="20" id="Fxf-5F-l3D"/>
|
|
||||||
<constraint firstItem="v9D-u4-Ucr" firstAttribute="centerY" secondItem="jaZ-f1-UDg" secondAttribute="centerY" id="IfR-SA-Uft"/>
|
|
||||||
<constraint firstItem="Fce-kc-b0h" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" id="KeW-9F-SKj"/>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="jaZ-f1-UDg" secondAttribute="trailing" constant="20" id="LSF-4E-uzG"/>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="ATn-Px-oM3" secondAttribute="trailing" constant="20" id="eXh-HX-MTx"/>
|
|
||||||
<constraint firstItem="jaZ-f1-UDg" firstAttribute="firstBaseline" secondItem="ATn-Px-oM3" secondAttribute="baseline" constant="16" id="gzw-C9-vLu"/>
|
|
||||||
<constraint firstItem="ATn-Px-oM3" firstAttribute="top" secondItem="Fce-kc-b0h" secondAttribute="bottom" constant="8" id="mIu-3V-PcW"/>
|
|
||||||
</constraints>
|
|
||||||
</view>
|
|
||||||
<connections>
|
|
||||||
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
|
|
||||||
</connections>
|
|
||||||
<point key="canvasLocation" x="11" y="132.5"/>
|
|
||||||
</window>
|
|
||||||
</objects>
|
|
||||||
</document>
|
|
|
@ -1,50 +0,0 @@
|
||||||
//
|
|
||||||
// AccountsDeleteWindowController.swift
|
|
||||||
// NetNewsWire
|
|
||||||
//
|
|
||||||
// Created by Maurice Parker on 5/1/19.
|
|
||||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import AppKit
|
|
||||||
import Account
|
|
||||||
|
|
||||||
class AccountsDeleteWindowController: NSWindowController {
|
|
||||||
|
|
||||||
@IBOutlet weak var deleteLabel: NSTextField!
|
|
||||||
private weak var hostWindow: NSWindow?
|
|
||||||
|
|
||||||
var account: Account?
|
|
||||||
|
|
||||||
convenience init(account: Account) {
|
|
||||||
self.init(windowNibName: NSNib.Name("AccountsDelete"))
|
|
||||||
self.account = account
|
|
||||||
}
|
|
||||||
|
|
||||||
override func windowDidLoad() {
|
|
||||||
let deletePrompt = NSLocalizedString("Delete", comment: "Delete")
|
|
||||||
deleteLabel.stringValue = "\(deletePrompt) \"\(account?.nameForDisplay ?? "")\"?"
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: API
|
|
||||||
|
|
||||||
func runSheetOnWindow(_ hostWindow: NSWindow, completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil) {
|
|
||||||
self.hostWindow = hostWindow
|
|
||||||
hostWindow.beginSheet(window!, completionHandler: handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: Actions
|
|
||||||
|
|
||||||
@IBAction func cancel(_ sender: Any) {
|
|
||||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.cancel)
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func delete(_ sender: Any) {
|
|
||||||
guard let account = account else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
AccountManager.shared.deleteAccount(account)
|
|
||||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -15,7 +15,6 @@ final class AccountsPreferencesViewController: NSViewController {
|
||||||
@IBOutlet weak var detailView: NSView!
|
@IBOutlet weak var detailView: NSView!
|
||||||
@IBOutlet weak var deleteButton: NSButton!
|
@IBOutlet weak var deleteButton: NSButton!
|
||||||
|
|
||||||
private var deleteController: AccountsDeleteWindowController?
|
|
||||||
private var sortedAccounts = [Account]()
|
private var sortedAccounts = [Account]()
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
|
@ -43,11 +42,21 @@ final class AccountsPreferencesViewController: NSViewController {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let account = sortedAccounts[tableView.selectedRow]
|
let acctName = sortedAccounts[tableView.selectedRow].nameForDisplay
|
||||||
deleteController = AccountsDeleteWindowController(account: account)
|
|
||||||
deleteController!.runSheetOnWindow(view.window!) { [weak self] result in
|
let alert = NSAlert()
|
||||||
if result == NSApplication.ModalResponse.OK {
|
alert.alertStyle = .warning
|
||||||
self?.showController(AccountsAddViewController())
|
let deletePrompt = NSLocalizedString("Delete", comment: "Delete")
|
||||||
|
alert.messageText = "\(deletePrompt) \"\(acctName)\"?"
|
||||||
|
alert.informativeText = NSLocalizedString("Are you sure you want to delete the account \"\(acctName)\"? This can not be undone.", comment: "Delete text")
|
||||||
|
|
||||||
|
alert.addButton(withTitle: NSLocalizedString("Delete", comment: "Delete Account"))
|
||||||
|
alert.addButton(withTitle: NSLocalizedString("Cancel", comment: "Cancel Delete Account"))
|
||||||
|
|
||||||
|
alert.beginSheetModal(for: view.window!) { [weak self] result in
|
||||||
|
if result == NSApplication.ModalResponse.alertFirstButtonReturn {
|
||||||
|
guard let self = self else { return }
|
||||||
|
AccountManager.shared.deleteAccount(self.sortedAccounts[self.tableView.selectedRow])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,6 @@
|
||||||
5144EA3D227A37AF00D19003 /* ExportOPMLSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA3C227A37AF00D19003 /* ExportOPMLSheet.xib */; };
|
5144EA3D227A37AF00D19003 /* ExportOPMLSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA3C227A37AF00D19003 /* ExportOPMLSheet.xib */; };
|
||||||
5144EA40227A37EC00D19003 /* ImportOPMLWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA3E227A37EC00D19003 /* ImportOPMLWindowController.swift */; };
|
5144EA40227A37EC00D19003 /* ImportOPMLWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA3E227A37EC00D19003 /* ImportOPMLWindowController.swift */; };
|
||||||
5144EA43227A380F00D19003 /* ExportOPMLWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA42227A380F00D19003 /* ExportOPMLWindowController.swift */; };
|
5144EA43227A380F00D19003 /* ExportOPMLWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA42227A380F00D19003 /* ExportOPMLWindowController.swift */; };
|
||||||
5144EA46227A5A8700D19003 /* AccountsDeleteWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA44227A5A8700D19003 /* AccountsDeleteWindowController.swift */; };
|
|
||||||
5144EA47227A5A8700D19003 /* AccountsDelete.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA45227A5A8700D19003 /* AccountsDelete.xib */; };
|
|
||||||
5144EA51227B8E4500D19003 /* AccountsFeedbinWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */; };
|
5144EA51227B8E4500D19003 /* AccountsFeedbinWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */; };
|
||||||
5144EA52227B8E4500D19003 /* AccountsFeedbin.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA50227B8E4500D19003 /* AccountsFeedbin.xib */; };
|
5144EA52227B8E4500D19003 /* AccountsFeedbin.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA50227B8E4500D19003 /* AccountsFeedbin.xib */; };
|
||||||
5183CCD0226E1E880010922C /* NonIntrinsicLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */; };
|
5183CCD0226E1E880010922C /* NonIntrinsicLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */; };
|
||||||
|
@ -646,8 +644,6 @@
|
||||||
5144EA3C227A37AF00D19003 /* ExportOPMLSheet.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ExportOPMLSheet.xib; sourceTree = "<group>"; };
|
5144EA3C227A37AF00D19003 /* ExportOPMLSheet.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ExportOPMLSheet.xib; sourceTree = "<group>"; };
|
||||||
5144EA3E227A37EC00D19003 /* ImportOPMLWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportOPMLWindowController.swift; sourceTree = "<group>"; };
|
5144EA3E227A37EC00D19003 /* ImportOPMLWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportOPMLWindowController.swift; sourceTree = "<group>"; };
|
||||||
5144EA42227A380F00D19003 /* ExportOPMLWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportOPMLWindowController.swift; sourceTree = "<group>"; };
|
5144EA42227A380F00D19003 /* ExportOPMLWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportOPMLWindowController.swift; sourceTree = "<group>"; };
|
||||||
5144EA44227A5A8700D19003 /* AccountsDeleteWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsDeleteWindowController.swift; sourceTree = "<group>"; };
|
|
||||||
5144EA45227A5A8700D19003 /* AccountsDelete.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountsDelete.xib; sourceTree = "<group>"; };
|
|
||||||
5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsFeedbinWindowController.swift; sourceTree = "<group>"; };
|
5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsFeedbinWindowController.swift; sourceTree = "<group>"; };
|
||||||
5144EA50227B8E4500D19003 /* AccountsFeedbin.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountsFeedbin.xib; sourceTree = "<group>"; };
|
5144EA50227B8E4500D19003 /* AccountsFeedbin.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountsFeedbin.xib; sourceTree = "<group>"; };
|
||||||
5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonIntrinsicLabel.swift; sourceTree = "<group>"; };
|
5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonIntrinsicLabel.swift; sourceTree = "<group>"; };
|
||||||
|
@ -1584,8 +1580,6 @@
|
||||||
5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */,
|
5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */,
|
||||||
5144EA352279FC3D00D19003 /* AccountsAddLocal.xib */,
|
5144EA352279FC3D00D19003 /* AccountsAddLocal.xib */,
|
||||||
5144EA372279FC6200D19003 /* AccountsAddLocalWindowController.swift */,
|
5144EA372279FC6200D19003 /* AccountsAddLocalWindowController.swift */,
|
||||||
5144EA45227A5A8700D19003 /* AccountsDelete.xib */,
|
|
||||||
5144EA44227A5A8700D19003 /* AccountsDeleteWindowController.swift */,
|
|
||||||
);
|
);
|
||||||
path = Accounts;
|
path = Accounts;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -2169,7 +2163,6 @@
|
||||||
848362FF2262A30E00DA1D35 /* template.html in Resources */,
|
848362FF2262A30E00DA1D35 /* template.html in Resources */,
|
||||||
848363082262A3DD00DA1D35 /* Main.storyboard in Resources */,
|
848363082262A3DD00DA1D35 /* Main.storyboard in Resources */,
|
||||||
51EF0F8E2279C9260050506E /* AccountsAdd.xib in Resources */,
|
51EF0F8E2279C9260050506E /* AccountsAdd.xib in Resources */,
|
||||||
5144EA47227A5A8700D19003 /* AccountsDelete.xib in Resources */,
|
|
||||||
84C9FC8F22629E8F00D921D6 /* NetNewsWire.sdef in Resources */,
|
84C9FC8F22629E8F00D921D6 /* NetNewsWire.sdef in Resources */,
|
||||||
84C9FC7D22629E1200D921D6 /* AccountsDetail.xib in Resources */,
|
84C9FC7D22629E1200D921D6 /* AccountsDetail.xib in Resources */,
|
||||||
5144EA362279FC3D00D19003 /* AccountsAddLocal.xib in Resources */,
|
5144EA362279FC3D00D19003 /* AccountsAddLocal.xib in Resources */,
|
||||||
|
@ -2390,7 +2383,6 @@
|
||||||
84B7178C201E66580091657D /* SidebarViewController+ContextualMenus.swift in Sources */,
|
84B7178C201E66580091657D /* SidebarViewController+ContextualMenus.swift in Sources */,
|
||||||
5144EA43227A380F00D19003 /* ExportOPMLWindowController.swift in Sources */,
|
5144EA43227A380F00D19003 /* ExportOPMLWindowController.swift in Sources */,
|
||||||
842611A21FCB769D0086A189 /* RSHTMLMetadata+Extension.swift in Sources */,
|
842611A21FCB769D0086A189 /* RSHTMLMetadata+Extension.swift in Sources */,
|
||||||
5144EA46227A5A8700D19003 /* AccountsDeleteWindowController.swift in Sources */,
|
|
||||||
84A1500520048DDF0046AD9A /* SendToMarsEditCommand.swift in Sources */,
|
84A1500520048DDF0046AD9A /* SendToMarsEditCommand.swift in Sources */,
|
||||||
D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */,
|
D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */,
|
||||||
849A978A1ED9ECEF007D329B /* ArticleStylesManager.swift in Sources */,
|
849A978A1ED9ECEF007D329B /* ArticleStylesManager.swift in Sources */,
|
||||||
|
|
Loading…
Reference in New Issue