Reset defaults by setting value rather than remove (#1385)

Initially reset to defaults was set up by removing the key from the preferences but that didn't work well upstream, changing the value to default instead.
This commit is contained in:
Stef Tervelde
2026-02-05 00:56:16 +01:00
committed by GitHub
parent 5317234c98
commit f34498acea
2 changed files with 13 additions and 1 deletions

View File

@@ -35,6 +35,9 @@ class ReactiveProperties : Properties() {
operator fun set(key: String, value: String) {
setProperty(key, value)
}
fun remove() {
TODO("Not yet implemented")
}
}
/*

View File

@@ -27,6 +27,7 @@ import androidx.compose.ui.window.application
import com.mikepenz.markdown.compose.Markdown
import com.mikepenz.markdown.m3.markdownColor
import com.mikepenz.markdown.m3.markdownTypography
import processing.app.DEFAULTS_FILE_NAME
import processing.app.LocalPreferences
import processing.app.ReactiveProperties
import processing.app.ui.PDEPreferences.Companion.preferences
@@ -35,6 +36,7 @@ import processing.app.ui.theme.*
import java.awt.Dimension
import java.awt.event.WindowEvent
import java.awt.event.WindowListener
import java.util.*
import javax.swing.SwingUtilities
import javax.swing.WindowConstants
@@ -592,9 +594,16 @@ fun PDEPreferencePane.showPane(groups: PDEPreferenceGroups) {
val prefs = LocalPreferences.current
TextButton(
onClick = {
val defaultsStream =
ClassLoader.getSystemResourceAsStream(DEFAULTS_FILE_NAME) ?: return@TextButton
val defaults = Properties().apply {
defaultsStream.reader(Charsets.UTF_8).use {
load(it)
}
}
groups.forEach { group ->
group.forEach { pref ->
prefs.remove(pref.key)
prefs[pref.key] = defaults.getProperty(pref.key, "")
}
}
}