diff --git a/Mac/Preferences/Accounts/AccountsDelete.xib b/Mac/Preferences/Accounts/AccountsDelete.xib deleted file mode 100644 index cd351f1ee..000000000 --- a/Mac/Preferences/Accounts/AccountsDelete.xib +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Are you sure you want to permanently delete this account? -This cannot be undone. - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Mac/Preferences/Accounts/AccountsDeleteWindowController.swift b/Mac/Preferences/Accounts/AccountsDeleteWindowController.swift deleted file mode 100644 index ff03d6b7e..000000000 --- a/Mac/Preferences/Accounts/AccountsDeleteWindowController.swift +++ /dev/null @@ -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) - } - -} diff --git a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift index 41ed2accd..ad73219f5 100644 --- a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift +++ b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift @@ -15,7 +15,6 @@ final class AccountsPreferencesViewController: NSViewController { @IBOutlet weak var detailView: NSView! @IBOutlet weak var deleteButton: NSButton! - private var deleteController: AccountsDeleteWindowController? private var sortedAccounts = [Account]() override func viewDidLoad() { @@ -43,11 +42,21 @@ final class AccountsPreferencesViewController: NSViewController { return } - let account = sortedAccounts[tableView.selectedRow] - deleteController = AccountsDeleteWindowController(account: account) - deleteController!.runSheetOnWindow(view.window!) { [weak self] result in - if result == NSApplication.ModalResponse.OK { - self?.showController(AccountsAddViewController()) + let acctName = sortedAccounts[tableView.selectedRow].nameForDisplay + + let alert = NSAlert() + alert.alertStyle = .warning + 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]) } } diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index b65eca789..3b275a3fb 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -24,8 +24,6 @@ 5144EA3D227A37AF00D19003 /* ExportOPMLSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA3C227A37AF00D19003 /* ExportOPMLSheet.xib */; }; 5144EA40227A37EC00D19003 /* ImportOPMLWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5144EA3E227A37EC00D19003 /* ImportOPMLWindowController.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 */; }; 5144EA52227B8E4500D19003 /* AccountsFeedbin.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5144EA50227B8E4500D19003 /* AccountsFeedbin.xib */; }; 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 = ""; }; 5144EA3E227A37EC00D19003 /* ImportOPMLWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportOPMLWindowController.swift; sourceTree = ""; }; 5144EA42227A380F00D19003 /* ExportOPMLWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportOPMLWindowController.swift; sourceTree = ""; }; - 5144EA44227A5A8700D19003 /* AccountsDeleteWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsDeleteWindowController.swift; sourceTree = ""; }; - 5144EA45227A5A8700D19003 /* AccountsDelete.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountsDelete.xib; sourceTree = ""; }; 5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsFeedbinWindowController.swift; sourceTree = ""; }; 5144EA50227B8E4500D19003 /* AccountsFeedbin.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AccountsFeedbin.xib; sourceTree = ""; }; 5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonIntrinsicLabel.swift; sourceTree = ""; }; @@ -1584,8 +1580,6 @@ 5144EA4F227B8E4500D19003 /* AccountsFeedbinWindowController.swift */, 5144EA352279FC3D00D19003 /* AccountsAddLocal.xib */, 5144EA372279FC6200D19003 /* AccountsAddLocalWindowController.swift */, - 5144EA45227A5A8700D19003 /* AccountsDelete.xib */, - 5144EA44227A5A8700D19003 /* AccountsDeleteWindowController.swift */, ); path = Accounts; sourceTree = ""; @@ -2169,7 +2163,6 @@ 848362FF2262A30E00DA1D35 /* template.html in Resources */, 848363082262A3DD00DA1D35 /* Main.storyboard in Resources */, 51EF0F8E2279C9260050506E /* AccountsAdd.xib in Resources */, - 5144EA47227A5A8700D19003 /* AccountsDelete.xib in Resources */, 84C9FC8F22629E8F00D921D6 /* NetNewsWire.sdef in Resources */, 84C9FC7D22629E1200D921D6 /* AccountsDetail.xib in Resources */, 5144EA362279FC3D00D19003 /* AccountsAddLocal.xib in Resources */, @@ -2390,7 +2383,6 @@ 84B7178C201E66580091657D /* SidebarViewController+ContextualMenus.swift in Sources */, 5144EA43227A380F00D19003 /* ExportOPMLWindowController.swift in Sources */, 842611A21FCB769D0086A189 /* RSHTMLMetadata+Extension.swift in Sources */, - 5144EA46227A5A8700D19003 /* AccountsDeleteWindowController.swift in Sources */, 84A1500520048DDF0046AD9A /* SendToMarsEditCommand.swift in Sources */, D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */, 849A978A1ED9ECEF007D329B /* ArticleStylesManager.swift in Sources */,