Skip to content

Commit afef20a

Browse files
committed
Try out packaging, the thirteenth. (Remove jars, fix Linux issue)
1 parent f1fad78 commit afef20a

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

.github/workflows/release-matrix.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ jobs:
347347
run: |
348348
set -euo pipefail
349349
mkdir -p dist
350-
cp build/libs/tritium.jar "dist/tritium-${{ matrix.platform }}-${{ matrix.arch }}.jar"
351350
352351
- name: Package Windows Portable Bundle
353352
if: runner.os == 'Windows'

src/main/kotlin/io/github/footermandev/tritium/ui/theme/TIcons.kt

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import io.qt.core.Qt
77
import io.qt.gui.QIcon
88
import io.qt.gui.QPixmap
99
import io.qt.widgets.QWidget
10+
import java.io.File
11+
import java.nio.file.Files
1012
import java.util.concurrent.ConcurrentHashMap
1113
import kotlin.math.ceil
1214

@@ -144,5 +146,33 @@ object TIcons {
144146
}
145147
}
146148

147-
internal val defaultProjectIcon = javaClass.getResource("/icons/folder.png")!!.path
148-
}
149+
internal val defaultProjectIcon: String by lazy {
150+
resolveFileResource("/icons/folder.png")
151+
?: renderFolderIconToTempPng()
152+
?: ""
153+
}
154+
155+
private fun resolveFileResource(path: String): String? {
156+
val url = javaClass.getResource(path) ?: return null
157+
return try {
158+
if(url.protocol == "file") File(url.toURI()).absolutePath else null
159+
} catch (_: Throwable) {
160+
null
161+
}
162+
}
163+
164+
private fun renderFolderIconToTempPng(): String? {
165+
return try {
166+
val pix = ThemeMngr.getIcon("file/folder", 16, 16, 1.0)?.pixmap(16, 16)
167+
if(pix == null || pix.isNull) {
168+
null
169+
} else {
170+
val temp = Files.createTempFile("tritium-default-folder-", ".png").toFile()
171+
temp.deleteOnExit()
172+
if(pix.save(temp.absolutePath, "PNG")) temp.absolutePath else null
173+
}
174+
} catch (_: Throwable) {
175+
null
176+
}
177+
}
178+
}

0 commit comments

Comments
 (0)