diff --git a/Evergreen/MainWindow/Sidebar/Keyboard/SidebarKeyboardShortcuts.plist b/Evergreen/MainWindow/Sidebar/Keyboard/SidebarKeyboardShortcuts.plist index 79f41b411..6ff6c91de 100644 --- a/Evergreen/MainWindow/Sidebar/Keyboard/SidebarKeyboardShortcuts.plist +++ b/Evergreen/MainWindow/Sidebar/Keyboard/SidebarKeyboardShortcuts.plist @@ -6,41 +6,25 @@ key , action - sidebarCollapse: - - - key - [leftarrow] - action - sidebarCollapse: - commandModifier - + collapseSelectedRows: key . action - sidebarExpand: - - - key - [rightarrow] - action - sidebarExpand: - commandModifier - + expandSelectedRows: key ; action - sidebarCollapseAll: + collapseAllExceptForGroupItems: key [leftarrow] action - sidebarCollapseAll: + collapseAllExceptForGroupItems: commandModifier optionModifier @@ -50,13 +34,13 @@ key ' action - sidebarExpandAll: + expandAll: key [rightarrow] action - sidebarExpandAll: + expandAll: commandModifier optionModifier diff --git a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift index 7b1e97f28..d5874943e 100644 --- a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift +++ b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift @@ -135,7 +135,6 @@ import RSCore // MARK: Navigation - func canGoToNextUnread() -> Bool { if let _ = rowContainingNextUnread() { diff --git a/Evergreen/Resources/KeyboardShortcuts/KeyboardShortcuts.html b/Evergreen/Resources/KeyboardShortcuts/KeyboardShortcuts.html index a4984e930..2f3ece27e 100644 --- a/Evergreen/Resources/KeyboardShortcuts/KeyboardShortcuts.html +++ b/Evergreen/Resources/KeyboardShortcuts/KeyboardShortcuts.html @@ -52,9 +52,9 @@ Left sidebar only… -Collapse, or cmd-leftArrow -Expand. or cmd-rightArrow -Collapse All; or option-cmd-leftArrow +Collapse, or option-leftArrow +Expand. or option-rightArrow +Collapse All (except for group items); or option-cmd-leftArrow Expand All' or option-cmd-rightArrow Move focus to headlinesrightArrow diff --git a/Frameworks/RSCore/RSCore/NSOutlineView+Extensions.swift b/Frameworks/RSCore/RSCore/NSOutlineView+Extensions.swift index de2e6e041..7bd4525e2 100755 --- a/Frameworks/RSCore/RSCore/NSOutlineView+Extensions.swift +++ b/Frameworks/RSCore/RSCore/NSOutlineView+Extensions.swift @@ -22,4 +22,79 @@ public extension NSOutlineView { } } } + + @IBAction func collapseSelectedRows(_ sender: Any?) { + + for item in selectedItems { + if isExpandable(item) && isItemExpanded(item) { + collapseItem(item) + } + } + } + + @IBAction func expandSelectedRows(_ sender: Any?) { + + for item in selectedItems { + if isExpandable(item) && !isItemExpanded(item) { + expandItem(item) + } + } + } + + @IBAction func expandAll(_ sender: Any?) { + + expandAllChildren(of: nil) + } + + @IBAction func collapseAllExceptForGroupItems(_ sender: Any?) { + + collapseAllChildren(of: nil, exceptForGroupItems: true) + } + + func expandAllChildren(of item: Any?) { + + guard let childItems = children(of: item) else { + return + } + + for child in childItems { + if !isItemExpanded(child) && isExpandable(child) { + expandItem(child, expandChildren: true) + } + expandAllChildren(of: child) + } + } + + func collapseAllChildren(of item: Any?, exceptForGroupItems: Bool) { + + guard let childItems = children(of: item) else { + return + } + + for child in childItems { + collapseAllChildren(of: child, exceptForGroupItems: exceptForGroupItems) + if exceptForGroupItems && isGroupItem(child) { + continue + } + if isItemExpanded(child) { + collapseItem(child, collapseChildren: true) + } + } + } + + func children(of item: Any?) -> [Any]? { + + var children = [Any]() + for indexOfItem in 0.. Bool { + + return delegate?.outlineView?(self, isGroupItem: item) ?? false + } }