54 self.tr("Save all"), |
54 self.tr("Save all"), |
55 self.tr("Yes"), |
55 self.tr("Yes"), |
56 self.tr("Yes to all"), |
56 self.tr("Yes to all"), |
57 ] |
57 ] |
58 self.buttonsCodeListBinary = [ |
58 self.buttonsCodeListBinary = [ |
59 E5MessageBox.NoButton, |
59 EricMessageBox.NoButton, |
60 E5MessageBox.Abort, |
60 EricMessageBox.Abort, |
61 E5MessageBox.Apply, |
61 EricMessageBox.Apply, |
62 E5MessageBox.Cancel, |
62 EricMessageBox.Cancel, |
63 E5MessageBox.Close, |
63 EricMessageBox.Close, |
64 E5MessageBox.Discard, |
64 EricMessageBox.Discard, |
65 E5MessageBox.Help, |
65 EricMessageBox.Help, |
66 E5MessageBox.Ignore, |
66 EricMessageBox.Ignore, |
67 E5MessageBox.No, |
67 EricMessageBox.No, |
68 E5MessageBox.NoToAll, |
68 EricMessageBox.NoToAll, |
69 E5MessageBox.Ok, |
69 EricMessageBox.Ok, |
70 E5MessageBox.Open, |
70 EricMessageBox.Open, |
71 E5MessageBox.Reset, |
71 EricMessageBox.Reset, |
72 E5MessageBox.RestoreDefaults, |
72 EricMessageBox.RestoreDefaults, |
73 E5MessageBox.Retry, |
73 EricMessageBox.Retry, |
74 E5MessageBox.Save, |
74 EricMessageBox.Save, |
75 E5MessageBox.SaveAll, |
75 EricMessageBox.SaveAll, |
76 E5MessageBox.Yes, |
76 EricMessageBox.Yes, |
77 E5MessageBox.YesToAll, |
77 EricMessageBox.YesToAll, |
78 ] |
78 ] |
79 self.buttonsCodeListText = [ |
79 self.buttonsCodeListText = [ |
80 "E5MessageBox.NoButton", |
80 "EricMessageBox.NoButton", |
81 "E5MessageBox.Abort", |
81 "EricMessageBox.Abort", |
82 "E5MessageBox.Apply", |
82 "EricMessageBox.Apply", |
83 "E5MessageBox.Cancel", |
83 "EricMessageBox.Cancel", |
84 "E5MessageBox.Close", |
84 "EricMessageBox.Close", |
85 "E5MessageBox.Discard", |
85 "EricMessageBox.Discard", |
86 "E5MessageBox.Help", |
86 "EricMessageBox.Help", |
87 "E5MessageBox.Ignore", |
87 "EricMessageBox.Ignore", |
88 "E5MessageBox.No", |
88 "EricMessageBox.No", |
89 "E5MessageBox.NoToAll", |
89 "EricMessageBox.NoToAll", |
90 "E5MessageBox.Ok", |
90 "EricMessageBox.Ok", |
91 "E5MessageBox.Open", |
91 "EricMessageBox.Open", |
92 "E5MessageBox.Reset", |
92 "EricMessageBox.Reset", |
93 "E5MessageBox.RestoreDefaults", |
93 "EricMessageBox.RestoreDefaults", |
94 "E5MessageBox.Retry", |
94 "EricMessageBox.Retry", |
95 "E5MessageBox.Save", |
95 "EricMessageBox.Save", |
96 "E5MessageBox.SaveAll", |
96 "EricMessageBox.SaveAll", |
97 "E5MessageBox.Yes", |
97 "EricMessageBox.Yes", |
98 "E5MessageBox.YesToAll", |
98 "EricMessageBox.YesToAll", |
99 ] |
99 ] |
100 |
100 |
101 self.defaultCombo.addItems(self.buttonsList) |
101 self.defaultCombo.addItems(self.buttonsList) |
102 |
102 |
103 self.bTest = self.buttonBox.addButton( |
103 self.bTest = self.buttonBox.addButton( |
248 def on_bTest_clicked(self): |
248 def on_bTest_clicked(self): |
249 """ |
249 """ |
250 Private method to test the selected options. |
250 Private method to test the selected options. |
251 """ |
251 """ |
252 if self.rAbout.isChecked(): |
252 if self.rAbout.isChecked(): |
253 E5MessageBox.about( |
253 EricMessageBox.about( |
254 None, |
254 None, |
255 self.eCaption.text(), |
255 self.eCaption.text(), |
256 self.eMessage.toPlainText() |
256 self.eMessage.toPlainText() |
257 ) |
257 ) |
258 elif self.rAboutQt.isChecked(): |
258 elif self.rAboutQt.isChecked(): |
259 E5MessageBox.aboutQt( |
259 EricMessageBox.aboutQt( |
260 None, self.eCaption.text() |
260 None, self.eCaption.text() |
261 ) |
261 ) |
262 elif ( |
262 elif ( |
263 self.rInformation.isChecked() or |
263 self.rInformation.isChecked() or |
264 self.rQuestion.isChecked() or |
264 self.rQuestion.isChecked() or |
265 self.rWarning.isChecked() or |
265 self.rWarning.isChecked() or |
266 self.rCritical.isChecked() |
266 self.rCritical.isChecked() |
267 ): |
267 ): |
268 buttons = E5MessageBox.NoButton |
268 buttons = EricMessageBox.NoButton |
269 if self.abortCheck.isChecked(): |
269 if self.abortCheck.isChecked(): |
270 buttons |= E5MessageBox.Abort |
270 buttons |= EricMessageBox.Abort |
271 if self.applyCheck.isChecked(): |
271 if self.applyCheck.isChecked(): |
272 buttons |= E5MessageBox.Apply |
272 buttons |= EricMessageBox.Apply |
273 if self.cancelCheck.isChecked(): |
273 if self.cancelCheck.isChecked(): |
274 buttons |= E5MessageBox.Cancel |
274 buttons |= EricMessageBox.Cancel |
275 if self.closeCheck.isChecked(): |
275 if self.closeCheck.isChecked(): |
276 buttons |= E5MessageBox.Close |
276 buttons |= EricMessageBox.Close |
277 if self.discardCheck.isChecked(): |
277 if self.discardCheck.isChecked(): |
278 buttons |= E5MessageBox.Discard |
278 buttons |= EricMessageBox.Discard |
279 if self.helpCheck.isChecked(): |
279 if self.helpCheck.isChecked(): |
280 buttons |= E5MessageBox.Help |
280 buttons |= EricMessageBox.Help |
281 if self.ignoreCheck.isChecked(): |
281 if self.ignoreCheck.isChecked(): |
282 buttons |= E5MessageBox.Ignore |
282 buttons |= EricMessageBox.Ignore |
283 if self.noCheck.isChecked(): |
283 if self.noCheck.isChecked(): |
284 buttons |= E5MessageBox.No |
284 buttons |= EricMessageBox.No |
285 if self.notoallCheck.isChecked(): |
285 if self.notoallCheck.isChecked(): |
286 buttons |= E5MessageBox.NoToAll |
286 buttons |= EricMessageBox.NoToAll |
287 if self.okCheck.isChecked(): |
287 if self.okCheck.isChecked(): |
288 buttons |= E5MessageBox.Ok |
288 buttons |= EricMessageBox.Ok |
289 if self.openCheck.isChecked(): |
289 if self.openCheck.isChecked(): |
290 buttons |= E5MessageBox.Open |
290 buttons |= EricMessageBox.Open |
291 if self.resetCheck.isChecked(): |
291 if self.resetCheck.isChecked(): |
292 buttons |= E5MessageBox.Reset |
292 buttons |= EricMessageBox.Reset |
293 if self.restoreCheck.isChecked(): |
293 if self.restoreCheck.isChecked(): |
294 buttons |= E5MessageBox.RestoreDefaults |
294 buttons |= EricMessageBox.RestoreDefaults |
295 if self.retryCheck.isChecked(): |
295 if self.retryCheck.isChecked(): |
296 buttons |= E5MessageBox.Retry |
296 buttons |= EricMessageBox.Retry |
297 if self.saveCheck.isChecked(): |
297 if self.saveCheck.isChecked(): |
298 buttons |= E5MessageBox.Save |
298 buttons |= EricMessageBox.Save |
299 if self.saveallCheck.isChecked(): |
299 if self.saveallCheck.isChecked(): |
300 buttons |= E5MessageBox.SaveAll |
300 buttons |= EricMessageBox.SaveAll |
301 if self.yesCheck.isChecked(): |
301 if self.yesCheck.isChecked(): |
302 buttons |= E5MessageBox.Yes |
302 buttons |= EricMessageBox.Yes |
303 if self.yestoallCheck.isChecked(): |
303 if self.yestoallCheck.isChecked(): |
304 buttons |= E5MessageBox.YesToAll |
304 buttons |= EricMessageBox.YesToAll |
305 if buttons == E5MessageBox.NoButton: |
305 if buttons == EricMessageBox.NoButton: |
306 buttons = E5MessageBox.Ok |
306 buttons = EricMessageBox.Ok |
307 |
307 |
308 defaultButton = self.buttonsCodeListBinary[ |
308 defaultButton = self.buttonsCodeListBinary[ |
309 self.defaultCombo.currentIndex()] |
309 self.defaultCombo.currentIndex()] |
310 |
310 |
311 if self.rInformation.isChecked(): |
311 if self.rInformation.isChecked(): |
312 E5MessageBox.information( |
312 EricMessageBox.information( |
313 self, |
313 self, |
314 self.eCaption.text(), |
314 self.eCaption.text(), |
315 self.eMessage.toPlainText(), |
315 self.eMessage.toPlainText(), |
316 buttons, |
316 buttons, |
317 defaultButton |
317 defaultButton |
318 ) |
318 ) |
319 elif self.rQuestion.isChecked(): |
319 elif self.rQuestion.isChecked(): |
320 E5MessageBox.question( |
320 EricMessageBox.question( |
321 self, |
321 self, |
322 self.eCaption.text(), |
322 self.eCaption.text(), |
323 self.eMessage.toPlainText(), |
323 self.eMessage.toPlainText(), |
324 buttons, |
324 buttons, |
325 defaultButton |
325 defaultButton |
326 ) |
326 ) |
327 elif self.rWarning.isChecked(): |
327 elif self.rWarning.isChecked(): |
328 E5MessageBox.warning( |
328 EricMessageBox.warning( |
329 self, |
329 self, |
330 self.eCaption.text(), |
330 self.eCaption.text(), |
331 self.eMessage.toPlainText(), |
331 self.eMessage.toPlainText(), |
332 buttons, |
332 buttons, |
333 defaultButton |
333 defaultButton |
334 ) |
334 ) |
335 elif self.rCritical.isChecked(): |
335 elif self.rCritical.isChecked(): |
336 E5MessageBox.critical( |
336 EricMessageBox.critical( |
337 self, |
337 self, |
338 self.eCaption.text(), |
338 self.eCaption.text(), |
339 self.eMessage.toPlainText(), |
339 self.eMessage.toPlainText(), |
340 buttons, |
340 buttons, |
341 defaultButton |
341 defaultButton |
343 elif ( |
343 elif ( |
344 self.rYesNo.isChecked() or |
344 self.rYesNo.isChecked() or |
345 self.rRetryAbort.isChecked() |
345 self.rRetryAbort.isChecked() |
346 ): |
346 ): |
347 if self.iconInformation.isChecked(): |
347 if self.iconInformation.isChecked(): |
348 icon = E5MessageBox.Information |
348 icon = EricMessageBox.Information |
349 elif self.iconQuestion.isChecked(): |
349 elif self.iconQuestion.isChecked(): |
350 icon = E5MessageBox.Question |
350 icon = EricMessageBox.Question |
351 elif self.iconWarning.isChecked(): |
351 elif self.iconWarning.isChecked(): |
352 icon = E5MessageBox.Warning |
352 icon = EricMessageBox.Warning |
353 elif self.iconCritical.isChecked(): |
353 elif self.iconCritical.isChecked(): |
354 icon = E5MessageBox.Critical |
354 icon = EricMessageBox.Critical |
355 |
355 |
356 if self.rYesNo.isChecked(): |
356 if self.rYesNo.isChecked(): |
357 E5MessageBox.yesNo( |
357 EricMessageBox.yesNo( |
358 self, |
358 self, |
359 self.eCaption.text(), |
359 self.eCaption.text(), |
360 self.eMessage.toPlainText(), |
360 self.eMessage.toPlainText(), |
361 icon=icon, |
361 icon=icon, |
362 yesDefault=self.yesDefaultCheck.isChecked() |
362 yesDefault=self.yesDefaultCheck.isChecked() |
363 ) |
363 ) |
364 elif self.rRetryAbort.isChecked(): |
364 elif self.rRetryAbort.isChecked(): |
365 E5MessageBox.retryAbort( |
365 EricMessageBox.retryAbort( |
366 self, |
366 self, |
367 self.eCaption.text(), |
367 self.eCaption.text(), |
368 self.eMessage.toPlainText(), |
368 self.eMessage.toPlainText(), |
369 icon=icon |
369 icon=icon |
370 ) |
370 ) |
371 elif self.rOkToClearData.isChecked(): |
371 elif self.rOkToClearData.isChecked(): |
372 E5MessageBox.okToClearData( |
372 EricMessageBox.okToClearData( |
373 self, |
373 self, |
374 self.eCaption.text(), |
374 self.eCaption.text(), |
375 self.eMessage.toPlainText(), |
375 self.eMessage.toPlainText(), |
376 lambda: True |
376 lambda: True |
377 ) |
377 ) |
386 with introductory text (boolean) |
386 with introductory text (boolean) |
387 @return the button code (string) |
387 @return the button code (string) |
388 """ |
388 """ |
389 buttons = [] |
389 buttons = [] |
390 if self.abortCheck.isChecked(): |
390 if self.abortCheck.isChecked(): |
391 buttons.append("E5MessageBox.Abort") |
391 buttons.append("EricMessageBox.Abort") |
392 if self.applyCheck.isChecked(): |
392 if self.applyCheck.isChecked(): |
393 buttons.append("E5MessageBox.Apply") |
393 buttons.append("EricMessageBox.Apply") |
394 if self.cancelCheck.isChecked(): |
394 if self.cancelCheck.isChecked(): |
395 buttons.append("E5MessageBox.Cancel") |
395 buttons.append("EricMessageBox.Cancel") |
396 if self.closeCheck.isChecked(): |
396 if self.closeCheck.isChecked(): |
397 buttons.append("E5MessageBox.Close") |
397 buttons.append("EricMessageBox.Close") |
398 if self.discardCheck.isChecked(): |
398 if self.discardCheck.isChecked(): |
399 buttons.append("E5MessageBox.Discard") |
399 buttons.append("EricMessageBox.Discard") |
400 if self.helpCheck.isChecked(): |
400 if self.helpCheck.isChecked(): |
401 buttons.append("E5MessageBox.Help") |
401 buttons.append("EricMessageBox.Help") |
402 if self.ignoreCheck.isChecked(): |
402 if self.ignoreCheck.isChecked(): |
403 buttons.append("E5MessageBox.Ignore") |
403 buttons.append("EricMessageBox.Ignore") |
404 if self.noCheck.isChecked(): |
404 if self.noCheck.isChecked(): |
405 buttons.append("E5MessageBox.No") |
405 buttons.append("EricMessageBox.No") |
406 if self.notoallCheck.isChecked(): |
406 if self.notoallCheck.isChecked(): |
407 buttons.append("E5MessageBox.NoToAll") |
407 buttons.append("EricMessageBox.NoToAll") |
408 if self.okCheck.isChecked(): |
408 if self.okCheck.isChecked(): |
409 buttons.append("E5MessageBox.Ok") |
409 buttons.append("EricMessageBox.Ok") |
410 if self.openCheck.isChecked(): |
410 if self.openCheck.isChecked(): |
411 buttons.append("E5MessageBox.Open") |
411 buttons.append("EricMessageBox.Open") |
412 if self.resetCheck.isChecked(): |
412 if self.resetCheck.isChecked(): |
413 buttons.append("E5MessageBox.Reset") |
413 buttons.append("EricMessageBox.Reset") |
414 if self.restoreCheck.isChecked(): |
414 if self.restoreCheck.isChecked(): |
415 buttons.append("E5MessageBox.RestoreDefaults") |
415 buttons.append("EricMessageBox.RestoreDefaults") |
416 if self.retryCheck.isChecked(): |
416 if self.retryCheck.isChecked(): |
417 buttons.append("E5MessageBox.Retry") |
417 buttons.append("EricMessageBox.Retry") |
418 if self.saveCheck.isChecked(): |
418 if self.saveCheck.isChecked(): |
419 buttons.append("E5MessageBox.Save") |
419 buttons.append("EricMessageBox.Save") |
420 if self.saveallCheck.isChecked(): |
420 if self.saveallCheck.isChecked(): |
421 buttons.append("E5MessageBox.SaveAll") |
421 buttons.append("EricMessageBox.SaveAll") |
422 if self.yesCheck.isChecked(): |
422 if self.yesCheck.isChecked(): |
423 buttons.append("E5MessageBox.Yes") |
423 buttons.append("EricMessageBox.Yes") |
424 if self.yestoallCheck.isChecked(): |
424 if self.yestoallCheck.isChecked(): |
425 buttons.append("E5MessageBox.YesToAll") |
425 buttons.append("EricMessageBox.YesToAll") |
426 if len(buttons) == 0: |
426 if len(buttons) == 0: |
427 return "" |
427 return "" |
428 |
428 |
429 istring2 = istring + indString |
429 istring2 = istring + indString |
430 joinstring = ' |{0}{1}'.format(os.linesep, istring2) |
430 joinstring = ' |{0}{1}'.format(os.linesep, istring2) |
475 parent = self.parentEdit.text() |
475 parent = self.parentEdit.text() |
476 if parent == "": |
476 if parent == "": |
477 parent = "None" |
477 parent = "None" |
478 |
478 |
479 if self.iconInformation.isChecked(): |
479 if self.iconInformation.isChecked(): |
480 icon = "E5MessageBox.Information" |
480 icon = "EricMessageBox.Information" |
481 elif self.iconQuestion.isChecked(): |
481 elif self.iconQuestion.isChecked(): |
482 icon = "E5MessageBox.Question" |
482 icon = "EricMessageBox.Question" |
483 elif self.iconWarning.isChecked(): |
483 elif self.iconWarning.isChecked(): |
484 icon = "E5MessageBox.Warning" |
484 icon = "EricMessageBox.Warning" |
485 elif self.iconCritical.isChecked(): |
485 elif self.iconCritical.isChecked(): |
486 icon = "E5MessageBox.Critical" |
486 icon = "EricMessageBox.Critical" |
487 |
487 |
488 if not self.rStandard.isChecked(): |
488 if not self.rStandard.isChecked(): |
489 resvar = self.eResultVar.text() |
489 resvar = self.eResultVar.text() |
490 if not resvar: |
490 if not resvar: |
491 resvar = "res" |
491 resvar = "res" |
492 |
492 |
493 if self.rAbout.isChecked(): |
493 if self.rAbout.isChecked(): |
494 msgdlg = "E5MessageBox.about({0}".format(os.linesep) |
494 msgdlg = "EricMessageBox.about({0}".format(os.linesep) |
495 elif self.rAboutQt.isChecked(): |
495 elif self.rAboutQt.isChecked(): |
496 msgdlg = "E5MessageBox.aboutQt({0}".format(os.linesep) |
496 msgdlg = "EricMessageBox.aboutQt({0}".format(os.linesep) |
497 elif self.rInformation.isChecked(): |
497 elif self.rInformation.isChecked(): |
498 msgdlg = "{0} = E5MessageBox.information({1}".format( |
498 msgdlg = "{0} = EricMessageBox.information({1}".format( |
499 resvar, os.linesep) |
499 resvar, os.linesep) |
500 elif self.rQuestion.isChecked(): |
500 elif self.rQuestion.isChecked(): |
501 msgdlg = "{0} = E5MessageBox.question({1}".format( |
501 msgdlg = "{0} = EricMessageBox.question({1}".format( |
502 resvar, os.linesep) |
502 resvar, os.linesep) |
503 elif self.rWarning.isChecked(): |
503 elif self.rWarning.isChecked(): |
504 msgdlg = "{0} = E5MessageBox.warning({1}".format( |
504 msgdlg = "{0} = EricMessageBox.warning({1}".format( |
505 resvar, os.linesep) |
505 resvar, os.linesep) |
506 elif self.rCritical.isChecked(): |
506 elif self.rCritical.isChecked(): |
507 msgdlg = "{0} = E5MessageBox.critical({1}".format( |
507 msgdlg = "{0} = EricMessageBox.critical({1}".format( |
508 resvar, os.linesep) |
508 resvar, os.linesep) |
509 elif self.rYesNo.isChecked(): |
509 elif self.rYesNo.isChecked(): |
510 msgdlg = "{0} = E5MessageBox.yesNo({1}".format( |
510 msgdlg = "{0} = EricMessageBox.yesNo({1}".format( |
511 resvar, os.linesep) |
511 resvar, os.linesep) |
512 elif self.rRetryAbort.isChecked(): |
512 elif self.rRetryAbort.isChecked(): |
513 msgdlg = "{0} = E5MessageBox.retryAbort({1}".format( |
513 msgdlg = "{0} = EricMessageBox.retryAbort({1}".format( |
514 resvar, os.linesep) |
514 resvar, os.linesep) |
515 elif self.rOkToClearData.isChecked(): |
515 elif self.rOkToClearData.isChecked(): |
516 msgdlg = "{0} = E5MessageBox.okToClearData({1}".format( |
516 msgdlg = "{0} = EricMessageBox.okToClearData({1}".format( |
517 resvar, os.linesep) |
517 resvar, os.linesep) |
518 |
518 |
519 msgdlg += '{0}{1},{2}'.format(istring, parent, os.linesep) |
519 msgdlg += '{0}{1},{2}'.format(istring, parent, os.linesep) |
520 msgdlg += '{0}self.tr("{1}")'.format( |
520 msgdlg += '{0}self.tr("{1}")'.format( |
521 istring, self.eCaption.text()) |
521 istring, self.eCaption.text()) |