235 @param textFormat format of the text (Qt.TextFormat) |
235 @param textFormat format of the text (Qt.TextFormat) |
236 @return flag indicating the selection of the Yes button (boolean) |
236 @return flag indicating the selection of the Yes button (boolean) |
237 """ |
237 """ |
238 assert icon in [Critical, Information, Question, Warning] |
238 assert icon in [Critical, Information, Question, Warning] |
239 |
239 |
240 res = __messageBox(parent, title, text, icon, |
240 res = __messageBox( |
241 QMessageBox.StandardButtons(QMessageBox.Yes | QMessageBox.No), |
241 parent, title, text, icon, |
242 yesDefault and QMessageBox.Yes or QMessageBox.No, |
242 QMessageBox.StandardButtons(QMessageBox.Yes | QMessageBox.No), |
243 textFormat) |
243 yesDefault and QMessageBox.Yes or QMessageBox.No, |
|
244 textFormat) |
244 return res == QMessageBox.Yes |
245 return res == QMessageBox.Yes |
245 |
246 |
246 |
247 |
247 def retryAbort(parent, title, text, icon=Question, textFormat=Qt.AutoText): |
248 def retryAbort(parent, title, text, icon=Question, textFormat=Qt.AutoText): |
248 """ |
249 """ |
256 @param textFormat format of the text (Qt.TextFormat) |
257 @param textFormat format of the text (Qt.TextFormat) |
257 @return flag indicating the selection of the Retry button (boolean) |
258 @return flag indicating the selection of the Retry button (boolean) |
258 """ |
259 """ |
259 assert icon in [Critical, Information, Question, Warning] |
260 assert icon in [Critical, Information, Question, Warning] |
260 |
261 |
261 res = __messageBox(parent, title, text, icon, |
262 res = __messageBox( |
262 QMessageBox.StandardButtons(QMessageBox.Retry | QMessageBox.Abort), |
263 parent, title, text, icon, |
263 QMessageBox.Retry, |
264 QMessageBox.StandardButtons(QMessageBox.Retry | QMessageBox.Abort), |
264 textFormat) |
265 QMessageBox.Retry, |
|
266 textFormat) |
265 return res == QMessageBox.Retry |
267 return res == QMessageBox.Retry |
266 |
268 |
267 |
269 |
268 def okToClearData(parent, title, text, saveFunc, textFormat=Qt.AutoText): |
270 def okToClearData(parent, title, text, saveFunc, textFormat=Qt.AutoText): |
269 """ |
271 """ |
275 @param saveFunc reference to a function performing the save action. It |
277 @param saveFunc reference to a function performing the save action. It |
276 must be a parameterless function returning a flag indicating success. |
278 must be a parameterless function returning a flag indicating success. |
277 @param textFormat format of the text (Qt.TextFormat) |
279 @param textFormat format of the text (Qt.TextFormat) |
278 @return flag indicating that it is ok to clear the data (boolean) |
280 @return flag indicating that it is ok to clear the data (boolean) |
279 """ |
281 """ |
280 res = __messageBox(parent, title, text, QMessageBox.Warning, |
282 res = __messageBox( |
281 QMessageBox.StandardButtons( |
283 parent, title, text, QMessageBox.Warning, |
282 QMessageBox.Abort | QMessageBox.Discard | QMessageBox.Save), |
284 QMessageBox.StandardButtons( |
283 QMessageBox.Save, |
285 QMessageBox.Abort | QMessageBox.Discard | QMessageBox.Save), |
284 textFormat) |
286 QMessageBox.Save, |
|
287 textFormat) |
285 if res == QMessageBox.Abort: |
288 if res == QMessageBox.Abort: |
286 return False |
289 return False |
287 if res == QMessageBox.Save: |
290 if res == QMessageBox.Save: |
288 return saveFunc() |
291 return saveFunc() |
289 return True |
292 return True |