Unified · Split
| @@ -25,22 +25,26 @@ class Dialog { · 24 unmodified lines | ||
| 25 | 25 | self.option = option |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | − func openFiles() -> [String]? { | |
| 28 | + func openFiles(title: String? = nil, path: URL? = nil) -> [String]? { | |
| 29 | 29 | let types: [UTType] = (TypeHelper.toStringArray(option?.root.video_exts) + |
| 30 | 30 | TypeHelper.toStringArray(option?.root.audio_exts) + |
| 31 | 31 | TypeHelper.toStringArray(option?.root.image_exts) + |
| 32 | 32 | TypeHelper.toStringArray(option?.root.archive_exts) + |
| 33 | 33 | TypeHelper.toStringArray(option?.root.playlist_exts)).compactMap { UTType(filenameExtension: $0) } |
| 34 | − return open(types: types) | |
| 34 | + return open(title: title, path: path, types: types) | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | − func openPlaylist() -> String? { | |
| 37 | + func openPlaylist(title: String? = nil, path: URL? = nil) -> String? { | |
| 38 | 38 | let types: [UTType] = TypeHelper.toStringArray(option?.root.playlist_exts).compactMap { UTType(filenameExtension: $0) } |
| 39 | − return open(directories: false, multiple: false, types: types)?.first | |
| 39 | + return open(title: title, path: path, directories: false, multiple: false, types: types)?.first | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | − func open(directories: Bool = true, multiple: Bool = true, types: [UTType] = []) -> [String]? { | |
| 42 | + func open(title: String? = nil, path: URL? = nil, files: Bool = true, | |
| 43 | + directories: Bool = true, multiple: Bool = true, types: [UTType] = []) -> [String]? { | |
| 43 | 44 | let panel = NSOpenPanel() |
| 45 | + panel.title = title ?? panel.title | |
| 46 | + panel.directoryURL = path | |
| 47 | + panel.canChooseFiles = files | |
| 44 | 48 | panel.canChooseDirectories = directories |
| 45 | 49 | panel.allowsMultipleSelection = multiple |
| 46 | 50 | panel.allowedContentTypes = types |