Skip to content

Commit a4f4280

Browse files
committed
Add text repeat functionality after last Ayah
Introduces a repeat counter for text playback when the last Ayah is reached, based on the configured repeat count. Also adds logic to handle different actions after text playback, such as playing an alert, repeating, or moving to the next Ayah, according to user settings.
1 parent c19bef4 commit a4f4280

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

ui/quran_interface.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def __init__(self, title):
7878
self.set_text(Config.general.auto_restore_position_enabled)
7979
logger.debug(f"restore setting is: {Config.general.auto_restore_position_enabled}")
8080
self.set_shortcut()
81+
self.current_text_repeat = 0
8182
logger.debug("QuranInterface initialized successfully.")
8283

8384
def center_window(self):
@@ -223,6 +224,7 @@ def OnNext(self):
223224
self.quran_view.setText(self.quran_manager.next())
224225
self.set_text_ctrl_label()
225226
Globals.effects_manager.play("next")
227+
self.current_text_repeat += 0
226228
logger.debug("Text set successfully.")
227229
if self.quran_manager.current_position == self.quran_manager.max_position:
228230
logger.debug("Reached the end of the Quran.")
@@ -233,6 +235,7 @@ def OnBack(self, is_auto_call: bool = False):
233235
self.quran_view.setText(self.quran_manager.back())
234236
self.set_text_ctrl_label()
235237
Globals.effects_manager.play("previous")
238+
self.current_text_repeat += 0
236239
logger.debug("Text set successfully.")
237240
if self.quran_manager.current_position == 1:
238241
logger.debug("Reached the beginning of the Quran.")
@@ -663,5 +666,28 @@ def OnRandomMessages(self, event):
663666

664667
def on_last_ayah_reached(self):
665668
logger.debug("Last Ayah reached signal received in QuranInterface.")
666-
self.OnNext()
667-
self.toolbar.toggle_play_pause()
669+
670+
if Config.listening.text_repeat_count > 0:
671+
self.current_text_repeat += 1
672+
total_repeats = Config.listening.text_repeat_count
673+
logger.debug(f"Repeat {self.current_text_repeat}/{Config.listening.text_repeat_count}")
674+
if self.current_text_repeat <= total_repeats:
675+
self.set_focus_to_ayah(0)
676+
self.toolbar.toggle_play_pause()
677+
return
678+
else:
679+
logger.debug("Repeat limit reached, resetting counter.")
680+
self.current_text_repeat = 0
681+
682+
if Config.listening.action_after_text == 1:
683+
Globals.effects_manager.play("alert")
684+
685+
elif Config.listening.action_after_text == 2:
686+
self.set_focus_to_ayah(0)
687+
self.toolbar.toggle_play_pause()
688+
689+
elif Config.listening.action_after_text == 3:
690+
if not self.quran_manager.navigation_mode == NavigationMode.CUSTOM_RANGE:
691+
self.OnNext()
692+
self.toolbar.toggle_play_pause()
693+

0 commit comments

Comments
 (0)