Skip to content

Commit

Permalink
Merge branch 'albayan_beta' of https://github.com/tecwindow/albayan i…
Browse files Browse the repository at this point in the history
…nto albayan_beta
  • Loading branch information
MesterPerfect committed Dec 19, 2024
2 parents fc411c0 + 00e5aba commit 3b89f02
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
14 changes: 13 additions & 1 deletion ui/dialogs/settings_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
QSpacerItem,
QSizePolicy,
QHBoxLayout,
QSpinBox,
QStackedWidget
)
from PyQt6.QtGui import QKeySequence
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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"])
Expand Down
10 changes: 8 additions & 2 deletions ui/widgets/menu_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion utils/audio_player/bass_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,6 +29,7 @@ class SettingsManager:
"listening": {
"reciter": 58,
"action_after_listening": 0,
"forward_time": 5
},
"search": {
"ignore_tashkeel": True,
Expand Down

0 comments on commit 3b89f02

Please sign in to comment.