[BUG] Show import/export panel as modal panel.

This approach would ensure the panel show in most front and in center of screen.
This commit is contained in:
Charlie Qiu
2017-01-17 02:07:33 +08:00
parent e5c8e965d4
commit f730c5cba2

View File

@ -79,7 +79,7 @@ class ServerProfileManager: NSObject {
openPanel.canCreateDirectories = false openPanel.canCreateDirectories = false
openPanel.canChooseFiles = true openPanel.canChooseFiles = true
openPanel.becomeKey() openPanel.becomeKey()
openPanel.begin { (result) -> Void in let result = openPanel.runModal()
if (result == NSFileHandlingPanelOKButton && (openPanel.url) != nil) { if (result == NSFileHandlingPanelOKButton && (openPanel.url) != nil) {
let fileManager = FileManager.default let fileManager = FileManager.default
let filePath:String = (openPanel.url?.path)! let filePath:String = (openPanel.url?.path)!
@ -124,7 +124,6 @@ class ServerProfileManager: NSObject {
} }
} }
} }
}
func exportConfigFile() { func exportConfigFile() {
//exampleconfigsNSDictionaryconfigs //exampleconfigsNSDictionaryconfigs
@ -164,7 +163,7 @@ class ServerProfileManager: NSObject {
savePanel.allowedFileTypes = ["json"] savePanel.allowedFileTypes = ["json"]
savePanel.nameFieldStringValue = "export.json" savePanel.nameFieldStringValue = "export.json"
savePanel.becomeKey() savePanel.becomeKey()
savePanel.begin { (result) -> Void in let result = savePanel.runModal()
if (result == NSFileHandlingPanelOKButton && (savePanel.url) != nil) { if (result == NSFileHandlingPanelOKButton && (savePanel.url) != nil) {
//write jsonArr1 back to file //write jsonArr1 back to file
try! jsonString.write(toFile: (savePanel.url?.path)!, atomically: true, encoding: String.Encoding.utf8) try! jsonString.write(toFile: (savePanel.url?.path)!, atomically: true, encoding: String.Encoding.utf8)
@ -176,7 +175,6 @@ class ServerProfileManager: NSObject {
.deliver(notification) .deliver(notification)
} }
} }
}
class func showExampleConfigFile() { class func showExampleConfigFile() {
//copy file to ~/Downloads folder //copy file to ~/Downloads folder