|
@@ -335,7 +335,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
NSArrayController *groupedFindArrayController;
|
|
|
}
|
|
|
|
|
|
- @property (nonatomic, assign) BOOL isAscendSort;
|
|
|
@property (nonatomic, retain) NSView *filterButtonLayer;
|
|
|
@property (nonatomic, retain) KMButtonLayer *moreButtonLayer;
|
|
|
|
|
@@ -412,6 +411,7 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
private let LABEL_COLUMNID = "label"
|
|
|
var foldType: KMFoldAllAnnotationType = .none
|
|
|
private let KMLeftSideViewNoteSortTypeKey = "KMLeftSideViewNoteSortTypeKey"
|
|
|
+ private let KMLeftSideViewAscendSortBoolKey = "KMLeftSideViewAscendSortBoolKey"
|
|
|
|
|
|
private var _noteSortType: KMNoteSortType = .none
|
|
|
var noteSortType: KMNoteSortType {
|
|
@@ -425,6 +425,12 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var isAscendSort = false {
|
|
|
+ didSet {
|
|
|
+ NotificationCenter.default.post(name: NSNotification.Name(rawValue: "KMAnnotationSortTypeKeyNotification"), object: self)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
lazy var leftSideEmptyVC: KMLeftSideEmptyFileViewController = {
|
|
|
let vc = KMLeftSideEmptyFileViewController(nibName: "KMLeftSideEmptyFileViewController", bundle: nil)
|
|
|
vc.view.wantsLayer = true
|
|
@@ -656,14 +662,14 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
}
|
|
|
self.sortTypeLabel.textColor = KMAppearance.Layout.h1Color()
|
|
|
|
|
|
-// _isAscendSort = [sud boolForKey:KMLeftSideViewAscendSortBoolKey];
|
|
|
-// if (_isAscendSort) {
|
|
|
-// [_noteSortButton setImage:[NSImage imageNamed:KMImageNameBtnSidebarRankReverse]];
|
|
|
-// [_noteSortButton setToolTip:NSLocalizedString(@"ascending sort", nil)];
|
|
|
-// } else {
|
|
|
-// [_noteSortButton setImage:[NSImage imageNamed:KMImageNameBtnSidebarRankPositive]];
|
|
|
-// [_noteSortButton setToolTip:NSLocalizedString(@"descending sort", nil)];
|
|
|
-// }
|
|
|
+ self.isAscendSort = sud.bool(forKey: KMLeftSideViewAscendSortBoolKey)
|
|
|
+ if (self.isAscendSort) {
|
|
|
+ self.noteSortButton.image = NSImage(named: KMImageNameBtnSidebarRankReverse)
|
|
|
+ self.noteSortButton.toolTip = KMLocalizedString("ascending sort", nil)
|
|
|
+ } else {
|
|
|
+ self.noteSortButton.image = NSImage(named: KMImageNameBtnSidebarRankPositive)
|
|
|
+ self.noteSortButton.toolTip = KMLocalizedString("descending sort", nil)
|
|
|
+ }
|
|
|
|
|
|
self.sortTypeBox.downCallback = { [unowned self] downEntered, mouseBox, _ in
|
|
|
if (downEntered) {
|
|
@@ -1087,31 +1093,6 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
|
|
|
[self.noteSearchField becomeFirstResponder];
|
|
|
}
|
|
|
-
|
|
|
- - (IBAction)noteSortAction:(id)sender {
|
|
|
- if (self.isAscendSort) {
|
|
|
- self.isAscendSort = NO;
|
|
|
- [self.noteSortButton setImage:[NSImage imageNamed:KMImageNameBtnSidebarRankPositive]];
|
|
|
- [self.noteSortButton setToolTip:NSLocalizedString(@"descending sort", nil)];
|
|
|
- } else {
|
|
|
- self.isAscendSort = YES;
|
|
|
- [self.noteSortButton setImage:[NSImage imageNamed:KMImageNameBtnSidebarRankReverse]];
|
|
|
- [self.noteSortButton setToolTip:NSLocalizedString(@"ascending sort", nil)];
|
|
|
- }
|
|
|
- [[NSUserDefaults standardUserDefaults] setBool:self.isAscendSort forKey:KMLeftSideViewAscendSortBoolKey];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- #pragma mark - get && set
|
|
|
-
|
|
|
- - (void)setIsAscendSort:(BOOL)isAscendSort {
|
|
|
- _isAscendSort = isAscendSort;
|
|
|
-
|
|
|
- [[NSNotificationCenter defaultCenter] postNotificationName:@"KMAnnotationSortTypeKeyNotification" object:self userInfo:nil];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
*/
|
|
|
|
|
|
func resetThumbnails() {
|
|
@@ -1184,6 +1165,20 @@ class KMLeftSideViewController: KMSideViewController {
|
|
|
UserDefaults.standard.set(self.noteSortType.rawValue, forKey: KMLeftSideViewNoteSortTypeKey)
|
|
|
UserDefaults.standard.synchronize()
|
|
|
}
|
|
|
+
|
|
|
+ @IBAction func noteSortAction(_ sender: AnyObject?) {
|
|
|
+ if (self.isAscendSort) {
|
|
|
+ self.isAscendSort = false
|
|
|
+ self.noteSortButton.image = NSImage(named: KMImageNameBtnSidebarRankPositive)
|
|
|
+ self.noteSortButton.toolTip = KMLocalizedString("descending sort", nil)
|
|
|
+ } else {
|
|
|
+ self.isAscendSort = true
|
|
|
+ self.noteSortButton.image = NSImage(named: KMImageNameBtnSidebarRankReverse)
|
|
|
+ self.noteSortButton.toolTip = KMLocalizedString("ascending sort", nil)
|
|
|
+ }
|
|
|
+ UserDefaults.standard.setValue(self.isAscendSort, forKey: KMLeftSideViewAscendSortBoolKey)
|
|
|
+ UserDefaults.standard.synchronize()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//MARK: NSTableViewDelegate,NSTableViewDataSource
|