Skip to content

Commit af7b505

Browse files
committed
Add repeat functionality to AudioToolBar
Introduces a repeat mechanism for Ayah playback based on the configured repeat count. The toolbar now tracks the current repeat and replays the Ayah as needed before proceeding to the next action.
1 parent 4ea5495 commit af7b505

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ui/widgets/toolbar.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ def __init__(self, parent: Optional[object] = None):
173173
self.reciters = AyahReciter(data_folder / "quran" / "reciters.db")
174174
self.navigation = NavigationManager(self.parent, self.parent.quran_manager)
175175
self.audio_thread = AudioPlayerThread(self.player, self.parent)
176+
self.current_repeat = 0
176177
logger.debug("AudioToolBar initialized.")
177178

178179
self.play_pause_button = self.create_button("تشغيلالآية الحالية", self.toggle_play_pause)
@@ -272,7 +273,18 @@ def change_ayah_focus(self, manual: bool = False) -> None:
272273
def OnActionAfterListening(self):
273274
logger.debug("Action after listening triggered.")
274275
self.set_buttons_status()
276+
repeat_count = Config.listening.repeat_count
275277
action_after_listening = Config.listening.action_after_listening
278+
if repeat_count > 0:
279+
if self.current_repeat < repeat_count - 1:
280+
self.current_repeat += 1
281+
logger.debug(f"Repeating Ayah: repeat {self.current_repeat}/{repeat_count}")
282+
self.play_current_ayah()
283+
return
284+
285+
else:
286+
self.current_repeat = 0
287+
276288
if action_after_listening == 2 or self.navigation.current_ayah == 0:
277289
self.navigation.has_basmala = True if self.navigation.current_ayah < 2 else False
278290
self.OnPlayNext()

0 commit comments

Comments
 (0)