Skip to content

Commit cc31101

Browse files
committed
flag "Resizable" and "Maximized" window scale options as unstable due to known dialog focus problems
1 parent 3d400c4 commit cc31101

File tree

1 file changed

+37
-16
lines changed

1 file changed

+37
-16
lines changed

src/main/kotlin/com/spoiligaming/explorer/ui/screens/settings/SettingsTheme.kt

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,29 +126,51 @@ fun SettingsTheme() {
126126
Box(contentAlignment = Alignment.Center) {
127127
DropdownMenuWithLabel(
128128
label = "Window scale",
129-
currentValue = ConfigurationHandler.getInstance().themeSettings.windowScale,
130-
options = listOf("150%", "125%", "100%", "Resizable", "Maximized"),
129+
currentValue = run {
130+
val currentScale = ConfigurationHandler.getInstance().themeSettings.windowScale
131+
132+
when (currentScale) {
133+
"Resizable" -> "Resizable (unstable)"
134+
"Maximized" -> "Maximized (unstable)"
135+
else -> currentScale
136+
}
137+
},
138+
options =
139+
listOf(
140+
"150%",
141+
"125%",
142+
"100%",
143+
"Resizable (unstable)",
144+
"Maximized (unstable)",
145+
),
131146
) { newValue ->
147+
val processedValue =
148+
when {
149+
newValue.contains("Resizable (unstable)") -> "Resizable"
150+
newValue.contains("Maximized (unstable)") -> "Maximized"
151+
else -> newValue
152+
}
153+
132154
val currentScale = ConfigurationHandler.getInstance().themeSettings.windowScale
133155

134-
if (newValue in listOf("Resizable", "Maximized") &&
156+
if (processedValue in listOf("Resizable", "Maximized") &&
135157
currentScale in WindowUtility.windowScaleMapping.keys
136158
) {
137159
ConfigurationHandler.updateValue {
138160
windowProperties.previousScale = currentScale
139161
}
140162
}
141163

142-
windowFrame.isResizable = newValue == "Resizable"
143-
isWindowMaximized = newValue == "Maximized"
164+
windowFrame.isResizable = processedValue == "Resizable"
165+
isWindowMaximized = processedValue == "Maximized"
144166
ConfigurationHandler.updateValue {
145-
windowProperties.wasPreviousScaleResizable = newValue == "Resizable"
167+
windowProperties.wasPreviousScaleResizable = processedValue == "Resizable"
146168
}
147169

148170
ConfigurationHandler.updateValue {
149-
themeSettings.windowScale = newValue
171+
themeSettings.windowScale = processedValue
150172

151-
when (newValue) {
173+
when (processedValue) {
152174
"Maximized" -> {
153175
if (currentScale != "Resizable") {
154176
windowProperties.previousScale = currentScale
@@ -166,18 +188,17 @@ fun SettingsTheme() {
166188
ConfigurationHandler.getInstance().let { config ->
167189
config.themeSettings.windowScale.let { scale ->
168190
WindowUtility.windowScaleMapping[scale]
169-
?: WindowUtility
170-
.windowScaleMapping[config.windowProperties.previousScale]
191+
?: WindowUtility.windowScaleMapping[
192+
config.windowProperties.previousScale,
193+
]
171194
?: scale.toFloatOrNull()
172195
?: 1f
173196
}.let { windowScale ->
174197
config.windowProperties.currentWindowSize?.let {
175198
(width, height) ->
176199
width to height
177-
} ?: (800 * windowScale).toInt().let {
178-
width ->
179-
(600 * windowScale).toInt().let {
180-
height ->
200+
} ?: (800 * windowScale).toInt().let { width ->
201+
(600 * windowScale).toInt().let { height ->
181202
width to height
182203
}
183204
}
@@ -186,7 +207,7 @@ fun SettingsTheme() {
186207
centerOnScreen()
187208
}
188209
in WindowUtility.windowScaleMapping.keys -> {
189-
val newScale = WindowUtility.windowScaleMapping[newValue]!!
210+
val newScale = WindowUtility.windowScaleMapping[processedValue]!!
190211

191212
ConfigurationHandler.updateValue {
192213
windowProperties.wasPreviousScaleResizable = false
@@ -198,7 +219,7 @@ fun SettingsTheme() {
198219
}
199220
}
200221
else -> throw IllegalArgumentException(
201-
"Invalid window scale value: $newValue",
222+
"Invalid window scale value: $processedValue",
202223
)
203224
}
204225
}

0 commit comments

Comments
 (0)