mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-02 20:16:54 +01:00
Make local account display names changeable
This commit is contained in:
parent
9a73d7383e
commit
ba57a27a35
@ -63,6 +63,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||||||
let currentNameForDisplay = nameForDisplay
|
let currentNameForDisplay = nameForDisplay
|
||||||
if newValue != settings.name {
|
if newValue != settings.name {
|
||||||
settings.name = newValue
|
settings.name = newValue
|
||||||
|
settingsDirty = true
|
||||||
if currentNameForDisplay != nameForDisplay {
|
if currentNameForDisplay != nameForDisplay {
|
||||||
postDisplayNameDidChangeNotification()
|
postDisplayNameDidChangeNotification()
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="mPU-HG-I4u">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="mPU-HG-I4u">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<scenes>
|
<scenes>
|
||||||
@ -283,9 +283,23 @@
|
|||||||
</textFieldCell>
|
</textFieldCell>
|
||||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||||
<prototypeCellViews>
|
<prototypeCellViews>
|
||||||
<tableCellView id="8VZ-UT-iWO">
|
<tableCellView identifier="Cell" id="ZA5-gH-T6I">
|
||||||
<rect key="frame" x="1" y="1" width="116" height="17"/>
|
<rect key="frame" x="1" y="1" width="116" height="17"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<subviews>
|
||||||
|
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2hE-gk-uTf">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="116" height="17"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||||
|
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="tMr-Ok-LFl">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
|
</subviews>
|
||||||
|
<connections>
|
||||||
|
<outlet property="textField" destination="2hE-gk-uTf" id="OeM-bv-DDy"/>
|
||||||
|
</connections>
|
||||||
</tableCellView>
|
</tableCellView>
|
||||||
</prototypeCellViews>
|
</prototypeCellViews>
|
||||||
</tableColumn>
|
</tableColumn>
|
||||||
@ -360,6 +374,10 @@
|
|||||||
<constraint firstItem="1gP-iQ-hAV" firstAttribute="leading" secondItem="9qe-g9-RR3" secondAttribute="trailing" id="zce-qz-sim"/>
|
<constraint firstItem="1gP-iQ-hAV" firstAttribute="leading" secondItem="9qe-g9-RR3" secondAttribute="trailing" id="zce-qz-sim"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
|
<connections>
|
||||||
|
<outlet property="detailView" destination="Y7D-xQ-wep" id="7U0-LY-Xom"/>
|
||||||
|
<outlet property="tableView" destination="aTp-KR-y6b" id="jTu-6a-Jno"/>
|
||||||
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
<customObject id="AgZ-2t-A2h" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
<customObject id="AgZ-2t-A2h" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
|
@ -11,11 +11,30 @@ import Account
|
|||||||
|
|
||||||
final class AccountsPreferencesViewController: NSViewController {
|
final class AccountsPreferencesViewController: NSViewController {
|
||||||
|
|
||||||
|
@IBOutlet weak var tableView: NSTableView!
|
||||||
|
@IBOutlet weak var detailView: NSView!
|
||||||
|
|
||||||
private var sortedAccounts = [Account]()
|
private var sortedAccounts = [Account]()
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
|
||||||
|
}
|
||||||
|
|
||||||
override func viewWillAppear() {
|
override func viewWillAppear() {
|
||||||
updateSortedAccounts()
|
updateSortedAccounts()
|
||||||
|
tableView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewWillDisappear() {
|
||||||
|
super.viewWillDisappear()
|
||||||
|
resetContainerView()
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func displayNameDidChange(_ note: Notification) {
|
||||||
|
tableView.reloadData()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - NSTableViewDataSource
|
// MARK: - NSTableViewDataSource
|
||||||
@ -38,23 +57,30 @@ extension AccountsPreferencesViewController: NSTableViewDelegate {
|
|||||||
private static let cellIdentifier = NSUserInterfaceItemIdentifier(rawValue: "AccountCell")
|
private static let cellIdentifier = NSUserInterfaceItemIdentifier(rawValue: "AccountCell")
|
||||||
|
|
||||||
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
||||||
|
if let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Cell"), owner: nil) as? NSTableCellView {
|
||||||
func configure(_ cell: AccountsTableCellView) {
|
cell.textField?.stringValue = sortedAccounts[row].nameForDisplay
|
||||||
}
|
|
||||||
|
|
||||||
if let cell = tableView.makeView(withIdentifier: AccountsPreferencesViewController.cellIdentifier, owner: nil) as? AccountsTableCellView {
|
|
||||||
configure(cell)
|
|
||||||
return cell
|
return cell
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
let cell = AccountsTableCellView()
|
|
||||||
cell.identifier = AccountsPreferencesViewController.cellIdentifier
|
|
||||||
configure(cell)
|
|
||||||
return cell
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableViewSelectionDidChange(_ notification: Notification) {
|
func tableViewSelectionDidChange(_ notification: Notification) {
|
||||||
|
|
||||||
|
let selectedRow = tableView.selectedRow
|
||||||
|
guard selectedRow != -1 else {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let account = sortedAccounts[selectedRow]
|
||||||
|
|
||||||
|
let controller = LocalAccountPreferencesViewController(account: account)
|
||||||
|
addChild(controller)
|
||||||
|
controller.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
detailView.addSubview(controller.view)
|
||||||
|
detailView.rs_addFullSizeConstraints(forSubview: controller.view)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Private
|
// MARK: - Private
|
||||||
@ -64,4 +90,12 @@ private extension AccountsPreferencesViewController {
|
|||||||
func updateSortedAccounts() {
|
func updateSortedAccounts() {
|
||||||
sortedAccounts = AccountManager.shared.sortedAccounts
|
sortedAccounts = AccountManager.shared.sortedAccounts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resetContainerView() {
|
||||||
|
if let controller = children.first {
|
||||||
|
children.removeAll()
|
||||||
|
controller.view.removeFromSuperview()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
//
|
|
||||||
// AccountsTableCellView.swift
|
|
||||||
// NetNewsWire
|
|
||||||
//
|
|
||||||
// Created by Brent Simmons on 3/23/19.
|
|
||||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import AppKit
|
|
||||||
|
|
||||||
final class AccountsTableCellView: NSTableCellView {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<objects>
|
<objects>
|
||||||
<customObject id="-2" userLabel="File's Owner" customClass="LocalAccountPreferencesViewController" customModule="NetNewsWire" customModuleProvider="target"/>
|
<customObject id="-2" userLabel="File's Owner" customClass="LocalAccountPreferencesViewController" customModule="NetNewsWire" customModuleProvider="target">
|
||||||
|
<connections>
|
||||||
|
<outlet property="nameTextField" destination="TT0-Kf-YTC" id="oMG-jn-Qn0"/>
|
||||||
|
<outlet property="typeLabel" destination="XYX-iz-hnq" id="SKM-et-3h3"/>
|
||||||
|
<outlet property="view" destination="3ki-rg-6yb" id="ttM-4E-OLN"/>
|
||||||
|
</connections>
|
||||||
|
</customObject>
|
||||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||||
<tabView id="3ki-rg-6yb">
|
<tabView id="3ki-rg-6yb">
|
||||||
|
@ -9,7 +9,10 @@
|
|||||||
import AppKit
|
import AppKit
|
||||||
import Account
|
import Account
|
||||||
|
|
||||||
final class LocalAccountPreferencesViewController: NSViewController {
|
final class LocalAccountPreferencesViewController: NSViewController, NSTextFieldDelegate {
|
||||||
|
|
||||||
|
@IBOutlet weak var typeLabel: NSTextField!
|
||||||
|
@IBOutlet weak var nameTextField: NSTextField!
|
||||||
|
|
||||||
private weak var account: Account?
|
private weak var account: Account?
|
||||||
|
|
||||||
@ -21,4 +24,20 @@ final class LocalAccountPreferencesViewController: NSViewController {
|
|||||||
public required init?(coder: NSCoder) {
|
public required init?(coder: NSCoder) {
|
||||||
super.init(coder: coder)
|
super.init(coder: coder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewDidLoad() {
|
||||||
|
super.viewDidLoad()
|
||||||
|
nameTextField.delegate = self
|
||||||
|
typeLabel.stringValue = account?.defaultName ?? ""
|
||||||
|
nameTextField.stringValue = account?.name ?? ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func controlTextDidEndEditing(_ obj: Notification) {
|
||||||
|
if !nameTextField.stringValue.isEmpty {
|
||||||
|
account?.name = nameTextField.stringValue
|
||||||
|
} else {
|
||||||
|
account?.name = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,6 @@
|
|||||||
84C9FC7C22629E1200D921D6 /* AccountsPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */; };
|
84C9FC7C22629E1200D921D6 /* AccountsPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */; };
|
||||||
84C9FC7D22629E1200D921D6 /* LocalAccount.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84C9FC7422629E1200D921D6 /* LocalAccount.xib */; };
|
84C9FC7D22629E1200D921D6 /* LocalAccount.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84C9FC7422629E1200D921D6 /* LocalAccount.xib */; };
|
||||||
84C9FC7E22629E1200D921D6 /* LocalAccountPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C9FC7522629E1200D921D6 /* LocalAccountPreferencesViewController.swift */; };
|
84C9FC7E22629E1200D921D6 /* LocalAccountPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C9FC7522629E1200D921D6 /* LocalAccountPreferencesViewController.swift */; };
|
||||||
84C9FC7F22629E1200D921D6 /* AccountsTableCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C9FC7622629E1200D921D6 /* AccountsTableCellView.swift */; };
|
|
||||||
84C9FC8222629E4800D921D6 /* Preferences.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 84C9FC8022629E4800D921D6 /* Preferences.storyboard */; };
|
84C9FC8222629E4800D921D6 /* Preferences.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 84C9FC8022629E4800D921D6 /* Preferences.storyboard */; };
|
||||||
84C9FC8C22629E8F00D921D6 /* KeyboardShortcuts.html in Resources */ = {isa = PBXBuildFile; fileRef = 84C9FC8722629E8F00D921D6 /* KeyboardShortcuts.html */; };
|
84C9FC8C22629E8F00D921D6 /* KeyboardShortcuts.html in Resources */ = {isa = PBXBuildFile; fileRef = 84C9FC8722629E8F00D921D6 /* KeyboardShortcuts.html */; };
|
||||||
84C9FC8D22629E8F00D921D6 /* EvergreenLarge.png in Resources */ = {isa = PBXBuildFile; fileRef = 84C9FC8822629E8F00D921D6 /* EvergreenLarge.png */; };
|
84C9FC8D22629E8F00D921D6 /* EvergreenLarge.png in Resources */ = {isa = PBXBuildFile; fileRef = 84C9FC8822629E8F00D921D6 /* EvergreenLarge.png */; };
|
||||||
@ -808,7 +807,6 @@
|
|||||||
84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsPreferencesViewController.swift; sourceTree = "<group>"; };
|
84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsPreferencesViewController.swift; sourceTree = "<group>"; };
|
||||||
84C9FC7422629E1200D921D6 /* LocalAccount.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LocalAccount.xib; sourceTree = "<group>"; };
|
84C9FC7422629E1200D921D6 /* LocalAccount.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LocalAccount.xib; sourceTree = "<group>"; };
|
||||||
84C9FC7522629E1200D921D6 /* LocalAccountPreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalAccountPreferencesViewController.swift; sourceTree = "<group>"; };
|
84C9FC7522629E1200D921D6 /* LocalAccountPreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalAccountPreferencesViewController.swift; sourceTree = "<group>"; };
|
||||||
84C9FC7622629E1200D921D6 /* AccountsTableCellView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountsTableCellView.swift; sourceTree = "<group>"; };
|
|
||||||
84C9FC8122629E4800D921D6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Mac/Base.lproj/Preferences.storyboard; sourceTree = SOURCE_ROOT; };
|
84C9FC8122629E4800D921D6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Mac/Base.lproj/Preferences.storyboard; sourceTree = SOURCE_ROOT; };
|
||||||
84C9FC8722629E8F00D921D6 /* KeyboardShortcuts.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = KeyboardShortcuts.html; sourceTree = "<group>"; };
|
84C9FC8722629E8F00D921D6 /* KeyboardShortcuts.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = KeyboardShortcuts.html; sourceTree = "<group>"; };
|
||||||
84C9FC8822629E8F00D921D6 /* EvergreenLarge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = EvergreenLarge.png; sourceTree = "<group>"; };
|
84C9FC8822629E8F00D921D6 /* EvergreenLarge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = EvergreenLarge.png; sourceTree = "<group>"; };
|
||||||
@ -1562,7 +1560,6 @@
|
|||||||
84C9FC7122629E1200D921D6 /* AccountsControlsBackgroundView.swift */,
|
84C9FC7122629E1200D921D6 /* AccountsControlsBackgroundView.swift */,
|
||||||
84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */,
|
84C9FC7222629E1200D921D6 /* AccountsPreferencesViewController.swift */,
|
||||||
84C9FC7322629E1200D921D6 /* Local */,
|
84C9FC7322629E1200D921D6 /* Local */,
|
||||||
84C9FC7622629E1200D921D6 /* AccountsTableCellView.swift */,
|
|
||||||
);
|
);
|
||||||
path = Accounts;
|
path = Accounts;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -2396,7 +2393,6 @@
|
|||||||
84AD1EAA2031617300BC20B7 /* FolderPasteboardWriter.swift in Sources */,
|
84AD1EAA2031617300BC20B7 /* FolderPasteboardWriter.swift in Sources */,
|
||||||
84AD1EBC2032AF5C00BC20B7 /* SidebarOutlineDataSource.swift in Sources */,
|
84AD1EBC2032AF5C00BC20B7 /* SidebarOutlineDataSource.swift in Sources */,
|
||||||
845A29241FC9255E007B49E3 /* SidebarCellAppearance.swift in Sources */,
|
845A29241FC9255E007B49E3 /* SidebarCellAppearance.swift in Sources */,
|
||||||
84C9FC7F22629E1200D921D6 /* AccountsTableCellView.swift in Sources */,
|
|
||||||
84F3EE1620DEC97E003FADEB /* FeedFinder.swift in Sources */,
|
84F3EE1620DEC97E003FADEB /* FeedFinder.swift in Sources */,
|
||||||
845EE7B11FC2366500854A1F /* StarredFeedDelegate.swift in Sources */,
|
845EE7B11FC2366500854A1F /* StarredFeedDelegate.swift in Sources */,
|
||||||
848F6AE51FC29CFB002D422E /* FaviconDownloader.swift in Sources */,
|
848F6AE51FC29CFB002D422E /* FaviconDownloader.swift in Sources */,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user