Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/processing/app/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class ReactiveProperties : Properties() {
operator fun set(key: String, value: String) {
setProperty(key, value)
}
fun remove() {
TODO("Not yet implemented")
}
}

/*
Expand Down
11 changes: 10 additions & 1 deletion app/src/processing/app/ui/PDEPreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -593,9 +595,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, "")
}
}
}
Expand Down