|
@@ -229,11 +229,13 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
|
|
|
var files: [Any] = []
|
|
|
var selectFiles: [URL] = []
|
|
|
-
|
|
|
+ var selectFiles_shift: [Int] = []
|
|
|
+
|
|
|
var showMode: HistoryFileShowMode!
|
|
|
open weak var delete: KMHomeHistoryFileViewControllerDelegate?
|
|
|
|
|
|
- var allowMultipleChoices: Bool!
|
|
|
+ var allowMultipleChoices_cmd: Bool!
|
|
|
+ var allowMultipleChoices_shift: Bool!
|
|
|
var multipleChoices: [KMBox] = []
|
|
|
var multipleChoicesInts: [Int] = []
|
|
|
|
|
@@ -253,7 +255,8 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
|
|
|
initializeUI()
|
|
|
initLocalization()
|
|
|
- allowMultipleChoices = true
|
|
|
+ allowMultipleChoices_cmd = false
|
|
|
+ allowMultipleChoices_shift = false
|
|
|
|
|
|
if UserDefaults.standard.bool(forKey: "kFileListViewListModeKey") {
|
|
|
showMode = .List
|
|
@@ -401,7 +404,7 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
}
|
|
|
|
|
|
func multipleChoicesAction(choiceBox box: KMBox, choiceRow row: Int) -> Void {
|
|
|
- if allowMultipleChoices {
|
|
|
+ if allowMultipleChoices_cmd {
|
|
|
if multipleChoices.contains(box) {
|
|
|
box.fillColor = .clear
|
|
|
multipleChoices.removeObject(box)
|
|
@@ -409,6 +412,11 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
multipleChoices.append(box)
|
|
|
}
|
|
|
|
|
|
+ for box in multipleChoices {
|
|
|
+ box.fillColor = NSColor(red: 37/255.0, green: 139/255.0, blue: 251/255.0, alpha: 1.0)
|
|
|
+ }
|
|
|
+ } else if allowMultipleChoices_shift {
|
|
|
+
|
|
|
for box in multipleChoices {
|
|
|
box.fillColor = NSColor(red: 37/255.0, green: 139/255.0, blue: 251/255.0, alpha: 1.0)
|
|
|
}
|
|
@@ -425,12 +433,14 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
}
|
|
|
|
|
|
func multipleChoicesIntsAction(choiceRow row: Int) -> Void {
|
|
|
- if allowMultipleChoices {
|
|
|
+ if allowMultipleChoices_cmd {
|
|
|
if multipleChoicesInts.contains(row) {
|
|
|
multipleChoicesInts.removeObject(row)
|
|
|
} else {
|
|
|
multipleChoicesInts.append(row)
|
|
|
}
|
|
|
+ } else if allowMultipleChoices_shift {
|
|
|
+
|
|
|
} else {
|
|
|
multipleChoicesInts.removeAll()
|
|
|
multipleChoicesInts.append(row)
|
|
@@ -440,11 +450,21 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
override func flagsChanged(with event: NSEvent) {
|
|
|
super.flagsChanged(with: event)
|
|
|
if event.type == .flagsChanged {
|
|
|
- if event.keyCode == 58 {
|
|
|
- if allowMultipleChoices {
|
|
|
- allowMultipleChoices = false
|
|
|
+ if event.keyCode == 55 { // cmd
|
|
|
+ if allowMultipleChoices_cmd {
|
|
|
+ selectFiles_shift.removeAll()
|
|
|
+ allowMultipleChoices_cmd = false
|
|
|
+ } else {
|
|
|
+ allowMultipleChoices_cmd = true
|
|
|
+ allowMultipleChoices_shift = false
|
|
|
+ }
|
|
|
+ } else if event.keyCode == 56 { // shift
|
|
|
+ if allowMultipleChoices_shift {
|
|
|
+ selectFiles_shift.removeAll()
|
|
|
+ allowMultipleChoices_shift = false
|
|
|
} else {
|
|
|
- allowMultipleChoices = true
|
|
|
+ allowMultipleChoices_shift = true
|
|
|
+ allowMultipleChoices_cmd = false
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -519,10 +539,53 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
item.refreshUI(url)
|
|
|
item.mainBox.downCallback = { [self](downEntered: Bool, mouseBox: KMBox) -> Void in
|
|
|
if downEntered {
|
|
|
- if selectFiles.contains(url) {
|
|
|
- selectFiles.removeObject(url)
|
|
|
+ if allowMultipleChoices_shift {
|
|
|
+ if selectFiles_shift.count == 0 {
|
|
|
+ selectFiles.append(url)
|
|
|
+ selectFiles_shift.append(i)
|
|
|
+ } else if selectFiles_shift.count == 1 {
|
|
|
+ let first = selectFiles_shift[0] as Int
|
|
|
+ selectFiles.removeAll()
|
|
|
+ if first > i {
|
|
|
+ for path in files[i...first] {
|
|
|
+ selectFiles.append(path as! URL)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for path in files[first...i] {
|
|
|
+ selectFiles.append(path as! URL)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ selectFiles_shift.append(i)
|
|
|
+ } else if selectFiles_shift.count == 2 {
|
|
|
+ let first = selectFiles_shift[0] as Int
|
|
|
+ selectFiles.removeAll()
|
|
|
+ if first > i {
|
|
|
+ for path in files[i...first] {
|
|
|
+ selectFiles.append(path as! URL)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for path in files[first...i] {
|
|
|
+ selectFiles.append(path as! URL)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ selectFiles_shift[1] = i
|
|
|
+ }
|
|
|
+ } else if allowMultipleChoices_cmd {
|
|
|
+ if selectFiles.contains(url) {
|
|
|
+ selectFiles.removeObject(url)
|
|
|
+ } else {
|
|
|
+ selectFiles.append(url)
|
|
|
+ }
|
|
|
+ if selectFiles_shift.contains(i) {
|
|
|
+ selectFiles_shift.removeObject(i)
|
|
|
+ } else {
|
|
|
+ selectFiles_shift.append(i)
|
|
|
+ }
|
|
|
} else {
|
|
|
+ selectFiles.removeAll()
|
|
|
+ selectFiles_shift.removeAll()
|
|
|
selectFiles.append(url)
|
|
|
+ selectFiles_shift.append(i)
|
|
|
}
|
|
|
collectionView.reloadData()
|
|
|
}
|
|
@@ -578,10 +641,53 @@ class KMHomeHistoryFileViewController: NSViewController, NSCollectionViewDelegat
|
|
|
cellView.highlightCell(multipleChoicesInts, row)
|
|
|
cellView.mainBox.downCallback = { [self](downEntered: Bool, mouseBox: KMBox) -> Void in
|
|
|
if downEntered {
|
|
|
- if selectFiles.contains(url) {
|
|
|
- selectFiles.removeObject(url)
|
|
|
+ if allowMultipleChoices_shift {
|
|
|
+ if selectFiles_shift.count == 0 {
|
|
|
+ selectFiles.append(url)
|
|
|
+ selectFiles_shift.append(row)
|
|
|
+ } else if selectFiles_shift.count == 1 {
|
|
|
+ let first = selectFiles_shift[0] as Int
|
|
|
+ selectFiles.removeAll()
|
|
|
+ if first > row {
|
|
|
+ for path in files[row...first] {
|
|
|
+ selectFiles.append(path as! URL)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for path in files[first...row] {
|
|
|
+ selectFiles.append(path as! URL)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ selectFiles_shift.append(row)
|
|
|
+ } else if selectFiles_shift.count == 2 {
|
|
|
+ let first = selectFiles_shift[0] as Int
|
|
|
+ selectFiles.removeAll()
|
|
|
+ if first > row {
|
|
|
+ for path in files[row...first] {
|
|
|
+ selectFiles.append(path as! URL)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for path in files[first...row] {
|
|
|
+ selectFiles.append(path as! URL)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ selectFiles_shift[1] = row
|
|
|
+ }
|
|
|
+ } else if allowMultipleChoices_cmd {
|
|
|
+ if selectFiles.contains(url) {
|
|
|
+ selectFiles.removeObject(url)
|
|
|
+ } else {
|
|
|
+ selectFiles.append(url)
|
|
|
+ }
|
|
|
+ if selectFiles_shift.contains(row) {
|
|
|
+ selectFiles_shift.removeObject(row)
|
|
|
+ } else {
|
|
|
+ selectFiles_shift.append(row)
|
|
|
+ }
|
|
|
} else {
|
|
|
+ selectFiles.removeAll()
|
|
|
+ selectFiles_shift.removeAll()
|
|
|
selectFiles.append(url)
|
|
|
+ selectFiles_shift.append(row)
|
|
|
}
|
|
|
tableView.reloadData()
|
|
|
}
|