41
41
AUTOSPLIT_VERSION ,
42
42
BGRA_CHANNEL_COUNT ,
43
43
FROZEN ,
44
+ ONE_SECOND ,
44
45
auto_split_directory ,
45
46
decimal ,
46
47
flatten ,
@@ -76,7 +77,9 @@ class AutoSplit(QMainWindow, design.Ui_MainWindow):
76
77
77
78
# Timers
78
79
timer_live_image = QtCore .QTimer ()
80
+ timer_live_image .setTimerType (QtCore .Qt .TimerType .PreciseTimer )
79
81
timer_start_image = QtCore .QTimer ()
82
+ timer_start_image .setTimerType (QtCore .Qt .TimerType .PreciseTimer )
80
83
81
84
# Widgets
82
85
AboutWidget : about .Ui_AboutAutoSplitWidget | None = None
@@ -205,7 +208,7 @@ def _update_checker_widget_signal_slot(latest_version: str, check_on_open: bool)
205
208
206
209
# live image checkbox
207
210
self .timer_live_image .timeout .connect (lambda : self .__update_live_image_details (None , True ))
208
- self .timer_live_image .start (int (1000 / self .settings_dict ["fps_limit" ]))
211
+ self .timer_live_image .start (int (ONE_SECOND / self .settings_dict ["fps_limit" ]))
209
212
210
213
# Automatic timer start
211
214
self .timer_start_image .timeout .connect (self .__start_image_function )
@@ -296,7 +299,7 @@ def __load_start_image(self, started_by_button: bool = False, wait_for_delay: bo
296
299
self .highest_similarity = 0.0
297
300
self .reset_highest_similarity = 0.0
298
301
self .split_below_threshold = False
299
- self .timer_start_image .start (int (1000 / self .settings_dict ["fps_limit" ]))
302
+ self .timer_start_image .start (int (ONE_SECOND / self .settings_dict ["fps_limit" ]))
300
303
301
304
QApplication .processEvents ()
302
305
@@ -341,7 +344,7 @@ def __start_image_function(self):
341
344
if self .start_image .get_delay_time (self ) > 0 :
342
345
self .start_image_status_value_label .setText ("delaying start..." )
343
346
delay_start_time = time ()
344
- start_delay = self .start_image .get_delay_time (self ) / 1000
347
+ start_delay = self .start_image .get_delay_time (self ) / ONE_SECOND
345
348
time_delta = 0.0
346
349
while time_delta < start_delay :
347
350
delay_time_left = start_delay - time_delta
@@ -564,7 +567,7 @@ def __auto_splitter(self): # noqa: PLR0912,PLR0915
564
567
while self .split_image_number < number_of_split_images :
565
568
# Check if we are not waiting for the split delay to send the key press
566
569
if self .waiting_for_split_delay :
567
- time_millis = int (round (time () * 1000 ))
570
+ time_millis = int (round (time () * ONE_SECOND ))
568
571
if time_millis < split_time :
569
572
QApplication .processEvents ()
570
573
continue
@@ -583,9 +586,9 @@ def __auto_splitter(self): # noqa: PLR0912,PLR0915
583
586
if not self .split_image .check_flag (DUMMY_FLAG ):
584
587
# If it's a delayed split, check if the delay has passed
585
588
# Otherwise calculate the split time for the key press
586
- split_delay = self .split_image .get_delay_time (self ) / 1000
589
+ split_delay = self .split_image .get_delay_time (self ) / ONE_SECOND
587
590
if split_delay > 0 and not self .waiting_for_split_delay :
588
- split_time = round (time () + split_delay * 1000 )
591
+ split_time = round (time () + split_delay * ONE_SECOND )
589
592
self .waiting_for_split_delay = True
590
593
buttons_to_disable = [
591
594
self .next_image_button ,
@@ -668,7 +671,7 @@ def __similarity_threshold_loop(self, number_of_split_images: int, dummy_splits_
668
671
# Limit the number of time the comparison runs to reduce cpu usage
669
672
frame_interval = 1 / self .settings_dict ["fps_limit" ]
670
673
# Use a time delta to have a consistant check interval
671
- wait_delta_ms = int ((frame_interval - (time () - start ) % frame_interval ) * 1000 )
674
+ wait_delta_ms = int ((frame_interval - (time () - start ) % frame_interval ) * ONE_SECOND )
672
675
673
676
below_flag = self .split_image .check_flag (BELOW_FLAG )
674
677
# if the b flag is set, let similarity go above threshold first,
0 commit comments