chore: improve wsl

This commit is contained in:
hstyi
2025-06-25 11:59:06 +08:00
committed by hstyi
parent 891688d0ca
commit a2a02c0bad
4 changed files with 16 additions and 8 deletions

View File

@@ -2,9 +2,10 @@ package app.termora
import com.formdev.flatlaf.extras.FlatSVGIcon
open class DynamicIcon(name: String, private val darkName: String) : FlatSVGIcon(name) {
open class DynamicIcon(name: String, private val darkName: String, val allowColorFilter: Boolean = true) :
FlatSVGIcon(name) {
constructor(name: String) : this(name, name)
val dark by lazy { DynamicIcon(darkName, name) }
val dark by lazy { DynamicIcon(darkName, name, allowColorFilter) }
}

View File

@@ -40,7 +40,12 @@ object Icons {
val error by lazy { DynamicIcon("icons/error.svg", "icons/error_dark.svg") }
val cwmUsers by lazy { DynamicIcon("icons/cwmUsers.svg", "icons/cwmUsers_dark.svg") }
val cwmPermissions by lazy { DynamicIcon("icons/cwmPermissions.svg", "icons/cwmPermissions_dark.svg") }
val warningIntroduction by lazy { DynamicIcon("icons/warningIntroduction.svg", "icons/warningIntroduction_dark.svg") }
val warningIntroduction by lazy {
DynamicIcon(
"icons/warningIntroduction.svg",
"icons/warningIntroduction_dark.svg"
)
}
val networkPolicy by lazy { DynamicIcon("icons/networkPolicy.svg", "icons/networkPolicy_dark.svg") }
val clusterRole by lazy { DynamicIcon("icons/clusterRole.svg", "icons/clusterRole_dark.svg") }
val daemonSets by lazy { DynamicIcon("icons/daemonSets.svg", "icons/daemonSets_dark.svg") }
@@ -91,7 +96,7 @@ object Icons {
val digitalocean by lazy { DynamicIcon("icons/digitalocean.svg", "icons/digitalocean_dark.svg") }
val terminalUnread by lazy { DynamicIcon("icons/terminalUnread.svg", "icons/terminalUnread_dark.svg") }
val dbPrimitive by lazy { DynamicIcon("icons/dbPrimitive.svg", "icons/dbPrimitive_dark.svg") }
val linux by lazy { DynamicIcon("icons/linux.svg", "icons/linux_dark.svg") }
val linux by lazy { DynamicIcon("icons/linux.svg", "icons/linux_dark.svg", false) }
val debian by lazy { DynamicIcon("icons/debian.svg") }
val fedora by lazy { DynamicIcon("icons/fedora.svg") }
val almalinux by lazy { DynamicIcon("icons/almalinux.svg") }

View File

@@ -29,12 +29,14 @@ internal open class WSLHostOptionsPane : OptionsPane() {
open fun getHost(): Host {
val name = generalOption.nameTextField.text
val protocol = WSLProtocolProvider.PROTOCOL
val host = (generalOption.hostComboBox.selectedItem as WSLDistribution).distributionName
val wsl = generalOption.hostComboBox.selectedItem as WSLDistribution
val host = wsl.distributionName
val options = Options.Companion.Default.copy(
encoding = terminalOption.charsetComboBox.selectedItem as String,
env = terminalOption.environmentTextArea.text,
startupCommand = terminalOption.startupCommandTextField.text,
extras = mutableMapOf("wsl-guid" to wsl.guid, "wsl-flavor" to wsl.flavor)
)
return Host(

View File

@@ -85,11 +85,11 @@ open class SimpleTreeCellRenderer : DefaultTreeCellRenderer() {
if (c is DefaultTreeCellRenderer) {
if (g.color == c.textSelectionColor) {
val icon = this.icon
if (icon is DynamicIcon && FlatLaf.isLafDark().not()) {
if (icon is DynamicIcon && icon.allowColorFilter && FlatLaf.isLafDark().not()) {
val oldColorFilter = icon.colorFilter
// icon.colorFilter = colorFilter
icon.colorFilter = colorFilter
icon.paintIcon(c, g, x, y)
// icon.colorFilter = oldColorFilter
icon.colorFilter = oldColorFilter
return
}
}