Skip to content

Commit cec58eb

Browse files
committed
Add auto-restore position option to Quran view
The QuranInterface now accepts an auto_restore_position_enabled flag from config to determine whether to restore the last position or start from the beginning. The set_text method was updated to support this behavior, and debug logging was added. MenuBar's saved position action now explicitly restores the position.
1 parent cd42e36 commit cec58eb

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

ui/quran_interface.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def __init__(self, title):
7373
self.tray_manager = SystemTrayManager(self, program_name, program_icon)
7474
self.create_widgets()
7575
self.create_layout()
76-
self.set_text()
76+
77+
self.set_text(Config.general.auto_restore_position_enabled)
78+
logger.debug(f"restore setting is: {Config.general.auto_restore_position_enabled}")
7779
self.set_shortcut()
7880
logger.debug("QuranInterface initialized successfully.")
7981

@@ -174,10 +176,15 @@ def create_layout(self):
174176
self.centralWidget().setLayout(layout)
175177

176178

177-
def set_text(self):
179+
def set_text(self, restore: bool = True):
178180
logger.debug("Loading Quran text...")
179-
ayah_number = self.preferences_manager.get_int("current_ayah_number", 1)
180-
current_position = self.preferences_manager.get_int("current_position", 1)
181+
if not restore:
182+
current_position = 1
183+
ayah_number = 1
184+
else:
185+
ayah_number = self.preferences_manager.get_int("current_ayah_number", 1)
186+
current_position = self.preferences_manager.get_int("current_position")
187+
181188
mode = self.preferences_manager.get_int("navigation_mode", NavigationMode.SURAH.value)
182189
self.quran_manager.navigation_mode = NavigationMode.from_int(mode)
183190
logger.debug(f"Current position: {current_position}, Ayah number: {ayah_number}, Mode: {self.quran_manager.navigation_mode}")

ui/widgets/menu_bar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def create_menu(self):
4040
self.previous_action = QAction("السابق", self)
4141
self.previous_action.triggered.connect(self.parent.OnBack)
4242
self.go_to_saved_position_action = QAction("الذهاب إلى الموضع المحفوظ", self)
43-
self.go_to_saved_position_action.triggered.connect(self.parent.set_text)
43+
self.go_to_saved_position_action.triggered.connect(lambda: self.parent.set_text(True))
4444
self.go_to_saved_position_action.triggered.connect(lambda: Globals.effects_manager.play("move"))
4545
self.search_action = QAction("البحث", self)
4646
self.search_action.triggered.connect(self.parent.OnSearch)

0 commit comments

Comments
 (0)