33from PyQt6 .QtGui import QKeyEvent
44from PyQt6 .QtWidgets import QTextEdit
55from utils .settings import SettingsManager
6+ from utils .const import Globals
67
78
89class ReadOnlyTextEdit (QTextEdit ):
@@ -22,6 +23,7 @@ class QuranViewer(ReadOnlyTextEdit):
2223 def __init__ (self , parent = None ):
2324 super ().__init__ (parent )
2425 self .parent = parent
26+ self .is_page_turn_alert = False
2527 self .textChanged .connect (self .set_ctrl )
2628
2729 def set_ctrl (self ):
@@ -49,11 +51,20 @@ def keyPressEvent(self, e):
4951 current_line = self .textCursor ().block ().blockNumber ()
5052 total_lines = self .document ().blockCount ()
5153
54+ if current_line >= 1 and current_line + 1 != total_lines :
55+ self .is_page_turn_alert = False
56+
5257 if e .key () == Qt .Key .Key_Up :
5358 if (current_line == 0 ) and (self .parent .quran .current_pos > 1 ):
59+ if not self .is_page_turn_alert :
60+ self .is_page_turn_alert = True
61+ Globals .effects_manager .play ("edit_alert" )
62+ return
5463 self .parent .OnBack ()
5564 elif e .key () == Qt .Key .Key_Down :
5665 if (current_line == total_lines - 1 ) and (self .parent .quran .current_pos < self .parent .quran .max_pos ):
66+ if not self .is_page_turn_alert :
67+ self .is_page_turn_alert = True
68+ Globals .effects_manager .play ("edit_alert" )
69+ return
5770 self .parent .OnNext ()
58-
59-
0 commit comments