Skip to content

Commit

Permalink
🐛 Fix icon path error issue on Linux (#2102)
Browse files Browse the repository at this point in the history
  • Loading branch information
guiyanakuang authored Oct 21, 2024
1 parent 1e64b9c commit fa05241
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@ import com.crosspaste.app.AppLaunchState
import com.crosspaste.app.DesktopAppSize
import com.crosspaste.app.DesktopAppWindowManager
import com.crosspaste.app.ExitMode
import com.crosspaste.utils.DesktopResourceUtils
import com.crosspaste.composeapp.generated.resources.Res
import com.crosspaste.utils.GlobalCoroutineScopeImpl.mainCoroutineDispatcher
import dorkbox.systemTray.MenuItem
import dorkbox.systemTray.SystemTray
import dorkbox.systemTray.SystemTray.TrayType
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.launch
import org.jetbrains.compose.resources.ExperimentalResourceApi
import org.koin.compose.koinInject
import java.awt.GraphicsEnvironment
import java.awt.Toolkit
import java.net.URL

object LinuxTrayView {

val logger = KotlinLogging.logger {}

@OptIn(ExperimentalResourceApi::class)
@Composable
fun Tray() {
val applicationExit = LocalExitApplication.current
Expand All @@ -50,7 +53,7 @@ object LinuxTrayView {
}

LaunchedEffect(Unit) {
tray?.setImage(DesktopResourceUtils.resourceInputStream("icon/crosspaste.png"))
tray?.setImage(URL(Res.getUri("drawable/crosspaste.png")).openStream())
tray?.setTooltip("CrossPaste")
tray?.menu?.add(
MenuItem("Open CrossPaste") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ import java.util.Properties

object DesktopResourceUtils {

fun resourceInputStream(fileName: String): InputStream {
return ClassLoaderResourceLoader.load(fileName)
}

fun loadProperties(fileName: String): Properties {
val properties = Properties()
InputStreamReader(resourceInputStream(fileName), StandardCharsets.UTF_8).use { inputStreamReader ->
val inputStream = ClassLoaderResourceLoader.load(fileName)
InputStreamReader(inputStream, StandardCharsets.UTF_8).use { inputStreamReader ->
properties.load(inputStreamReader)
}
return properties
Expand Down

0 comments on commit fa05241

Please sign in to comment.