diff --git a/ui/dialogs/settings_dialog.py b/ui/dialogs/settings_dialog.py index 8c2b24e..2a7299d 100644 --- a/ui/dialogs/settings_dialog.py +++ b/ui/dialogs/settings_dialog.py @@ -15,6 +15,7 @@ QSpacerItem, QSizePolicy, QHBoxLayout, + QSpinBox, QStackedWidget ) from PyQt6.QtGui import QKeySequence @@ -141,11 +142,20 @@ def init_ui(self): [self.action_combo.addItem(text, id) for text, id in items_with_ids] self.action_combo.setAccessibleName(self.action_label.text()) + self.duration_label = QLabel("مدة التقديم والترجيع (بالثواني):") + self.duration_spinbox = QSpinBox() + self.duration_spinbox.setAccessibleName(self.duration_label.text()) + self.duration_spinbox.setRange(2, 15) + self.duration_spinbox.setSingleStep(1) + + self.group_listening_layout.addWidget(self.reciters_label) self.group_listening_layout.addWidget(self.reciters_combo) self.group_listening_layout.addSpacerItem(QSpacerItem(20, 5, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Fixed)) # مسافة نتوسطة self.group_listening_layout.addWidget(self.action_label) self.group_listening_layout.addWidget(self.action_combo) + self.group_listening_layout.addWidget(self.duration_label) + self.group_listening_layout.addWidget(self.duration_spinbox) self.group_listening.setLayout(self.group_listening_layout) self.group_listening_layout.addSpacerItem(QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)) @@ -272,7 +282,8 @@ def save_settings(self): listening_settings = { "reciter": self.reciters_combo.currentData(), - "action_after_listening": self.action_combo.currentData() + "action_after_listening": self.action_combo.currentData(), + "forward_time": self.duration_spinbox.value() } reading_settings = { @@ -322,6 +333,7 @@ def set_current_settings(self): self.start_on_system_start_checkbox.setChecked(current_settings["general"]["auto_start_enabled"]) self.auto_save_position_checkbox.setChecked(current_settings["general"]["auto_save_position_enabled"]) self.update_checkbox.setChecked(current_settings["general"]["check_update_enabled"]) + self.duration_spinbox.setValue(current_settings["listening"]["forward_time"]) self.log_checkbox.setChecked(current_settings["general"]["logging_enabled"]) self.ignore_tashkeel_checkbox.setChecked(current_settings["search"]["ignore_tashkeel"]) self.ignore_hamza_checkbox.setChecked(current_settings["search"]["ignore_hamza"]) diff --git a/ui/widgets/menu_bar.py b/ui/widgets/menu_bar.py index 7bafe2c..5c3d5cb 100644 --- a/ui/widgets/menu_bar.py +++ b/ui/widgets/menu_bar.py @@ -76,10 +76,14 @@ def create_menu(self): self.stop_action.triggered.connect(self.parent.toolbar.stop_audio) self.rewind_action = QAction("ترجيع", self) self.rewind_action.setShortcuts([QKeySequence("J"), QKeySequence("Ctrl+Alt+Left")]) - self.rewind_action.triggered.connect(lambda: self.parent.toolbar.player.rewind()) + self.rewind_action.triggered.connect(lambda: self.parent.toolbar.player.rewind(SettingsManager.current_settings["listening"]["forward_time"])) self.forward_action = QAction("تقديم", self) self.forward_action.setShortcuts([QKeySequence("L"), QKeySequence("Ctrl+Alt+Right")]) - self.forward_action.triggered.connect(lambda: self.parent.toolbar.player.forward()) + self.forward_action.triggered.connect(lambda: self.parent.toolbar.player.forward(SettingsManager.current_settings["listening"]["forward_time"])) + self.replay_action = QAction("إعادة", self) + self.replay_action.setShortcut(QKeySequence("Ctrl+J")) + self.replay_action.triggered.connect(lambda: self.parent.toolbar.player.set_position(0)) + self.play_next_action = QAction("تشغيل الآية التالية", self) self.play_next_action.setShortcut(QKeySequence("Ctrl+Shift+N")) self.play_next_action.setEnabled(False) @@ -93,9 +97,11 @@ def create_menu(self): player_menu.addAction(self.stop_action) player_menu.addAction(self.rewind_action) player_menu.addAction(self.forward_action) + player_menu.addAction(self.replay_action) player_menu.addAction(self.play_next_action) player_menu.addAction(self.play_previous_action) + actions_menu = self.addMenu("الإجرائات(&A)") self.save_position_action = QAction("حفظ الموضع الحالي", self) self.save_position_action.setShortcut(QKeySequence("Ctrl+S")) diff --git a/utils/audio_player/bass_player.py b/utils/audio_player/bass_player.py index 9c4a48d..acaf9a9 100644 --- a/utils/audio_player/bass_player.py +++ b/utils/audio_player/bass_player.py @@ -114,7 +114,7 @@ def set_position(self, new_seconds: float) -> None: new_seconds = max(0.0, new_seconds) duration = self.BASS_ChannelBytes2Seconds(self.current_channel, bass.BASS_ChannelGetLength( self.current_channel, 0)) - new_seconds = min(new_seconds, duration) + new_seconds = min(new_seconds, duration-1) new_position = self.BASS_ChannelSeconds2Bytes(self.current_channel, new_seconds) self.BASS_ChannelSetPosition(self.current_channel, new_position, 0) diff --git a/utils/settings.py b/utils/settings.py index d888a7d..b1610a5 100644 --- a/utils/settings.py +++ b/utils/settings.py @@ -10,6 +10,7 @@ class SettingsManager: default_settings = { "general": { "language": "Arabic", + "ltr_direction": False, "run_in_background_enabled": False, "auto_start_enabled": False, "auto_save_position_enabled": False, @@ -28,6 +29,7 @@ class SettingsManager: "listening": { "reciter": 58, "action_after_listening": 0, + "forward_time": 5 }, "search": { "ignore_tashkeel": True,