mirror of
https://github.com/dev-claw/vripper-project.git
synced 2026-08-19 08:35:41 +02:00
open gallery folder option missing on right click (#111)
This commit is contained in:
@@ -81,6 +81,11 @@
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.java.dev.jna</groupId>
|
||||
<artifactId>jna-platform</artifactId>
|
||||
<version>5.13.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package me.mnlr.vripper.utils
|
||||
|
||||
import com.sun.jna.Native
|
||||
import com.sun.jna.WString
|
||||
import com.sun.jna.platform.win32.ShellAPI
|
||||
import com.sun.jna.platform.win32.WinDef
|
||||
import com.sun.jna.win32.StdCallLibrary
|
||||
|
||||
interface Shell32 : ShellAPI, StdCallLibrary {
|
||||
fun ShellExecuteW(
|
||||
hwnd: WinDef.HWND?,
|
||||
lpOperation: WString?,
|
||||
lpFile: WString?,
|
||||
lpParameters: WString?,
|
||||
lpDirectory: WString?,
|
||||
nShowCmd: Int
|
||||
): WinDef.HINSTANCE?
|
||||
|
||||
companion object {
|
||||
val INSTANCE = Native.load(
|
||||
"shell32",
|
||||
Shell32::class.java
|
||||
) as Shell32
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.mnlr.vripper.view.tables
|
||||
|
||||
import com.sun.jna.WString
|
||||
import javafx.collections.FXCollections
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.scene.control.*
|
||||
@@ -9,6 +10,7 @@ import me.mnlr.vripper.controller.PostController
|
||||
import me.mnlr.vripper.event.Event
|
||||
import me.mnlr.vripper.event.EventBus
|
||||
import me.mnlr.vripper.model.PostModel
|
||||
import me.mnlr.vripper.utils.Shell32
|
||||
import tornadofx.*
|
||||
|
||||
|
||||
@@ -107,8 +109,17 @@ class PostsTableView : View("Download") {
|
||||
detailsIcon.fitHeight = 18.0
|
||||
detailsItem.graphic = detailsIcon
|
||||
|
||||
val locationItem = MenuItem("Open Download Directory")
|
||||
locationItem.setOnAction {
|
||||
openFileDirectory(tableRow.item.path)
|
||||
}
|
||||
val locationIcon = ImageView("file-explorer.png")
|
||||
locationIcon.fitWidth = 18.0
|
||||
locationIcon.fitHeight = 18.0
|
||||
locationItem.graphic = locationIcon
|
||||
|
||||
contextMenu.items.addAll(
|
||||
startItem, stopItem, deleteItem, SeparatorMenuItem(), detailsItem
|
||||
startItem, stopItem, deleteItem, SeparatorMenuItem(), detailsItem, locationItem
|
||||
)
|
||||
tableRow.contextMenuProperty()
|
||||
.bind(tableRow.emptyProperty().map { empty -> if (empty) null else contextMenu })
|
||||
@@ -157,6 +168,17 @@ class PostsTableView : View("Download") {
|
||||
}
|
||||
}
|
||||
|
||||
private fun openFileDirectory(path: String) {
|
||||
val os = System.getProperty("os.name")
|
||||
if(os.contains("Windows")) {
|
||||
Shell32.INSTANCE.ShellExecuteW(null, WString("open"), WString(path), null, null, 1)
|
||||
} else if(os.contains("Linux")) {
|
||||
Runtime.getRuntime().exec("xdg-open $path")
|
||||
} else if(os.contains("Mac")) {
|
||||
Runtime.getRuntime().exec("open -R $path")
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteSelected() {
|
||||
val postIdList = tableView.selectionModel.selectedItems.map { it.postId }
|
||||
confirm(
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 364 B |
Reference in New Issue
Block a user