@@ -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 ()
0 commit comments