Skip to content

Commit 8196f93

Browse files
committed
优化数值范围
优化 **数值范围设置**,改用 `setRange` 统一设置范围,避免最小值大于最大值的错误
1 parent 57d4c32 commit 8196f93

10 files changed

Lines changed: 31 additions & 35 deletions

File tree

CHANGELOG/v2.0.0/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ v2.0 - Koharu(小鸟游星野) release 1
2121
- 优化 **UI组件刷新机制**,为每个UI操作添加独立异常处理,确保对象删除时不会崩溃
2222
- 优化 **文件监视器响应机制**,确保在UI组件销毁后仍能安全处理文件变化事件
2323
- 优化 **CSES文件导入管理**,统一保存文件名为 `cses_schedule.yml`,每次导入自动覆盖旧文件
24+
- 优化 **数值范围设置**,改用 `setRange` 统一设置范围,避免最小值大于最大值的错误
2425

2526
## 🐛 修复问题
2627

app/view/settings/extraction_settings/lottery_settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(self, parent=None):
6666
# 半重复抽取次数输入框
6767
self.half_repeat_spin = SpinBox()
6868
self.half_repeat_spin.setFixedWidth(WIDTH_SPINBOX)
69-
self.half_repeat_spin.setMinimum(0)
69+
self.half_repeat_spin.setRange(0, 100)
7070
self.half_repeat_spin.setValue(
7171
readme_settings_async("lottery_settings", "half_repeat")
7272
)
@@ -470,7 +470,7 @@ def __init__(self, parent=None):
470470
# 动画间隔输入框
471471
self.animation_interval_spin = SpinBox()
472472
self.animation_interval_spin.setFixedWidth(WIDTH_SPINBOX)
473-
self.animation_interval_spin.setMinimum(1)
473+
self.animation_interval_spin.setRange(1, 1000)
474474
self.animation_interval_spin.setSuffix("ms")
475475
self.animation_interval_spin.setValue(
476476
readme_settings_async("lottery_settings", "animation_interval")
@@ -486,7 +486,7 @@ def __init__(self, parent=None):
486486
# 自动播放次数输入框
487487
self.autoplay_count_spin = SpinBox()
488488
self.autoplay_count_spin.setFixedWidth(WIDTH_SPINBOX)
489-
self.autoplay_count_spin.setMinimum(1)
489+
self.autoplay_count_spin.setRange(1, 1000)
490490
self.autoplay_count_spin.setValue(
491491
readme_settings_async("lottery_settings", "autoplay_count")
492492
)

app/view/settings/extraction_settings/quick_draw_settings.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, parent=None):
6969
# 半重复抽取次数输入框
7070
self.half_repeat_spin = SpinBox()
7171
self.half_repeat_spin.setFixedWidth(WIDTH_SPINBOX)
72-
self.half_repeat_spin.setMinimum(0)
72+
self.half_repeat_spin.setRange(0, 100)
7373
self.half_repeat_spin.setValue(
7474
readme_settings_async("quick_draw_settings", "half_repeat")
7575
)
@@ -100,8 +100,7 @@ def __init__(self, parent=None):
100100
# 点击后禁用时间输入框
101101
self.disable_after_click_spin = SpinBox()
102102
self.disable_after_click_spin.setFixedWidth(WIDTH_SPINBOX)
103-
self.disable_after_click_spin.setMinimum(0)
104-
self.disable_after_click_spin.setMaximum(60)
103+
self.disable_after_click_spin.setRange(0, 60)
105104
self.disable_after_click_spin.setSuffix("s")
106105
self.disable_after_click_spin.setValue(
107106
readme_settings_async("quick_draw_settings", "disable_after_click")
@@ -505,7 +504,7 @@ def __init__(self, parent=None):
505504
# 动画间隔输入框
506505
self.animation_interval_spin = SpinBox()
507506
self.animation_interval_spin.setFixedWidth(WIDTH_SPINBOX)
508-
self.animation_interval_spin.setMinimum(1)
507+
self.animation_interval_spin.setRange(1, 1000)
509508
self.animation_interval_spin.setSuffix("ms")
510509
self.animation_interval_spin.setValue(
511510
readme_settings_async("quick_draw_settings", "animation_interval")
@@ -521,7 +520,7 @@ def __init__(self, parent=None):
521520
# 自动播放次数输入框
522521
self.autoplay_count_spin = SpinBox()
523522
self.autoplay_count_spin.setFixedWidth(WIDTH_SPINBOX)
524-
self.autoplay_count_spin.setMinimum(1)
523+
self.autoplay_count_spin.setRange(1, 1000)
525524
self.autoplay_count_spin.setValue(
526525
readme_settings_async("quick_draw_settings", "autoplay_count")
527526
)

app/view/settings/extraction_settings/roll_call_settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(self, parent=None):
8181
# 半重复抽取次数输入框
8282
self.half_repeat_spin = SpinBox()
8383
self.half_repeat_spin.setFixedWidth(WIDTH_SPINBOX)
84-
self.half_repeat_spin.setMinimum(0)
84+
self.half_repeat_spin.setRange(0, 100)
8585
self.half_repeat_spin.setValue(
8686
readme_settings_async("roll_call_settings", "half_repeat")
8787
)
@@ -464,7 +464,7 @@ def __init__(self, parent=None):
464464
# 动画间隔输入框
465465
self.animation_interval_spin = SpinBox()
466466
self.animation_interval_spin.setFixedWidth(WIDTH_SPINBOX)
467-
self.animation_interval_spin.setMinimum(1)
467+
self.animation_interval_spin.setRange(1, 1000)
468468
self.animation_interval_spin.setSuffix("ms")
469469
self.animation_interval_spin.setValue(
470470
readme_settings_async("roll_call_settings", "animation_interval")
@@ -480,7 +480,7 @@ def __init__(self, parent=None):
480480
# 自动播放次数输入框
481481
self.autoplay_count_spin = SpinBox()
482482
self.autoplay_count_spin.setFixedWidth(WIDTH_SPINBOX)
483-
self.autoplay_count_spin.setMinimum(1)
483+
self.autoplay_count_spin.setRange(1, 1000)
484484
self.autoplay_count_spin.setValue(
485485
readme_settings_async("roll_call_settings", "autoplay_count")
486486
)

app/view/settings/floating_window_management.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def __init__(self, parent=None):
380380
self.floating_window_stick_to_edge_recover_seconds_spinbox.setFixedWidth(
381381
WIDTH_SPINBOX
382382
)
383-
self.floating_window_stick_to_edge_recover_seconds_spinbox.setMinimum(1)
383+
self.floating_window_stick_to_edge_recover_seconds_spinbox.setRange(1, 60)
384384
self.floating_window_stick_to_edge_recover_seconds_spinbox.setSuffix("s")
385385
self.floating_window_stick_to_edge_recover_seconds_spinbox.setValue(
386386
readme_settings_async(

app/view/settings/more_settings/fair_draw.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def __init__(self, parent=None):
207207
# 冷启动轮次
208208
self.cold_start_rounds_spinbox = SpinBox()
209209
self.cold_start_rounds_spinbox.setFixedWidth(WIDTH_SPINBOX)
210-
self.cold_start_rounds_spinbox.setMinimum(1)
210+
self.cold_start_rounds_spinbox.setRange(1, 1000)
211211
self.cold_start_rounds_spinbox.setValue(
212212
readme_settings_async("fair_draw_settings", "cold_start_rounds")
213213
)
@@ -264,7 +264,7 @@ def __init__(self, parent=None):
264264
# 频率惩罚权重
265265
self.frequency_weight_spinbox = DoubleSpinBox()
266266
self.frequency_weight_spinbox.setFixedWidth(WIDTH_SPINBOX)
267-
self.frequency_weight_spinbox.setMinimum(0.01)
267+
self.frequency_weight_spinbox.setRange(0.01, 100.0)
268268
self.frequency_weight_spinbox.setValue(
269269
readme_settings_async("fair_draw_settings", "frequency_weight")
270270
)
@@ -303,7 +303,7 @@ def __init__(self, parent=None):
303303
# 差距阈值
304304
self.gap_threshold_spinbox = SpinBox()
305305
self.gap_threshold_spinbox.setFixedWidth(WIDTH_SPINBOX)
306-
self.gap_threshold_spinbox.setMinimum(1)
306+
self.gap_threshold_spinbox.setRange(1, 100)
307307
self.gap_threshold_spinbox.setValue(
308308
readme_settings_async("fair_draw_settings", "gap_threshold")
309309
)
@@ -318,7 +318,7 @@ def __init__(self, parent=None):
318318
# 候选池最少人数
319319
self.min_pool_size_spinbox = SpinBox()
320320
self.min_pool_size_spinbox.setFixedWidth(WIDTH_SPINBOX)
321-
self.min_pool_size_spinbox.setMinimum(1)
321+
self.min_pool_size_spinbox.setRange(1, 1000)
322322
self.min_pool_size_spinbox.setValue(
323323
readme_settings_async("fair_draw_settings", "min_pool_size")
324324
)
@@ -462,7 +462,7 @@ def __init__(self, parent=None):
462462
# 设置基础权重
463463
self.base_weight_spinbox = DoubleSpinBox()
464464
self.base_weight_spinbox.setFixedWidth(WIDTH_SPINBOX)
465-
self.base_weight_spinbox.setMinimum(0.01)
465+
self.base_weight_spinbox.setRange(0.01, 1000.0)
466466
self.base_weight_spinbox.setValue(
467467
readme_settings_async("fair_draw_settings", "base_weight")
468468
)
@@ -475,7 +475,7 @@ def __init__(self, parent=None):
475475
# 设置权重范围最小值
476476
self.min_weight_spinbox = DoubleSpinBox()
477477
self.min_weight_spinbox.setFixedWidth(WIDTH_SPINBOX)
478-
self.min_weight_spinbox.setMinimum(0.01)
478+
self.min_weight_spinbox.setRange(0.01, 1000.0)
479479
self.min_weight_spinbox.setValue(
480480
readme_settings_async("fair_draw_settings", "min_weight")
481481
)
@@ -488,7 +488,7 @@ def __init__(self, parent=None):
488488
# 设置权重范围最大值
489489
self.max_weight_spinbox = DoubleSpinBox()
490490
self.max_weight_spinbox.setFixedWidth(WIDTH_SPINBOX)
491-
self.max_weight_spinbox.setMinimum(0.01)
491+
self.max_weight_spinbox.setRange(0.01, 1000.0)
492492
self.max_weight_spinbox.setValue(
493493
readme_settings_async("fair_draw_settings", "max_weight")
494494
)
@@ -502,7 +502,7 @@ def __init__(self, parent=None):
502502
# 小组平衡权重
503503
self.group_weight_spinbox = DoubleSpinBox()
504504
self.group_weight_spinbox.setFixedWidth(WIDTH_SPINBOX)
505-
self.group_weight_spinbox.setMinimum(0.01)
505+
self.group_weight_spinbox.setRange(0.01, 1000.0)
506506
self.group_weight_spinbox.setValue(
507507
readme_settings_async("fair_draw_settings", "group_weight")
508508
)
@@ -515,7 +515,7 @@ def __init__(self, parent=None):
515515
# 性别平衡权重
516516
self.gender_weight_spinbox = DoubleSpinBox()
517517
self.gender_weight_spinbox.setFixedWidth(WIDTH_SPINBOX)
518-
self.gender_weight_spinbox.setMinimum(0.01)
518+
self.gender_weight_spinbox.setRange(0.01, 1000.0)
519519
self.gender_weight_spinbox.setValue(
520520
readme_settings_async("fair_draw_settings", "gender_weight")
521521
)
@@ -530,7 +530,7 @@ def __init__(self, parent=None):
530530
# 时间因子权重
531531
self.time_weight_spinbox = DoubleSpinBox()
532532
self.time_weight_spinbox.setFixedWidth(WIDTH_SPINBOX)
533-
self.time_weight_spinbox.setMinimum(0.01)
533+
self.time_weight_spinbox.setRange(0.01, 1000.0)
534534
self.time_weight_spinbox.setValue(
535535
readme_settings_async("fair_draw_settings", "time_weight")
536536
)

app/view/settings/notification_settings/lottery_notification_settings.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def __init__(self, parent=None):
130130
# 主窗口显示阈值
131131
self.main_window_threshold_spinbox = SpinBox()
132132
self.main_window_threshold_spinbox.setFixedWidth(WIDTH_SPINBOX)
133-
self.main_window_threshold_spinbox.setMinimum(1)
133+
self.main_window_threshold_spinbox.setRange(1, 100)
134134
self.main_window_threshold_spinbox.setValue(
135135
readme_settings_async(
136136
"lottery_notification_settings", "main_window_display_threshold"
@@ -301,7 +301,7 @@ def __init__(self, parent=None):
301301
# 浮窗自动关闭时间
302302
self.floating_window_auto_close_time_spinbox = SpinBox()
303303
self.floating_window_auto_close_time_spinbox.setFixedWidth(WIDTH_SPINBOX)
304-
self.floating_window_auto_close_time_spinbox.setMinimum(1)
304+
self.floating_window_auto_close_time_spinbox.setRange(0, 60)
305305
self.floating_window_auto_close_time_spinbox.setSuffix("s")
306306
self.floating_window_auto_close_time_spinbox.setValue(
307307
readme_settings_async(
@@ -451,8 +451,7 @@ def __init__(self, parent=None):
451451
# 通知显示时长
452452
self.notification_display_duration_spinbox = SpinBox()
453453
self.notification_display_duration_spinbox.setFixedWidth(WIDTH_SPINBOX)
454-
self.notification_display_duration_spinbox.setMinimum(1)
455-
self.notification_display_duration_spinbox.setMaximum(60)
454+
self.notification_display_duration_spinbox.setRange(1, 60)
456455
self.notification_display_duration_spinbox.setSuffix("s")
457456
self.notification_display_duration_spinbox.setValue(
458457
readme_settings_async(

app/view/settings/notification_settings/quick_draw_notification_settings.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def __init__(self, parent=None):
202202
# 浮窗自动关闭时间
203203
self.floating_window_auto_close_time_spinbox = SpinBox()
204204
self.floating_window_auto_close_time_spinbox.setFixedWidth(WIDTH_SPINBOX)
205-
self.floating_window_auto_close_time_spinbox.setMinimum(1)
205+
self.floating_window_auto_close_time_spinbox.setRange(0, 60)
206206
self.floating_window_auto_close_time_spinbox.setSuffix("s")
207207
self.floating_window_auto_close_time_spinbox.setValue(
208208
readme_settings_async(
@@ -352,8 +352,7 @@ def __init__(self, parent=None):
352352
# 通知显示时长
353353
self.notification_display_duration_spinbox = SpinBox()
354354
self.notification_display_duration_spinbox.setFixedWidth(WIDTH_SPINBOX)
355-
self.notification_display_duration_spinbox.setMinimum(1)
356-
self.notification_display_duration_spinbox.setMaximum(60)
355+
self.notification_display_duration_spinbox.setRange(1, 60)
357356
self.notification_display_duration_spinbox.setSuffix("s")
358357
self.notification_display_duration_spinbox.setValue(
359358
readme_settings_async(

app/view/settings/notification_settings/roll_call_notification_settings.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __init__(self, parent=None):
153153
# 主窗口显示阈值
154154
self.main_window_threshold_spinbox = SpinBox()
155155
self.main_window_threshold_spinbox.setFixedWidth(WIDTH_SPINBOX)
156-
self.main_window_threshold_spinbox.setMinimum(1)
156+
self.main_window_threshold_spinbox.setRange(1, 1000)
157157
self.main_window_threshold_spinbox.setValue(
158158
readme_settings_async(
159159
"roll_call_notification_settings", "main_window_display_threshold"
@@ -308,7 +308,7 @@ def __init__(self, parent=None):
308308
# 浮窗自动关闭时间
309309
self.floating_window_auto_close_time_spinbox = SpinBox()
310310
self.floating_window_auto_close_time_spinbox.setFixedWidth(WIDTH_SPINBOX)
311-
self.floating_window_auto_close_time_spinbox.setMinimum(1)
311+
self.floating_window_auto_close_time_spinbox.setRange(0, 60)
312312
self.floating_window_auto_close_time_spinbox.setSuffix("s")
313313
self.floating_window_auto_close_time_spinbox.setValue(
314314
readme_settings_async(
@@ -458,8 +458,7 @@ def __init__(self, parent=None):
458458
# 通知显示时长
459459
self.notification_display_duration_spinbox = SpinBox()
460460
self.notification_display_duration_spinbox.setFixedWidth(WIDTH_SPINBOX)
461-
self.notification_display_duration_spinbox.setMinimum(1)
462-
self.notification_display_duration_spinbox.setMaximum(60)
461+
self.notification_display_duration_spinbox.setRange(1, 60)
463462
self.notification_display_duration_spinbox.setSuffix("s")
464463
self.notification_display_duration_spinbox.setValue(
465464
readme_settings_async(

app/view/settings/voice_settings/basic_voice_settings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ def __init__(self, parent=None):
195195
# 语速调节设置
196196
self.speech_rate = SpinBox()
197197
self.speech_rate.setFixedWidth(WIDTH_SPINBOX)
198-
self.speech_rate.setMinimum(1)
199-
self.speech_rate.setMaximum(500)
198+
self.speech_rate.setRange(1, 500)
200199
self.speech_rate.setSuffix("wpm")
201200
self.speech_rate.setValue(
202201
int(readme_settings_async("basic_voice_settings", "speech_rate"))

0 commit comments

Comments
 (0)