Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Audio/sounds/nuzool.ogg
Binary file not shown.
20 changes: 20 additions & 0 deletions ui/widgets/qText_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from PyQt6.QtGui import QKeyEvent, QTextCursor
from PyQt6.QtWidgets import QTextEdit
from core_functions.quran.types import NavigationMode
from core_functions.info import TanzilAyah
from utils.settings import Config
from utils.const import Globals
from utils.logger import LoggerManager
Expand Down Expand Up @@ -52,10 +53,29 @@ def set_ctrl(self):
self.parent.menu_bar.copy_verse_action.setEnabled(status)
#logger.debug(f"Control state set to: {status}.")

def _announce_nuzul_if_available(self):
"""After moving to a new verse, announce if it has a reason of revelation."""
try:
current_line_text = self.textCursor().block().text()
# Only check actual verse lines (they end with a verse number like (5))
if not re.search(r"\(\d+\)$", current_line_text):
return
ayah = self.parent.quran_manager.view_content.get_by_position(
self.textCursor().block().position()
)
if TanzilAyah(ayah.number).text:
Globals.effects_manager.play("nuzool")
logger.debug(f"Nuzul sound played for ayah {ayah.number}.")
except Exception:
pass # Never crash the viewer over an announcement

def keyPressEvent(self, e):
super().keyPressEvent(e)
self.set_ctrl()

if e.key() in (Qt.Key.Key_Up, Qt.Key.Key_Down):
self._announce_nuzul_if_available()

if e.key() in (Qt.Key.Key_Return, Qt.Key.Key_Enter) and self.parent.menu_bar.verse_tafsir_action.isEnabled():
self.parent.OnInterpretation(event=e)
logger.debug("Enter key pressed, triggering Tafsir.")
Expand Down