Skip to content

Commit e24febe

Browse files
committed
Reset defaults by setting value rather than remove
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.
1 parent 4edb29a commit e24febe

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

app/src/processing/app/Preferences.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class ReactiveProperties : Properties() {
3838
operator fun set(key: String, value: String) {
3939
setProperty(key, value)
4040
}
41+
fun remove() {
42+
TODO("Not yet implemented")
43+
}
4144
}
4245

4346
/*

app/src/processing/app/ui/PDEPreferences.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import androidx.compose.ui.window.application
2727
import com.mikepenz.markdown.compose.Markdown
2828
import com.mikepenz.markdown.m3.markdownColor
2929
import com.mikepenz.markdown.m3.markdownTypography
30+
import processing.app.DEFAULTS_FILE_NAME
3031
import processing.app.LocalPreferences
3132
import processing.app.ReactiveProperties
3233
import processing.app.ui.PDEPreferences.Companion.preferences
@@ -35,6 +36,7 @@ import processing.app.ui.theme.*
3536
import java.awt.Dimension
3637
import java.awt.event.WindowEvent
3738
import java.awt.event.WindowListener
39+
import java.util.*
3840
import javax.swing.SwingUtilities
3941
import javax.swing.WindowConstants
4042

@@ -593,9 +595,16 @@ fun PDEPreferencePane.showPane(groups: PDEPreferenceGroups) {
593595
val prefs = LocalPreferences.current
594596
TextButton(
595597
onClick = {
598+
val defaultsStream =
599+
ClassLoader.getSystemResourceAsStream(DEFAULTS_FILE_NAME) ?: return@TextButton
600+
val defaults = Properties().apply {
601+
defaultsStream.reader(Charsets.UTF_8).use {
602+
load(it)
603+
}
604+
}
596605
groups.forEach { group ->
597606
group.forEach { pref ->
598-
prefs.remove(pref.key)
607+
prefs[pref.key] = defaults.getProperty(pref.key, "")
599608
}
600609
}
601610
}

0 commit comments

Comments
 (0)