NetNewsWire-Mac AppDefaults is now a singleton
This commit is contained in:
parent
f92b219cdc
commit
a57f98e4e7
|
@ -15,6 +15,9 @@ enum FontSize: Int {
|
|||
}
|
||||
|
||||
struct AppDefaults {
|
||||
|
||||
static var shared = AppDefaults()
|
||||
private init() {}
|
||||
|
||||
struct Key {
|
||||
static let firstRunDate = "firstRunDate"
|
||||
|
@ -50,14 +53,14 @@ struct AppDefaults {
|
|||
private static let smallestFontSizeRawValue = FontSize.small.rawValue
|
||||
private static let largestFontSizeRawValue = FontSize.veryLarge.rawValue
|
||||
|
||||
static let isDeveloperBuild: Bool = {
|
||||
let isDeveloperBuild: Bool = {
|
||||
if let dev = Bundle.main.object(forInfoDictionaryKey: "DeveloperEntitlements") as? String, dev == "-dev" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}()
|
||||
|
||||
static let isFirstRun: Bool = {
|
||||
var isFirstRun: Bool = {
|
||||
if let _ = UserDefaults.standard.object(forKey: Key.firstRunDate) as? Date {
|
||||
return false
|
||||
}
|
||||
|
@ -65,7 +68,7 @@ struct AppDefaults {
|
|||
return true
|
||||
}()
|
||||
|
||||
static var windowState: [AnyHashable : Any]? {
|
||||
var windowState: [AnyHashable : Any]? {
|
||||
get {
|
||||
return UserDefaults.standard.object(forKey: Key.windowState) as? [AnyHashable : Any]
|
||||
}
|
||||
|
@ -74,7 +77,7 @@ struct AppDefaults {
|
|||
}
|
||||
}
|
||||
|
||||
static var activeExtensionPointIDs: [[AnyHashable : AnyHashable]]? {
|
||||
var activeExtensionPointIDs: [[AnyHashable : AnyHashable]]? {
|
||||
get {
|
||||
return UserDefaults.standard.object(forKey: Key.activeExtensionPointIDs) as? [[AnyHashable : AnyHashable]]
|
||||
}
|
||||
|
@ -83,160 +86,160 @@ struct AppDefaults {
|
|||
}
|
||||
}
|
||||
|
||||
static var lastImageCacheFlushDate: Date? {
|
||||
var lastImageCacheFlushDate: Date? {
|
||||
get {
|
||||
return date(for: Key.lastImageCacheFlushDate)
|
||||
return AppDefaults.date(for: Key.lastImageCacheFlushDate)
|
||||
}
|
||||
set {
|
||||
setDate(for: Key.lastImageCacheFlushDate, newValue)
|
||||
AppDefaults.setDate(for: Key.lastImageCacheFlushDate, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var openInBrowserInBackground: Bool {
|
||||
var openInBrowserInBackground: Bool {
|
||||
get {
|
||||
return bool(for: Key.openInBrowserInBackground)
|
||||
return AppDefaults.bool(for: Key.openInBrowserInBackground)
|
||||
}
|
||||
set {
|
||||
setBool(for: Key.openInBrowserInBackground, newValue)
|
||||
AppDefaults.setBool(for: Key.openInBrowserInBackground, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var sidebarFontSize: FontSize {
|
||||
var sidebarFontSize: FontSize {
|
||||
get {
|
||||
return fontSize(for: Key.sidebarFontSize)
|
||||
}
|
||||
set {
|
||||
setFontSize(for: Key.sidebarFontSize, newValue)
|
||||
AppDefaults.setFontSize(for: Key.sidebarFontSize, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var timelineFontSize: FontSize {
|
||||
var timelineFontSize: FontSize {
|
||||
get {
|
||||
return fontSize(for: Key.timelineFontSize)
|
||||
}
|
||||
set {
|
||||
setFontSize(for: Key.timelineFontSize, newValue)
|
||||
AppDefaults.setFontSize(for: Key.timelineFontSize, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var detailFontSize: FontSize {
|
||||
var detailFontSize: FontSize {
|
||||
get {
|
||||
return fontSize(for: Key.detailFontSize)
|
||||
}
|
||||
set {
|
||||
setFontSize(for: Key.detailFontSize, newValue)
|
||||
AppDefaults.setFontSize(for: Key.detailFontSize, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var addWebFeedAccountID: String? {
|
||||
var addWebFeedAccountID: String? {
|
||||
get {
|
||||
return string(for: Key.addWebFeedAccountID)
|
||||
return AppDefaults.string(for: Key.addWebFeedAccountID)
|
||||
}
|
||||
set {
|
||||
setString(for: Key.addWebFeedAccountID, newValue)
|
||||
AppDefaults.setString(for: Key.addWebFeedAccountID, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var addWebFeedFolderName: String? {
|
||||
var addWebFeedFolderName: String? {
|
||||
get {
|
||||
return string(for: Key.addWebFeedFolderName)
|
||||
return AppDefaults.string(for: Key.addWebFeedFolderName)
|
||||
}
|
||||
set {
|
||||
setString(for: Key.addWebFeedFolderName, newValue)
|
||||
AppDefaults.setString(for: Key.addWebFeedFolderName, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var addFolderAccountID: String? {
|
||||
var addFolderAccountID: String? {
|
||||
get {
|
||||
return string(for: Key.addFolderAccountID)
|
||||
return AppDefaults.string(for: Key.addFolderAccountID)
|
||||
}
|
||||
set {
|
||||
setString(for: Key.addFolderAccountID, newValue)
|
||||
AppDefaults.setString(for: Key.addFolderAccountID, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var importOPMLAccountID: String? {
|
||||
var importOPMLAccountID: String? {
|
||||
get {
|
||||
return string(for: Key.importOPMLAccountID)
|
||||
return AppDefaults.string(for: Key.importOPMLAccountID)
|
||||
}
|
||||
set {
|
||||
setString(for: Key.importOPMLAccountID, newValue)
|
||||
AppDefaults.setString(for: Key.importOPMLAccountID, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var exportOPMLAccountID: String? {
|
||||
var exportOPMLAccountID: String? {
|
||||
get {
|
||||
return string(for: Key.exportOPMLAccountID)
|
||||
return AppDefaults.string(for: Key.exportOPMLAccountID)
|
||||
}
|
||||
set {
|
||||
setString(for: Key.exportOPMLAccountID, newValue)
|
||||
AppDefaults.setString(for: Key.exportOPMLAccountID, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var defaultBrowserID: String? {
|
||||
var defaultBrowserID: String? {
|
||||
get {
|
||||
return string(for: Key.defaultBrowserID)
|
||||
return AppDefaults.string(for: Key.defaultBrowserID)
|
||||
}
|
||||
set {
|
||||
setString(for: Key.defaultBrowserID, newValue)
|
||||
AppDefaults.setString(for: Key.defaultBrowserID, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var showTitleOnMainWindow: Bool {
|
||||
return bool(for: Key.showTitleOnMainWindow)
|
||||
var showTitleOnMainWindow: Bool {
|
||||
return AppDefaults.bool(for: Key.showTitleOnMainWindow)
|
||||
}
|
||||
|
||||
static var showDebugMenu: Bool {
|
||||
return bool(for: Key.showDebugMenu)
|
||||
var showDebugMenu: Bool {
|
||||
return AppDefaults.bool(for: Key.showDebugMenu)
|
||||
}
|
||||
|
||||
static var hideDockUnreadCount: Bool {
|
||||
return bool(for: Key.hideDockUnreadCount)
|
||||
var hideDockUnreadCount: Bool {
|
||||
return AppDefaults.bool(for: Key.hideDockUnreadCount)
|
||||
}
|
||||
|
||||
#if !MAC_APP_STORE
|
||||
static var webInspectorEnabled: Bool {
|
||||
var webInspectorEnabled: Bool {
|
||||
get {
|
||||
return bool(for: Key.webInspectorEnabled)
|
||||
return AppDefaults.bool(for: Key.webInspectorEnabled)
|
||||
}
|
||||
set {
|
||||
setBool(for: Key.webInspectorEnabled, newValue)
|
||||
AppDefaults.setBool(for: Key.webInspectorEnabled, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var webInspectorStartsAttached: Bool {
|
||||
var webInspectorStartsAttached: Bool {
|
||||
get {
|
||||
return bool(for: Key.webInspectorStartsAttached)
|
||||
return AppDefaults.bool(for: Key.webInspectorStartsAttached)
|
||||
}
|
||||
set {
|
||||
setBool(for: Key.webInspectorStartsAttached, newValue)
|
||||
AppDefaults.setBool(for: Key.webInspectorStartsAttached, newValue)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static var timelineSortDirection: ComparisonResult {
|
||||
var timelineSortDirection: ComparisonResult {
|
||||
get {
|
||||
return sortDirection(for: Key.timelineSortDirection)
|
||||
return AppDefaults.sortDirection(for: Key.timelineSortDirection)
|
||||
}
|
||||
set {
|
||||
setSortDirection(for: Key.timelineSortDirection, newValue)
|
||||
AppDefaults.setSortDirection(for: Key.timelineSortDirection, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var timelineGroupByFeed: Bool {
|
||||
var timelineGroupByFeed: Bool {
|
||||
get {
|
||||
return bool(for: Key.timelineGroupByFeed)
|
||||
return AppDefaults.bool(for: Key.timelineGroupByFeed)
|
||||
}
|
||||
set {
|
||||
setBool(for: Key.timelineGroupByFeed, newValue)
|
||||
AppDefaults.setBool(for: Key.timelineGroupByFeed, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static var timelineShowsSeparators: Bool {
|
||||
return bool(for: Key.timelineShowsSeparators)
|
||||
var timelineShowsSeparators: Bool {
|
||||
return AppDefaults.bool(for: Key.timelineShowsSeparators)
|
||||
}
|
||||
|
||||
static var refreshInterval: RefreshInterval {
|
||||
var refreshInterval: RefreshInterval {
|
||||
get {
|
||||
let rawValue = UserDefaults.standard.integer(forKey: Key.refreshInterval)
|
||||
return RefreshInterval(rawValue: rawValue) ?? RefreshInterval.everyHour
|
||||
|
@ -246,7 +249,7 @@ struct AppDefaults {
|
|||
}
|
||||
}
|
||||
|
||||
static func registerDefaults() {
|
||||
func registerDefaults() {
|
||||
#if DEBUG
|
||||
let showDebugMenu = true
|
||||
#else
|
||||
|
@ -278,7 +281,7 @@ struct AppDefaults {
|
|||
// TODO: revisit the above when coming back to state restoration issues.
|
||||
}
|
||||
|
||||
static func actualFontSize(for fontSize: FontSize) -> CGFloat {
|
||||
func actualFontSize(for fontSize: FontSize) -> CGFloat {
|
||||
switch fontSize {
|
||||
case .small:
|
||||
return NSFont.systemFontSize
|
||||
|
@ -296,14 +299,14 @@ private extension AppDefaults {
|
|||
|
||||
static var firstRunDate: Date? {
|
||||
get {
|
||||
return date(for: Key.firstRunDate)
|
||||
return AppDefaults.date(for: Key.firstRunDate)
|
||||
}
|
||||
set {
|
||||
setDate(for: Key.firstRunDate, newValue)
|
||||
AppDefaults.setDate(for: Key.firstRunDate, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
static func fontSize(for key: String) -> FontSize {
|
||||
func fontSize(for key: String) -> FontSize {
|
||||
// Punted till after 1.0.
|
||||
return .medium
|
||||
|
||||
|
|
|
@ -191,8 +191,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
}
|
||||
#endif
|
||||
|
||||
AppDefaults.registerDefaults()
|
||||
let isFirstRun = AppDefaults.isFirstRun
|
||||
AppDefaults.shared.registerDefaults()
|
||||
let isFirstRun = AppDefaults.shared.isFirstRun
|
||||
if isFirstRun {
|
||||
logDebugMessage("Is first run.")
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
UNUserNotificationCenter.current().delegate = self
|
||||
userNotificationManager = UserNotificationManager()
|
||||
|
||||
if AppDefaults.showDebugMenu {
|
||||
if AppDefaults.shared.showDebugMenu {
|
||||
refreshTimer!.update()
|
||||
syncTimer!.update()
|
||||
|
||||
|
@ -417,7 +417,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
}
|
||||
#if !MAC_APP_STORE
|
||||
if item.action == #selector(toggleWebInspectorEnabled(_:)) {
|
||||
(item as! NSMenuItem).state = AppDefaults.webInspectorEnabled ? .on : .off
|
||||
(item as! NSMenuItem).state = AppDefaults.shared.webInspectorEnabled ? .on : .off
|
||||
}
|
||||
#endif
|
||||
return true
|
||||
|
@ -447,7 +447,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
|
||||
// MARK: - Dock Badge
|
||||
@objc func updateDockBadge() {
|
||||
let label = unreadCount > 0 && !AppDefaults.hideDockUnreadCount ? "\(unreadCount)" : ""
|
||||
let label = unreadCount > 0 && !AppDefaults.shared.hideDockUnreadCount ? "\(unreadCount)" : ""
|
||||
NSApplication.shared.dockTile.badgeLabel = label
|
||||
}
|
||||
|
||||
|
@ -624,16 +624,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
|
||||
@IBAction func sortByOldestArticleOnTop(_ sender: Any?) {
|
||||
|
||||
AppDefaults.timelineSortDirection = .orderedAscending
|
||||
AppDefaults.shared.timelineSortDirection = .orderedAscending
|
||||
}
|
||||
|
||||
@IBAction func sortByNewestArticleOnTop(_ sender: Any?) {
|
||||
|
||||
AppDefaults.timelineSortDirection = .orderedDescending
|
||||
AppDefaults.shared.timelineSortDirection = .orderedDescending
|
||||
}
|
||||
|
||||
@IBAction func groupByFeedToggled(_ sender: NSMenuItem) {
|
||||
AppDefaults.timelineGroupByFeed.toggle()
|
||||
AppDefaults.shared.timelineGroupByFeed.toggle()
|
||||
}
|
||||
|
||||
@IBAction func checkForUpdates(_ sender: Any?) {
|
||||
|
@ -680,13 +680,13 @@ extension AppDelegate {
|
|||
|
||||
@IBAction func toggleWebInspectorEnabled(_ sender: Any?) {
|
||||
#if !MAC_APP_STORE
|
||||
let newValue = !AppDefaults.webInspectorEnabled
|
||||
AppDefaults.webInspectorEnabled = newValue
|
||||
let newValue = !AppDefaults.shared.webInspectorEnabled
|
||||
AppDefaults.shared.webInspectorEnabled = newValue
|
||||
|
||||
// An attached inspector can display incorrectly on certain setups (like mine); default to displaying in a separate window,
|
||||
// and reset the default to a separate window when the preference is toggled off and on again in case the inspector is
|
||||
// accidentally reattached.
|
||||
AppDefaults.webInspectorStartsAttached = false
|
||||
AppDefaults.shared.webInspectorStartsAttached = false
|
||||
NotificationCenter.default.post(name: .WebInspectorEnabledDidChange, object: newValue)
|
||||
#endif
|
||||
}
|
||||
|
@ -717,13 +717,13 @@ private extension AppDelegate {
|
|||
|
||||
func updateSortMenuItems() {
|
||||
|
||||
let sortByNewestOnTop = AppDefaults.timelineSortDirection == .orderedDescending
|
||||
let sortByNewestOnTop = AppDefaults.shared.timelineSortDirection == .orderedDescending
|
||||
sortByNewestArticleOnTopMenuItem.state = sortByNewestOnTop ? .on : .off
|
||||
sortByOldestArticleOnTopMenuItem.state = sortByNewestOnTop ? .off : .on
|
||||
}
|
||||
|
||||
func updateGroupByFeedMenuItem() {
|
||||
let groupByFeedEnabled = AppDefaults.timelineGroupByFeed
|
||||
let groupByFeedEnabled = AppDefaults.shared.timelineGroupByFeed
|
||||
groupArticlesByFeedMenuItem.state = groupByFeedEnabled ? .on : .off
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ struct Browser {
|
|||
/// The user-assigned default browser, or `nil` if none was assigned
|
||||
/// (i.e., the system default should be used).
|
||||
static var defaultBrowser: MacWebBrowser? {
|
||||
if let bundleID = AppDefaults.defaultBrowserID, let browser = MacWebBrowser(bundleIdentifier: bundleID) {
|
||||
if let bundleID = AppDefaults.shared.defaultBrowserID, let browser = MacWebBrowser(bundleIdentifier: bundleID) {
|
||||
return browser
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ struct Browser {
|
|||
/// - invert: Whether to invert the "open in background in browser" preference
|
||||
static func open(_ urlString: String, invertPreference invert: Bool = false) {
|
||||
// Opens according to prefs.
|
||||
open(urlString, inBackground: invert ? !AppDefaults.openInBrowserInBackground : AppDefaults.openInBrowserInBackground)
|
||||
open(urlString, inBackground: invert ? !AppDefaults.shared.openInBrowserInBackground : AppDefaults.shared.openInBrowserInBackground)
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ struct Browser {
|
|||
extension Browser {
|
||||
|
||||
static var titleForOpenInBrowserInverted: String {
|
||||
let openInBackgroundPref = AppDefaults.openInBrowserInBackground
|
||||
let openInBackgroundPref = AppDefaults.shared.openInBrowserInBackground
|
||||
|
||||
return openInBackgroundPref ?
|
||||
NSLocalizedString("Open in Browser in Foreground", comment: "Open in Browser in Foreground menu item title") :
|
||||
|
|
|
@ -36,7 +36,7 @@ class AddFolderWindowController : NSWindowController {
|
|||
// MARK: - NSViewController
|
||||
|
||||
override func windowDidLoad() {
|
||||
let preferredAccountID = AppDefaults.addFolderAccountID
|
||||
let preferredAccountID = AppDefaults.shared.addFolderAccountID
|
||||
accountPopupButton.removeAllItems()
|
||||
|
||||
let menu = NSMenu()
|
||||
|
@ -93,7 +93,7 @@ private extension AddFolderWindowController {
|
|||
}
|
||||
|
||||
let account = menuItem.representedObject as! Account
|
||||
AppDefaults.addFolderAccountID = account.accountID
|
||||
AppDefaults.shared.addFolderAccountID = account.accountID
|
||||
|
||||
let folderName = self.folderNameTextField.stringValue
|
||||
if folderName.isEmpty {
|
||||
|
|
|
@ -116,7 +116,7 @@ final class DetailWebViewController: NSViewController, WKUIDelegate {
|
|||
waitingForFirstReload = true
|
||||
|
||||
#if !MAC_APP_STORE
|
||||
webInspectorEnabled = AppDefaults.webInspectorEnabled
|
||||
webInspectorEnabled = AppDefaults.shared.webInspectorEnabled
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(webInspectorEnabledDidChange(_:)), name: .WebInspectorEnabledDidChange, object: nil)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||
|
||||
sharingServicePickerDelegate = SharingServicePickerDelegate(self.window)
|
||||
|
||||
if !AppDefaults.showTitleOnMainWindow {
|
||||
if !AppDefaults.shared.showTitleOnMainWindow {
|
||||
window?.titleVisibility = .hidden
|
||||
}
|
||||
|
||||
|
@ -116,12 +116,12 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||
}
|
||||
|
||||
func saveStateToUserDefaults() {
|
||||
AppDefaults.windowState = savableState()
|
||||
AppDefaults.shared.windowState = savableState()
|
||||
window?.saveFrame(usingName: windowAutosaveName)
|
||||
}
|
||||
|
||||
func restoreStateFromUserDefaults() {
|
||||
if let state = AppDefaults.windowState {
|
||||
if let state = AppDefaults.shared.windowState {
|
||||
restoreState(from: state)
|
||||
window?.setFrameUsingName(windowAutosaveName, force: true)
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||
|
||||
@IBAction func openInBrowserUsingOppositeOfSettings(_ sender: Any?) {
|
||||
if let link = currentLink {
|
||||
Browser.open(link, inBackground: !AppDefaults.openInBrowserInBackground)
|
||||
Browser.open(link, inBackground: !AppDefaults.shared.openInBrowserInBackground)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -819,7 +819,7 @@ private extension MainWindowController {
|
|||
}
|
||||
|
||||
func validateToggleArticleExtractor(_ item: NSValidatedUserInterfaceItem) -> Bool {
|
||||
guard !AppDefaults.isDeveloperBuild else {
|
||||
guard !AppDefaults.shared.isDeveloperBuild else {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ private extension NNW3ImportController {
|
|||
guard let account = accessoryViewController.selectedAccount else {
|
||||
return
|
||||
}
|
||||
AppDefaults.importOPMLAccountID = account.accountID
|
||||
AppDefaults.shared.importOPMLAccountID = account.accountID
|
||||
|
||||
NNW3ImportController.importSubscriptionsPlist(subscriptionsPlistURL, into: account)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ final class NNW3OpenPanelAccessoryViewController: NSViewController {
|
|||
menuItem.representedObject = account
|
||||
menu.addItem(menuItem)
|
||||
|
||||
if account.accountID == AppDefaults.importOPMLAccountID {
|
||||
if account.accountID == AppDefaults.shared.importOPMLAccountID {
|
||||
accountPopUpButton.select(menuItem)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class ExportOPMLWindowController: NSWindowController {
|
|||
oneMenuItem.representedObject = oneAccount
|
||||
menu.addItem(oneMenuItem)
|
||||
|
||||
if oneAccount.accountID == AppDefaults.exportOPMLAccountID {
|
||||
if oneAccount.accountID == AppDefaults.shared.exportOPMLAccountID {
|
||||
accountPopUpButton.select(oneMenuItem)
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class ExportOPMLWindowController: NSWindowController {
|
|||
}
|
||||
|
||||
let account = menuItem.representedObject as! Account
|
||||
AppDefaults.exportOPMLAccountID = account.accountID
|
||||
AppDefaults.shared.exportOPMLAccountID = account.accountID
|
||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||
exportOPML(account: account)
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class ImportOPMLWindowController: NSWindowController {
|
|||
oneMenuItem.representedObject = oneAccount
|
||||
menu.addItem(oneMenuItem)
|
||||
|
||||
if oneAccount.accountID == AppDefaults.importOPMLAccountID {
|
||||
if oneAccount.accountID == AppDefaults.shared.importOPMLAccountID {
|
||||
accountPopUpButton.select(oneMenuItem)
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class ImportOPMLWindowController: NSWindowController {
|
|||
}
|
||||
|
||||
let account = menuItem.representedObject as! Account
|
||||
AppDefaults.importOPMLAccountID = account.accountID
|
||||
AppDefaults.shared.importOPMLAccountID = account.accountID
|
||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||
importOPML(account: account)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ struct SidebarCellAppearance: Equatable {
|
|||
let textFieldFont: NSFont
|
||||
|
||||
init(fontSize: FontSize) {
|
||||
self.textFieldFontSize = AppDefaults.actualFontSize(for: fontSize)
|
||||
self.textFieldFontSize = AppDefaults.shared.actualFontSize(for: fontSize)
|
||||
self.textFieldFont = NSFont.systemFont(ofSize: textFieldFontSize)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ protocol SidebarDelegate: class {
|
|||
// MARK: - NSViewController
|
||||
|
||||
override func viewDidLoad() {
|
||||
sidebarCellAppearance = SidebarCellAppearance(fontSize: AppDefaults.sidebarFontSize)
|
||||
sidebarCellAppearance = SidebarCellAppearance(fontSize: AppDefaults.shared.sidebarFontSize)
|
||||
|
||||
outlineView.dataSource = dataSource
|
||||
outlineView.doubleAction = #selector(doubleClickedSidebar(_:))
|
||||
|
|
|
@ -44,7 +44,7 @@ struct TimelineCellAppearance: Equatable {
|
|||
|
||||
init(showIcon: Bool, fontSize: FontSize) {
|
||||
|
||||
let actualFontSize = AppDefaults.actualFontSize(for: fontSize)
|
||||
let actualFontSize = AppDefaults.shared.actualFontSize(for: fontSize)
|
||||
let smallItemFontSize = floor(actualFontSize * 0.90)
|
||||
let largeItemFontSize = actualFontSize
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class TimelineTableCellView: NSTableCellView {
|
|||
return [self.dateView, self.feedNameView, self.titleView, self.summaryView, self.textView]
|
||||
}()
|
||||
|
||||
private var showsSeparator: Bool = AppDefaults.timelineShowsSeparators {
|
||||
private var showsSeparator: Bool = AppDefaults.shared.timelineShowsSeparators {
|
||||
didSet {
|
||||
separatorView.isHidden = !showsSeparator
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class TimelineTableCellView: NSTableCellView {
|
|||
}
|
||||
|
||||
func timelineShowsSeparatorsDefaultDidChange() {
|
||||
showsSeparator = AppDefaults.timelineShowsSeparators
|
||||
showsSeparator = AppDefaults.shared.timelineShowsSeparators
|
||||
}
|
||||
|
||||
override func setFrameSize(_ newSize: NSSize) {
|
||||
|
@ -209,7 +209,7 @@ private extension TimelineTableCellView {
|
|||
addSubviewAtInit(feedNameView, hidden: true)
|
||||
addSubviewAtInit(iconView, hidden: true)
|
||||
addSubviewAtInit(starView, hidden: true)
|
||||
addSubviewAtInit(separatorView, hidden: !AppDefaults.timelineShowsSeparators)
|
||||
addSubviewAtInit(separatorView, hidden: !AppDefaults.shared.timelineShowsSeparators)
|
||||
|
||||
makeTextFieldColorsNormal()
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ private extension TimelineContainerViewController {
|
|||
func updateViewOptionsPopUpButton() {
|
||||
let localizedTitle = NSLocalizedString("Sort %@", comment: "Sort")
|
||||
|
||||
if AppDefaults.timelineSortDirection == .orderedAscending {
|
||||
if AppDefaults.shared.timelineSortDirection == .orderedAscending {
|
||||
newestToOldestMenuItem.state = .off
|
||||
oldestToNewestMenuItem.state = .on
|
||||
let title = NSString.localizedStringWithFormat(localizedTitle as NSString, oldestToNewestMenuItem.title) as String
|
||||
|
@ -179,7 +179,7 @@ private extension TimelineContainerViewController {
|
|||
viewOptionsPopUpButton.setTitle(title)
|
||||
}
|
||||
|
||||
if AppDefaults.timelineGroupByFeed == true {
|
||||
if AppDefaults.shared.timelineGroupByFeed == true {
|
||||
groupByFeedMenuItem.state = .on
|
||||
} else {
|
||||
groupByFeedMenuItem.state = .off
|
||||
|
|
|
@ -142,21 +142,21 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||
private var didRegisterForNotifications = false
|
||||
static let fetchAndMergeArticlesQueue = CoalescingQueue(name: "Fetch and Merge Articles", interval: 0.5, maxInterval: 2.0)
|
||||
|
||||
private var sortDirection = AppDefaults.timelineSortDirection {
|
||||
private var sortDirection = AppDefaults.shared.timelineSortDirection {
|
||||
didSet {
|
||||
if sortDirection != oldValue {
|
||||
sortParametersDidChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
private var groupByFeed = AppDefaults.timelineGroupByFeed {
|
||||
private var groupByFeed = AppDefaults.shared.timelineGroupByFeed {
|
||||
didSet {
|
||||
if groupByFeed != oldValue {
|
||||
sortParametersDidChange()
|
||||
}
|
||||
}
|
||||
}
|
||||
private var fontSize: FontSize = AppDefaults.timelineFontSize {
|
||||
private var fontSize: FontSize = AppDefaults.shared.timelineFontSize {
|
||||
didSet {
|
||||
if fontSize != oldValue {
|
||||
fontSizeDidChange()
|
||||
|
@ -611,9 +611,9 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||
}
|
||||
|
||||
@objc func userDefaultsDidChange(_ note: Notification) {
|
||||
self.fontSize = AppDefaults.timelineFontSize
|
||||
self.sortDirection = AppDefaults.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.timelineGroupByFeed
|
||||
self.fontSize = AppDefaults.shared.timelineFontSize
|
||||
self.sortDirection = AppDefaults.shared.timelineSortDirection
|
||||
self.groupByFeed = AppDefaults.shared.timelineGroupByFeed
|
||||
}
|
||||
|
||||
// MARK: - Reloading Data
|
||||
|
|
|
@ -171,7 +171,7 @@ private extension AccountsAddViewController {
|
|||
}
|
||||
}
|
||||
|
||||
if AppDefaults.isDeveloperBuild {
|
||||
if AppDefaults.shared.isDeveloperBuild {
|
||||
removeAccountType(.cloudKit)
|
||||
removeAccountType(.feedly)
|
||||
removeAccountType(.feedWrangler)
|
||||
|
|
|
@ -55,7 +55,7 @@ final class GeneralPreferencesViewController: NSViewController {
|
|||
return
|
||||
}
|
||||
let bundleID = menuItem.representedObject as? String
|
||||
AppDefaults.defaultBrowserID = bundleID
|
||||
AppDefaults.shared.defaultBrowserID = bundleID
|
||||
updateUI()
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ private extension GeneralPreferencesViewController {
|
|||
menu.addItem(item)
|
||||
}
|
||||
|
||||
defaultBrowserPopup.selectItem(at: defaultBrowserPopup.indexOfItem(withRepresentedObject: AppDefaults.defaultBrowserID))
|
||||
defaultBrowserPopup.selectItem(at: defaultBrowserPopup.indexOfItem(withRepresentedObject: AppDefaults.shared.defaultBrowserID))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue