This commit is contained in:
Damiano Galassi committed 2017-08-01 11:25:04 +02:00
1 parent be30acd177
commit 747eb97682
1 file changed
+9 -5
+9 -5
View File
@@ -7,7 +7,6 @@
import Cocoa import Cocoa
@objc protocol ChapterSearchControllerDelegate { @objc protocol ChapterSearchControllerDelegate {
func chapterImportDone(chaptersToBeImported: [MP42TextSample]) func chapterImportDone(chaptersToBeImported: [MP42TextSample])
} }
@@ -113,6 +112,12 @@ import Cocoa
} }
@IBAction func closeWindow(_ sender: Any) { @IBAction func closeWindow(_ sender: Any) {
switch state {
case .searching(let task):
task.cancel()
default:
break
}
self.window?.sheetParent?.endSheet(self.window!, returnCode: NSApplication.ModalResponse.cancel) self.window?.sheetParent?.endSheet(self.window!, returnCode: NSApplication.ModalResponse.cancel)
} }
@@ -121,8 +126,8 @@ import Cocoa
private func updateUI() { private func updateUI() {
switch state { switch state {
case .none: case .none:
searchButton.isEnabled = true; searchButton.isEnabled = true
searchButton.keyEquivalent = "\r"; searchButton.keyEquivalent = "\r"
case .searching(_): case .searching(_):
progress.startAnimation(self) progress.startAnimation(self)
progress.isHidden = false progress.isHidden = false
@@ -138,7 +143,7 @@ import Cocoa
searchButton.keyEquivalent = "" searchButton.keyEquivalent = ""
} }
else { else {
searchButton.keyEquivalent = "\r"; searchButton.keyEquivalent = "\r"
addButton.isEnabled = false addButton.isEnabled = false
addButton.keyEquivalent = "" addButton.keyEquivalent = ""
} }
@@ -213,7 +218,6 @@ import Cocoa
else if tableColumn?.identifier.rawValue == "name" { else if tableColumn?.identifier.rawValue == "name" {
return chapter.name return chapter.name
} }
} }
return nil return nil
} }