mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
fix: background image selection failure
This commit is contained in:
@@ -22,8 +22,7 @@ class BackgroundManager private constructor() {
|
|||||||
fun setBackgroundImage(file: File) {
|
fun setBackgroundImage(file: File) {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
try {
|
try {
|
||||||
|
bufferedImage = file.inputStream().use { ImageIO.read(it) }
|
||||||
bufferedImage = ImageIO.read(file)
|
|
||||||
imageFilepath = file.absolutePath
|
imageFilepath = file.absolutePath
|
||||||
appearance.backgroundImage = file.absolutePath
|
appearance.backgroundImage = file.absolutePath
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import java.awt.event.ItemListener
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
import java.nio.file.StandardCopyOption
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
import javax.swing.*
|
import javax.swing.*
|
||||||
@@ -276,7 +277,8 @@ class SettingsOptionsPane : OptionsPane() {
|
|||||||
try {
|
try {
|
||||||
val destFile = FileUtils.getFile(Application.getBaseDataDir(), "background", file.name)
|
val destFile = FileUtils.getFile(Application.getBaseDataDir(), "background", file.name)
|
||||||
FileUtils.forceMkdirParent(destFile)
|
FileUtils.forceMkdirParent(destFile)
|
||||||
FileUtils.copyFile(file, destFile)
|
FileUtils.deleteQuietly(destFile)
|
||||||
|
FileUtils.copyFile(file, destFile, StandardCopyOption.REPLACE_EXISTING)
|
||||||
backgroundImageTextField.text = destFile.name
|
backgroundImageTextField.text = destFile.name
|
||||||
BackgroundManager.getInstance().setBackgroundImage(destFile)
|
BackgroundManager.getInstance().setBackgroundImage(destFile)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
Reference in New Issue
Block a user