parent
c91106a1bb
commit
3e7dc4ddc6
1 changed files with 11 additions and 6 deletions
|
@ -40,7 +40,7 @@ class OpenFilePickerUseCase @Inject constructor(
|
||||||
|
|
||||||
if (isZenityInstalled) {
|
if (isZenityInstalled) {
|
||||||
val command = when (pickerType) {
|
val command = when (pickerType) {
|
||||||
PickerType.FILES, PickerType.FILES_AND_DIRECTORIES -> listOf(
|
PickerType.FILES -> listOf(
|
||||||
"zenity",
|
"zenity",
|
||||||
"--file-selection",
|
"--file-selection",
|
||||||
"--title=Open"
|
"--title=Open"
|
||||||
|
@ -70,15 +70,21 @@ class OpenFilePickerUseCase @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMac) {
|
if (isMac) {
|
||||||
System.setProperty("apple.awt.fileDialogForDirectories", "true")
|
if (pickerType == PickerType.DIRECTORIES) {
|
||||||
val fileChooser = if (basePath.isNullOrEmpty())
|
System.setProperty("apple.awt.fileDialogForDirectories", "true")
|
||||||
|
}
|
||||||
|
|
||||||
|
val fileChooser = if (basePath.isNullOrEmpty()) {
|
||||||
FileDialog(null as java.awt.Frame?, "Open", FileDialog.LOAD)
|
FileDialog(null as java.awt.Frame?, "Open", FileDialog.LOAD)
|
||||||
else
|
} else {
|
||||||
FileDialog(null as java.awt.Frame?, "Open", FileDialog.LOAD).apply {
|
FileDialog(null as java.awt.Frame?, "Open", FileDialog.LOAD).apply {
|
||||||
directory = basePath
|
directory = basePath
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fileChooser.isMultipleMode = false
|
fileChooser.isMultipleMode = false
|
||||||
fileChooser.isVisible = true
|
fileChooser.isVisible = true
|
||||||
|
|
||||||
System.setProperty("apple.awt.fileDialogForDirectories", "false")
|
System.setProperty("apple.awt.fileDialogForDirectories", "false")
|
||||||
|
|
||||||
if (fileChooser.file != null && fileChooser.directory != null) {
|
if (fileChooser.file != null && fileChooser.directory != null) {
|
||||||
|
@ -103,6 +109,5 @@ class OpenFilePickerUseCase @Inject constructor(
|
||||||
|
|
||||||
enum class PickerType(val value: Int) {
|
enum class PickerType(val value: Int) {
|
||||||
FILES(JFileChooser.FILES_ONLY),
|
FILES(JFileChooser.FILES_ONLY),
|
||||||
DIRECTORIES(JFileChooser.DIRECTORIES_ONLY),
|
DIRECTORIES(JFileChooser.DIRECTORIES_ONLY);
|
||||||
FILES_AND_DIRECTORIES(JFileChooser.FILES_AND_DIRECTORIES);
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue