@@ -162,12 +162,17 @@ def connect_signals(self):
162162 self .menubar .forward_action .triggered .connect (self .forward )
163163 self .rewind_button .clicked .connect (self .rewind )
164164 self .menubar .rewind_action .triggered .connect (self .rewind )
165+ self .menubar .replay_action .triggered .connect (self .replay )
165166 self .volume_up_button .clicked .connect (self .increase_volume )
166167 self .menubar .up_volume_action .triggered .connect (self .increase_volume )
167168 self .volume_down_button .clicked .connect (self .decrease_volume )
168169 self .menubar .down_volume_action .triggered .connect (self .decrease_volume )
169170 self .next_surah_button .clicked .connect (self .next_surah )
170171 self .previous_surah_button .clicked .connect (self .previous_surah )
172+ self .menubar .next_surah_action .triggered .connect (self .next_surah )
173+ self .menubar .previous_surah_action .triggered .connect (self .previous_surah )
174+ self .menubar .next_reciter_action .triggered .connect (self .next_reciter )
175+ self .menubar .previous_reciter_action .triggered .connect (self .previous_reciter )
171176 self .close_button .clicked .connect (self .OnClose )
172177 self .volume_slider .valueChanged .connect (self .update_volume )
173178 self .time_slider .valueChanged .connect (self .update_time )
@@ -193,31 +198,29 @@ def disable_focus(self):
193198 for widget in widgets :
194199 widget .setFocusPolicy (Qt .FocusPolicy .NoFocus )
195200
196- def setup_shortcuts (self , disable = False , first_time = True ):
201+ def setup_shortcuts (self , disable = False ,):
197202
198203 shortcuts = {
199- self .menubar .play_pause_action : "Space" ,
200- self .menubar .forward_action : "Right" ,
201- self .menubar .rewind_action : "Left" ,
204+ self .menubar .play_pause_action : ["Space" , "K" ],
205+ self .menubar .forward_action : ["Right" , "L" ],
206+ self .menubar .rewind_action : ["Left" , "J" ],
207+ self .menubar .replay_action : "Home" ,
202208 self .menubar .up_volume_action : "Up" ,
203209 self .menubar .down_volume_action : "Down" ,
210+ self .menubar .previous_surah_action : "Ctrl+Left" ,
211+ self .menubar .next_surah_action : "Ctrl+Right" ,
212+ self .menubar .next_reciter_action : "Ctrl+Down" ,
213+ self .menubar .previous_reciter_action : "Ctrl+Up" ,
204214 self .menubar .stop_action : "S" ,
205- self .close_button : "Ctrl+Q" ,
206- self .next_surah_button : "Ctrl+Right" ,
207- self .previous_surah_button : "Ctrl+Left" ,
208- }
215+ self .menubar .close_window_action : ["Ctrl+W" , "Ctrl+F4" ],
216+ self .menubar .close_program_action : "Ctrl+X" ,
217+ }
209218
210219 for widget , key_sequence in shortcuts .items ():
211- widget .setShortcut (QKeySequence (key_sequence ))
220+ key_sequence = [key_sequence ] if isinstance (key_sequence , str ) else key_sequence
221+ widget .setShortcuts ([QKeySequence (key ) for key in key_sequence ])
212222
213- shortcuts = {
214- "Ctrl+Down" : self .next_reciter ,
215- "Ctrl+Up" : self .previous_reciter
216- }
217223
218- if first_time :
219- for key_sequence , function in shortcuts .items ():
220- QShortcut (QKeySequence (key_sequence ), self ).activated .connect (function )
221224
222225 def update_current_reciter (self ):
223226 reciter_id = self .reciter_combo .currentData ()
@@ -236,6 +239,7 @@ def update_current_reciter(self):
236239 self .filter_manager .change_category_items (2 , sura_items )
237240 self .statusBar ().showMessage (f"القارئ الحالي: { self .reciter_combo .currentText ()} " )
238241 saved_sura = self .surah_combo .findData (self .preferences_manager .get_int ("sura_number" ))
242+ saved_sura = 0 if saved_sura == - 1 else saved_sura
239243 self .surah_combo .setCurrentIndex (saved_sura )
240244
241245 def update_current_surah (self ):
@@ -265,6 +269,10 @@ def forward(self):
265269 def rewind (self ):
266270 self .player .rewind (10 )
267271
272+ def replay (self ):
273+ self .player .set_position (0 )
274+
275+
268276 def next_surah (self ):
269277 current_index = self .surah_combo .currentIndex ()
270278 if current_index < self .surah_combo .count () - 1 :
@@ -382,15 +390,22 @@ def OnFilteredItemsUpdated(self, widget: QComboBox, items: List[Item], selected_
382390
383391 def keyPressEvent (self , event : QKeyEvent ):
384392
393+
394+
395+
385396 if self .filter_manager .handle_key_press (event ):
386397 return
387-
398+
399+ if event .modifiers () & (Qt .ControlModifier | Qt .ShiftModifier | Qt .AltModifier ):
400+ return
401+
388402 shortcuts = {
389403 ord ("E" ): lambda : UniversalSpeech .say (self .elapsed_time_label .text ()),
390404 ord ("R" ): lambda : UniversalSpeech .say (self .remaining_time_label .text ()),
391405 ord ("T" ): lambda : UniversalSpeech .say (self .total_time .text ()),
392406 ord ("C" ): lambda : UniversalSpeech .say (self .reciter_combo .currentText ()),
393407 ord ("V" ): lambda : UniversalSpeech .say (self .surah_combo .currentText ()),
408+ ord ("I" ): lambda : UniversalSpeech .say (F"{ self .surah_combo .currentText ()} , { self .reciter_combo .currentText ()} " ),
394409 }
395410
396411 key_native = event .nativeVirtualKey ()
0 commit comments