mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-19 21:13:22 +01:00
Assign keyboard shortcuts to filters and change clean up shortcut. Issue #1842
This commit is contained in:
parent
9f516caa35
commit
97226f543b
@ -139,13 +139,19 @@ private extension KeyboardManager {
|
||||
keys.append(KeyboardManager.createKeyCommand(title: goToStarredTitle, action: "goToStarred:", input: "3", modifiers: [.command]))
|
||||
|
||||
let articleSearchTitle = NSLocalizedString("Article Search", comment: "Article Search")
|
||||
keys.append(KeyboardManager.createKeyCommand(title: articleSearchTitle, action: "articleSearch:", input: "f", modifiers: [.command, .shift]))
|
||||
keys.append(KeyboardManager.createKeyCommand(title: articleSearchTitle, action: "articleSearch:", input: "f", modifiers: [.command, .alternate]))
|
||||
|
||||
let markAllAsReadTitle = NSLocalizedString("Mark All as Read", comment: "Mark All as Read")
|
||||
keys.append(KeyboardManager.createKeyCommand(title: markAllAsReadTitle, action: "markAllAsRead:", input: "k", modifiers: [.command]))
|
||||
|
||||
let cleanUp = NSLocalizedString("Clean Up", comment: "Clean Up")
|
||||
keys.append(KeyboardManager.createKeyCommand(title: cleanUp, action: "cleanUp:", input: "h", modifiers: [.command, .shift]))
|
||||
keys.append(KeyboardManager.createKeyCommand(title: cleanUp, action: "cleanUp:", input: "`", modifiers: [.command]))
|
||||
|
||||
let toggleReadFeedsFilter = NSLocalizedString("Toggle Read Feeds Filter", comment: "Toggle Read Feeds Filter")
|
||||
keys.append(KeyboardManager.createKeyCommand(title: toggleReadFeedsFilter, action: "toggleReadFeedsFilter:", input: "f", modifiers: [.command, .shift]))
|
||||
|
||||
let toggleReadArticlesFilter = NSLocalizedString("Toggle Read Articles Filter", comment: "Toggle Read Articles Filter")
|
||||
keys.append(KeyboardManager.createKeyCommand(title: toggleReadArticlesFilter, action: "toggleReadArticlesFilter:", input: "h", modifiers: [.command, .shift]))
|
||||
|
||||
return keys
|
||||
}
|
||||
|
@ -378,13 +378,7 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
}
|
||||
|
||||
@IBAction func toggleFilter(_ sender: Any) {
|
||||
if coordinator.isReadFeedsFiltered {
|
||||
setFilterButtonToInactive()
|
||||
coordinator.showAllFeeds()
|
||||
} else {
|
||||
setFilterButtonToActive()
|
||||
coordinator.hideReadFeeds()
|
||||
}
|
||||
coordinator.toggleReadFeedsFilter()
|
||||
}
|
||||
|
||||
@IBAction func add(_ sender: UIBarButtonItem) {
|
||||
@ -509,6 +503,16 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
|
||||
}
|
||||
}
|
||||
|
||||
func updateUI() {
|
||||
if coordinator.isReadFeedsFiltered {
|
||||
setFilterButtonToActive()
|
||||
} else {
|
||||
setFilterButtonToInactive()
|
||||
}
|
||||
refreshProgressView?.updateRefreshLabel()
|
||||
addNewItemButton?.isEnabled = !AccountManager.shared.activeAccounts.isEmpty
|
||||
}
|
||||
|
||||
func focus() {
|
||||
becomeFirstResponder()
|
||||
}
|
||||
@ -580,16 +584,6 @@ private extension MasterFeedViewController {
|
||||
toolbarItems?.insert(refreshProgressItemButton, at: 2)
|
||||
}
|
||||
|
||||
func updateUI() {
|
||||
if coordinator.isReadFeedsFiltered {
|
||||
setFilterButtonToActive()
|
||||
} else {
|
||||
setFilterButtonToInactive()
|
||||
}
|
||||
refreshProgressView?.updateRefreshLabel()
|
||||
addNewItemButton?.isEnabled = !AccountManager.shared.activeAccounts.isEmpty
|
||||
}
|
||||
|
||||
func setFilterButtonToActive() {
|
||||
filterButton?.image = AppAssets.filterActiveImage
|
||||
filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Feeds", comment: "Selected - Filter Read Feeds")
|
||||
|
@ -111,13 +111,7 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
|
||||
|
||||
// MARK: Actions
|
||||
@IBAction func toggleFilter(_ sender: Any) {
|
||||
if coordinator.isReadArticlesFiltered {
|
||||
setFilterButtonToInactive()
|
||||
coordinator.showAllArticles()
|
||||
} else {
|
||||
setFilterButtonToActive()
|
||||
coordinator.hideReadArticles()
|
||||
}
|
||||
coordinator.toggleReadArticlesFilter()
|
||||
}
|
||||
|
||||
@IBAction func markAllAsRead(_ sender: Any) {
|
||||
@ -589,11 +583,13 @@ private extension MasterTimelineViewController {
|
||||
}
|
||||
|
||||
if coordinator.isReadArticlesFiltered {
|
||||
setFilterButtonToActive()
|
||||
filterButton?.image = AppAssets.filterActiveImage
|
||||
filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Articles", comment: "Selected - Filter Read Articles")
|
||||
} else {
|
||||
setFilterButtonToInactive()
|
||||
filterButton?.image = AppAssets.filterInactiveImage
|
||||
filterButton?.accLabelText = NSLocalizedString("Filter Read Articles", comment: "Filter Read Articles")
|
||||
}
|
||||
|
||||
|
||||
tableView.selectRow(at: nil, animated: false, scrollPosition: .top)
|
||||
if resetScroll && dataSource.snapshot().itemIdentifiers(inSection: 0).count > 0 {
|
||||
tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false)
|
||||
@ -603,16 +599,6 @@ private extension MasterTimelineViewController {
|
||||
|
||||
}
|
||||
|
||||
func setFilterButtonToActive() {
|
||||
filterButton?.image = AppAssets.filterActiveImage
|
||||
filterButton?.accLabelText = NSLocalizedString("Selected - Filter Read Articles", comment: "Selected - Filter Read Articles")
|
||||
}
|
||||
|
||||
func setFilterButtonToInactive() {
|
||||
filterButton?.image = AppAssets.filterInactiveImage
|
||||
filterButton?.accLabelText = NSLocalizedString("Filter Read Articles", comment: "Filter Read Articles")
|
||||
}
|
||||
|
||||
func updateToolbar() {
|
||||
markAllAsReadButton.isEnabled = coordinator.isTimelineUnreadAvailable
|
||||
firstUnreadButton.isEnabled = coordinator.isTimelineUnreadAvailable
|
||||
|
@ -94,6 +94,14 @@ class RootSplitViewController: UISplitViewController {
|
||||
coordinator.cleanUp()
|
||||
}
|
||||
|
||||
@objc func toggleReadFeedsFilter(_ sender: Any?) {
|
||||
coordinator.toggleReadFeedsFilter()
|
||||
}
|
||||
|
||||
@objc func toggleReadArticlesFilter(_ sender: Any?) {
|
||||
coordinator.toggleReadArticlesFilter()
|
||||
}
|
||||
|
||||
@objc func refresh(_ sender: Any?) {
|
||||
appDelegate.manualRefresh(errorHandler: ErrorHandler.present(self))
|
||||
}
|
||||
|
@ -581,6 +581,30 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
}
|
||||
}
|
||||
|
||||
func toggleReadFeedsFilter() {
|
||||
if isReadFeedsFiltered {
|
||||
treeControllerDelegate.isReadFiltered = false
|
||||
} else {
|
||||
treeControllerDelegate.isReadFiltered = true
|
||||
}
|
||||
rebuildBackingStores()
|
||||
masterFeedViewController?.updateUI()
|
||||
}
|
||||
|
||||
func toggleReadArticlesFilter() {
|
||||
guard let feedID = timelineFeed?.feedID else {
|
||||
return
|
||||
}
|
||||
|
||||
if isReadArticlesFiltered {
|
||||
readFilterEnabledTable[feedID] = false
|
||||
} else {
|
||||
readFilterEnabledTable[feedID] = true
|
||||
}
|
||||
|
||||
refreshTimeline(resetScroll: false)
|
||||
}
|
||||
|
||||
func shadowNodesFor(section: Int) -> [Node] {
|
||||
return shadowTable[section]
|
||||
}
|
||||
@ -617,30 +641,6 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
||||
}
|
||||
}
|
||||
|
||||
func showAllFeeds() {
|
||||
treeControllerDelegate.isReadFiltered = false
|
||||
rebuildBackingStores()
|
||||
}
|
||||
|
||||
func hideReadFeeds() {
|
||||
treeControllerDelegate.isReadFiltered = true
|
||||
rebuildBackingStores()
|
||||
}
|
||||
|
||||
func showAllArticles() {
|
||||
if let feedID = timelineFeed?.feedID {
|
||||
readFilterEnabledTable[feedID] = false
|
||||
}
|
||||
refreshTimeline(resetScroll: false)
|
||||
}
|
||||
|
||||
func hideReadArticles() {
|
||||
if let feedID = timelineFeed?.feedID {
|
||||
readFilterEnabledTable[feedID] = true
|
||||
}
|
||||
refreshTimeline(resetScroll: false)
|
||||
}
|
||||
|
||||
func isExpanded(_ containerIdentifiable: ContainerIdentifiable) -> Bool {
|
||||
if let containerID = containerIdentifiable.containerID {
|
||||
return expandedTable.contains(containerID)
|
||||
|
Loading…
Reference in New Issue
Block a user