src/eric7/EricWidgets/EricMessageBox.py

branch
eric7
changeset 9757
ab6e87f6f1c4
parent 9653
e67609152c5e
child 10060
b946699e9e79
equal deleted inserted replaced
9756:9854647c8c5c 9757:ab6e87f6f1c4
323 return res == QMessageBox.StandardButton.Retry 323 return res == QMessageBox.StandardButton.Retry
324 324
325 325
326 def okToClearData(parent, title, text, saveFunc, textFormat=Qt.TextFormat.AutoText): 326 def okToClearData(parent, title, text, saveFunc, textFormat=Qt.TextFormat.AutoText):
327 """ 327 """
328 Function to show a model message box to ask for clearing the data. 328 Function to show a modal message box to ask for clearing the data.
329 329
330 @param parent parent widget of the message box (QWidget) 330 @param parent parent widget of the message box (QWidget)
331 @param title caption of the message box (string) 331 @param title caption of the message box (string)
332 @param text text to be shown by the message box (string) 332 @param text text to be shown by the message box (string)
333 @param saveFunc reference to a function performing the save action. It 333 @param saveFunc reference to a function performing the save action. It
334 must be a parameterless function returning a flag indicating success. 334 must be a parameterless function returning a flag indicating success.
335 @param textFormat format of the text (Qt.TextFormat) 335 @param textFormat format of the text (Qt.TextFormat)
336 @return flag indicating that it is ok to clear the data (boolean) 336 @return flag indicating that it is ok to clear the data (boolean)
337 """ 337 """
338 buttons = QMessageBox.StandardButton.Abort | QMessageBox.StandardButton.Discard
339 if saveFunc:
340 buttons |= QMessageBox.StandardButton.Save
338 res = __messageBox( 341 res = __messageBox(
339 parent, 342 parent,
340 title, 343 title,
341 text, 344 text,
342 QMessageBox.Icon.Warning, 345 QMessageBox.Icon.Warning,
343 ( 346 buttons,
344 QMessageBox.StandardButton.Abort
345 | QMessageBox.StandardButton.Discard
346 | QMessageBox.StandardButton.Save
347 ),
348 QMessageBox.StandardButton.Save, 347 QMessageBox.StandardButton.Save,
349 textFormat, 348 textFormat,
350 ) 349 )
351 if res == QMessageBox.StandardButton.Abort: 350 if res == QMessageBox.StandardButton.Abort:
352 return False 351 return False

eric ide

mercurial