Skip to content

Commit c19bef4

Browse files
committed
Add advanced repeat and action options to listening settings
Enhanced the listening settings dialog to support separate repeat counts and actions for both individual ayahs and entire texts. Updated the settings model to include ayah_repeat_count, action_after_text, and text_repeat_count fields, and adjusted the UI to allow users to configure these new options.
1 parent 46fa5b4 commit c19bef4

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

ui/dialogs/settings_dialog.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,36 @@ def init_ui(self):
192192
display_text = f"{row['name']} - {row['rewaya']} - {row['type']} - ({row['bitrate']} kbps)"
193193
self.reciters_combo.addItem(display_text, row["id"])
194194

195-
self.action_label = QLabel("الإجراء بعد الاستماع:")
195+
self.action_label = QLabel("الإجراء بعد الاستماع لكل آية:")
196196
self.action_combo = QComboBox()
197197
items_with_ids = [("إيقاف", 0), ("تكرار", 1), ("الانتقال إلى الآية التالية", 2)]
198198
[self.action_combo.addItem(text, id) for text, id in items_with_ids]
199199
self.action_combo.setAccessibleName(self.action_label.text())
200200

201+
self.repeat_limit_label = QLabel("عدد مرات تكرار الآية:")
202+
self.repeat_limit_spinbox = SpinBox(self)
203+
self.repeat_limit_spinbox.setAccessibleName(self.repeat_limit_label.text())
204+
self.repeat_limit_spinbox.setRange(0, 5)
205+
self.repeat_limit_spinbox.setSingleStep(1)
206+
207+
self.action_after_text_label = QLabel("الإجراء بعد نهاية النص:")
208+
self.action_after_text_combo = QComboBox()
209+
items_after_text = [("إيقاف", 0), ("تنبيه صوتي", 1), ("تكرار النص الحالي", 2), ("الانتقال إلى التالي", 3)]
210+
[self.action_after_text_combo.addItem(text, id) for text, id in items_after_text]
211+
self.action_after_text_combo.setAccessibleName(self.action_after_text_label.text())
212+
213+
self.text_repeat_label = QLabel("عدد مرات تكرار النص:")
214+
self.text_repeat_spinbox = SpinBox(self)
215+
self.text_repeat_spinbox.setAccessibleName(self.text_repeat_label.text())
216+
self.text_repeat_spinbox.setRange(0, 5)
217+
self.text_repeat_spinbox.setSingleStep(1)
218+
201219
self.duration_label = QLabel("مدة التقديم والترجيع (بالثواني):")
202220
self.duration_spinbox = SpinBox(self)
203221
self.duration_spinbox.setAccessibleName(self.duration_label.text())
204222
self.duration_spinbox.setRange(2, 15)
205223
self.duration_spinbox.setSingleStep(1)
206224

207-
self.repeat_limit_label = QLabel("عدد مرات تكرار الآية:")
208-
self.repeat_limit_spinbox = SpinBox(self)
209-
self.repeat_limit_spinbox.setAccessibleName(self.repeat_limit_label.text())
210-
self.repeat_limit_spinbox.setRange(0, 5)
211-
self.repeat_limit_spinbox.setSingleStep(1)
212225

213226

214227

@@ -219,10 +232,14 @@ def init_ui(self):
219232
self.group_listening_layout.addSpacerItem(QSpacerItem(20, 5, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)) # مسافة نتوسطة
220233
self.group_listening_layout.addWidget(self.action_label)
221234
self.group_listening_layout.addWidget(self.action_combo)
222-
self.group_listening_layout.addWidget(self.duration_label)
223-
self.group_listening_layout.addWidget(self.duration_spinbox)
224235
self.group_listening_layout.addWidget(self.repeat_limit_label)
225236
self.group_listening_layout.addWidget(self.repeat_limit_spinbox)
237+
self.group_listening_layout.addWidget(self.action_after_text_label)
238+
self.group_listening_layout.addWidget(self.action_after_text_combo)
239+
self.group_listening_layout.addWidget(self.text_repeat_label)
240+
self.group_listening_layout.addWidget(self.text_repeat_spinbox)
241+
self.group_listening_layout.addWidget(self.duration_label)
242+
self.group_listening_layout.addWidget(self.duration_spinbox)
226243
self.group_listening_layout.addWidget(self.auto_move_focus_checkbox)
227244
self.group_listening.setLayout(self.group_listening_layout)
228245
self.group_listening_layout.addSpacerItem(QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding))
@@ -403,7 +420,9 @@ def save_settings(self):
403420
Config.listening.reciter = self.reciters_combo.currentData()
404421
Config.listening.action_after_listening = self.action_combo.currentData()
405422
Config.listening.forward_time = self.duration_spinbox.value()
406-
Config.listening.repeat_count = self.repeat_limit_spinbox.value()
423+
Config.listening.ayah_repeat_count = self.repeat_limit_spinbox.value()
424+
Config.listening.action_after_text = self.action_after_text_combo.currentData()
425+
Config.listening.text_repeat_count = self.text_repeat_spinbox.value()
407426
Config.listening.auto_move_focus = self.auto_move_focus_checkbox.isChecked()
408427

409428
Config.reading.font_type = self.font_type_combo.currentData().value
@@ -454,7 +473,8 @@ def set_current_settings(self):
454473
self.auto_restore_position_checkbox.setChecked(Config.general.auto_restore_position_enabled)
455474
self.update_checkbox.setChecked(Config.general.check_update_enabled)
456475
self.duration_spinbox.setValue(Config.listening.forward_time)
457-
self.repeat_limit_spinbox.setValue(Config.listening.repeat_count)
476+
self.repeat_limit_spinbox.setValue(Config.listening.ayah_repeat_count)
477+
self.text_repeat_spinbox.setValue(Config.listening.text_repeat_count)
458478
self.auto_move_focus_checkbox.setChecked(Config.listening.auto_move_focus)
459479
self.ignore_tashkeel_checkbox.setChecked(Config.search.ignore_tashkeel)
460480
self.ignore_hamza_checkbox.setChecked(Config.search.ignore_hamza)
@@ -464,6 +484,7 @@ def set_current_settings(self):
464484
(self.log_levels_combo, Config.general.log_level),
465485
(self.reciters_combo, Config.listening.reciter),
466486
(self.action_combo, Config.listening.action_after_listening),
487+
(self.action_after_text_combo , Config.listening.action_after_text),
467488
(self.font_type_combo, QuranFontType.from_int(Config.reading.font_type)),
468489
(self.marks_type_combo, MarksType.from_int(Config.reading.marks_type)),
469490
(self.ayah_device_combo, Config.audio.ayah_device),

utils/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ class ListeningSettings(BaseSection):
6363
SECTION_NAME: ClassVar[str] = "listening"
6464
reciter: int = 58
6565
action_after_listening: int = 0
66-
repeat_count: int = 1
66+
ayah_repeat_count: int = 0
67+
action_after_text: int = 0
68+
text_repeat_count: int = 0
6769
forward_time: int = 5
6870
auto_move_focus: bool = True
6971

0 commit comments

Comments
 (0)