From 142ce582e6b427a4590db50d4e0d9f4bb5625b51 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Sun, 6 Sep 2020 13:22:35 -0400 Subject: [PATCH] Replace binding with IBAction/IBOutlet for Hide Unread Count checkbox --- Mac/Base.lproj/Preferences.storyboard | 53 ++++++++----------- .../GeneralPrefencesViewController.swift | 14 ++++- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/Mac/Base.lproj/Preferences.storyboard b/Mac/Base.lproj/Preferences.storyboard index 1f112dedc..ea5a4d76a 100644 --- a/Mac/Base.lproj/Preferences.storyboard +++ b/Mac/Base.lproj/Preferences.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -138,18 +139,7 @@ - - - - - - - - - - NSNegateBoolean - - + @@ -198,6 +188,7 @@ + @@ -383,16 +374,16 @@ - + - + - + - + @@ -411,7 +402,7 @@ - + @@ -423,7 +414,7 @@ - + @@ -499,7 +490,7 @@ - + @@ -554,16 +545,16 @@ - + - + - + - + @@ -582,7 +573,7 @@ - + @@ -594,7 +585,7 @@ - + @@ -666,7 +657,7 @@ - + @@ -701,8 +692,8 @@ - - - + + + diff --git a/Mac/Preferences/General/GeneralPrefencesViewController.swift b/Mac/Preferences/General/GeneralPrefencesViewController.swift index aa720d4e1..1db9a0ddb 100644 --- a/Mac/Preferences/General/GeneralPrefencesViewController.swift +++ b/Mac/Preferences/General/GeneralPrefencesViewController.swift @@ -13,7 +13,8 @@ import RSWeb final class GeneralPreferencesViewController: NSViewController { @IBOutlet var defaultBrowserPopup: NSPopUpButton! - + @IBOutlet weak var showUnreadCountCheckbox: NSButton! + public override init(nibName nibNameOrNil: NSNib.Name?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) commonInit() @@ -45,6 +46,12 @@ final class GeneralPreferencesViewController: NSViewController { AppDefaults.shared.defaultBrowserID = bundleID updateUI() } + + + @IBAction func toggleShowingUnreadCount(_ sender: Any) { + guard let checkbox = sender as? NSButton else { return } + AppDefaults.shared.hideDockUnreadCount = checkbox.state.rawValue == 0 + } } // MARK: - Private @@ -57,6 +64,7 @@ private extension GeneralPreferencesViewController { func updateUI() { updateBrowserPopup() + updateHideUnreadCountCheckbox() } func updateBrowserPopup() { @@ -89,4 +97,8 @@ private extension GeneralPreferencesViewController { defaultBrowserPopup.selectItem(at: defaultBrowserPopup.indexOfItem(withRepresentedObject: AppDefaults.shared.defaultBrowserID)) } + + func updateHideUnreadCountCheckbox() { + showUnreadCountCheckbox.state = AppDefaults.shared.hideDockUnreadCount ? .off : .on + } }