Skip to content

Commit 95da7bd

Browse files
committed
Changed add dialogues and message boxes to customize the buttons names.
1 parent 39c8f3b commit 95da7bd

File tree

3 files changed

+93
-23
lines changed

3 files changed

+93
-23
lines changed

ui/dialogs/bookmark_dialog.py

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,41 +89,74 @@ def search_bookmarks(self):
8989
self.load_bookmarks(bookmarks)
9090

9191
def update_bookmark(self):
92-
9392
selected_items = self.bookmark_list.selectedItems()
9493
if not selected_items:
95-
QMessageBox.warning(self, "Selection Error", "لم يتم تحديد أي علامة")
94+
msg_box = QMessageBox(self)
95+
msg_box.setIcon(QMessageBox.Icon.Warning)
96+
msg_box.setWindowTitle("خطأ في التحديد")
97+
msg_box.setText("لم يتم تحديد أي علامة.")
98+
99+
ok_button = msg_box.addButton("موافق", QMessageBox.ButtonRole.AcceptRole)
100+
msg_box.exec()
96101
return
97102

98103
item = selected_items[0]
99104
bookmark = item.data(Qt.ItemDataRole.UserRole)
100105
bookmark_id = bookmark["id"]
101-
new_name, ok = QInputDialog.getText(self, "Update Bookmark", "Enter new bookmark name:", text=bookmark["name"])
102-
if ok and new_name:
103-
self.manager.update_bookmark(bookmark_id, new_name)
104-
current_row = self.bookmark_list.currentRow()
105-
self.load_bookmarks()
106-
self.bookmark_list.setCurrentRow(current_row)
107-
self.bookmark_list.setFocus()
106+
new_name = ""
107+
# Create an instance of QInputDialog
108+
dialog = QInputDialog(self)
109+
dialog.setWindowTitle("تحديث العلامة")
110+
dialog.setLabelText("أدخل اسم جديد للعلامة:")
111+
dialog.setTextValue(bookmark["name"])
112+
113+
# Change the button texts to Arabic.
114+
dialog.setOkButtonText("حفظ")
115+
dialog.setCancelButtonText("إلغاء")
116+
117+
# Execute the dialog and check the result.
118+
if dialog.exec() == QDialog.Accepted:
119+
new_name = dialog.textValue()
120+
if new_name:
121+
self.manager.update_bookmark(bookmark_id, new_name)
122+
current_row = self.bookmark_list.currentRow()
123+
self.load_bookmarks()
124+
self.bookmark_list.setCurrentRow(current_row)
125+
self.bookmark_list.setFocus()
126+
127+
108128

109129
def delete_bookmark(self):
110130

111131
selected_items = self.bookmark_list.selectedItems()
112132
if not selected_items:
113-
QMessageBox.warning(self, "Selection Error", "لم يتم تحديد أي علامة.")
133+
msg_box = QMessageBox(self)
134+
msg_box.setIcon(QMessageBox.Icon.Warning)
135+
msg_box.setWindowTitle("خطأ في التحديد")
136+
msg_box.setText("لم يتم تحديد أي علامة.")
137+
138+
ok_button = msg_box.addButton("موافق", QMessageBox.ButtonRole.AcceptRole)
139+
140+
msg_box.exec()
141+
114142
return
143+
115144

116145
item = selected_items[0]
117146
bookmark = item.data(Qt.ItemDataRole.UserRole)
118147
bookmark_id = bookmark["id"]
148+
149+
msg_box = QMessageBox(self)
150+
msg_box.setIcon(QMessageBox.Icon.Warning)
151+
msg_box.setWindowTitle("تحذير")
152+
msg_box.setText(f"هل أنت متأكد إنك تريد حذف هذه العلامة؟\n\nالاسم: {bookmark['name']}")
153+
154+
yes_button = msg_box.addButton("نعم", QMessageBox.ButtonRole.AcceptRole)
155+
no_button = msg_box.addButton("لا", QMessageBox.ButtonRole.RejectRole)
119156

120-
reply = QMessageBox.warning(
121-
self, "تحذير",
122-
f"هل أنت متأكد إنك تريد حذف هذه العلامة؟\n\nالاسم: {bookmark['name']}",
123-
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No
124-
)
157+
msg_box.exec()
125158

126-
if reply == QMessageBox.StandardButton.Yes:
159+
if msg_box.clickedButton() == yes_button:
127160
self.manager.delete_bookmark(bookmark_id)
128161
self.load_bookmarks()
129162
self.bookmark_list.setFocus()

ui/quran_interface.py

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,45 @@ def OnSaveBookmark(self, event):
336336
criteria_number = self.quran.type
337337

338338
if bookmark_manager.is_exist(aya_info[1]):
339-
QMessageBox.critical(self, "خطأ", f"تم حفظ العلامة المرجعية مسبقًا.")
340-
return
339+
msgBox = QMessageBox(self)
340+
msgBox.setIcon(QMessageBox.Critical)
341+
msgBox.setWindowTitle("خطأ")
342+
msgBox.setText("تم حفظ العلامة المرجعية مسبقًا.")
341343

342-
name, ok = QInputDialog.getText(self, "اسم العلامة", "أدخل اسم العلامة:")
343-
if ok and name:
344-
bookmark_manager.insert_bookmark(name, aya_info[1], aya_info[3], aya_info[0], aya_info[2], criteria_number)
345-
self.quran_view.setFocus()
344+
345+
msgBox.addButton("موافق", QMessageBox.AcceptRole)
346+
msgBox.exec()
347+
348+
return
349+
350+
351+
dialog = QInputDialog(self)
352+
dialog.setWindowTitle("اسم العلامة")
353+
dialog.setLabelText("أدخل اسم العلامة:")
354+
dialog.setTextValue("")
355+
356+
357+
dialog.setOkButtonText("إضافة")
358+
dialog.setCancelButtonText("إلغاء")
359+
360+
361+
if dialog.exec() == dialog.Accepted:
362+
name = dialog.textValue()
363+
if name:
364+
bookmark_manager.insert_bookmark(
365+
name,
366+
aya_info[1],
367+
aya_info[3],
368+
aya_info[0],
369+
aya_info[2],
370+
criteria_number
371+
)
372+
self.quran_view.setFocus()
373+
else:
374+
# Optionally, handle the case where the user accepts without entering a name
375+
return
376+
else:
377+
return
346378

347379
def OnSaveCurrentPosition(self):
348380
self.user_data_manager.save_position(

ui/widgets/menu_bar.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,12 @@ def OnAbout(self):
279279
f"إصدار البرنامج: {program_version}\n"
280280
f"الموقع الرسمي للبرنامج: {website}\n"
281281
)
282-
QMessageBox.about(self, "حول البرنامج", about_text)
282+
msg_box = QMessageBox(self)
283+
msg_box.setIcon(QMessageBox.Icon.Information)
284+
msg_box.setWindowTitle("حول البرنامج")
285+
msg_box.setText(about_text)
286+
ok_button = msg_box.addButton("موافق", QMessageBox.ButtonRole.AcceptRole)
287+
msg_box.exec()
283288

284289
def OnGoTo(self):
285290
category_number = self.parent.quran.type

0 commit comments

Comments
 (0)