Plugins/WizardPlugins/E5MessageBoxWizard/E5MessageBoxWizardDialog.py

changeset 945
8cd4d08fa9f6
parent 564
b3d966393ba9
child 1131
7781e396c903
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
11 11
12 from E5Gui import E5MessageBox 12 from E5Gui import E5MessageBox
13 13
14 from .Ui_E5MessageBoxWizardDialog import Ui_E5MessageBoxWizardDialog 14 from .Ui_E5MessageBoxWizardDialog import Ui_E5MessageBoxWizardDialog
15 15
16
16 class E5MessageBoxWizardDialog(QDialog, Ui_E5MessageBoxWizardDialog): 17 class E5MessageBoxWizardDialog(QDialog, Ui_E5MessageBoxWizardDialog):
17 """ 18 """
18 Class implementing the eric5 message box wizard dialog. 19 Class implementing the eric5 message box wizard dialog.
19 20
20 It displays a dialog for entering the parameters 21 It displays a dialog for entering the parameters
21 for the E5MessageBox code generator. 22 for the E5MessageBox code generator.
22 """ 23 """
23 def __init__(self, parent = None): 24 def __init__(self, parent=None):
24 """ 25 """
25 Constructor 26 Constructor
26 27
27 @param parent reference to the parent widget (QWidget) 28 @param parent reference to the parent widget (QWidget)
28 """ 29 """
29 QDialog.__init__(self, parent) 30 QDialog.__init__(self, parent)
30 self.setupUi(self) 31 self.setupUi(self)
31 32
32 # keep the following three lists in sync 33 # keep the following three lists in sync
33 self.buttonsList = [ 34 self.buttonsList = [
34 self.trUtf8("No button"), 35 self.trUtf8("No button"),
35 self.trUtf8("Abort"), 36 self.trUtf8("Abort"),
36 self.trUtf8("Apply"), 37 self.trUtf8("Apply"),
37 self.trUtf8("Cancel"), 38 self.trUtf8("Cancel"),
38 self.trUtf8("Close"), 39 self.trUtf8("Close"),
39 self.trUtf8("Discard"), 40 self.trUtf8("Discard"),
40 self.trUtf8("Help"), 41 self.trUtf8("Help"),
41 self.trUtf8("Ignore"), 42 self.trUtf8("Ignore"),
42 self.trUtf8("No"), 43 self.trUtf8("No"),
43 self.trUtf8("No to all"), 44 self.trUtf8("No to all"),
44 self.trUtf8("Ok"), 45 self.trUtf8("Ok"),
45 self.trUtf8("Open"), 46 self.trUtf8("Open"),
46 self.trUtf8("Reset"), 47 self.trUtf8("Reset"),
47 self.trUtf8("Restore defaults"), 48 self.trUtf8("Restore defaults"),
48 self.trUtf8("Retry"), 49 self.trUtf8("Retry"),
49 self.trUtf8("Save"), 50 self.trUtf8("Save"),
50 self.trUtf8("Save all"), 51 self.trUtf8("Save all"),
51 self.trUtf8("Yes"), 52 self.trUtf8("Yes"),
52 self.trUtf8("Yes to all"), 53 self.trUtf8("Yes to all"),
53 ] 54 ]
54 self.buttonsCodeListBinary = [ 55 self.buttonsCodeListBinary = [
55 E5MessageBox.NoButton, 56 E5MessageBox.NoButton,
56 E5MessageBox.Abort, 57 E5MessageBox.Abort,
57 E5MessageBox.Apply, 58 E5MessageBox.Apply,
302 self.eCaption.text(), 303 self.eCaption.text(),
303 self.eMessage.toPlainText(), 304 self.eMessage.toPlainText(),
304 E5MessageBox.StandardButtons(buttons), 305 E5MessageBox.StandardButtons(buttons),
305 defaultButton 306 defaultButton
306 ) 307 )
307 elif self.rWarning.isChecked(): 308 elif self.rWarning.isChecked():
308 E5MessageBox.warning(self, 309 E5MessageBox.warning(self,
309 self.eCaption.text(), 310 self.eCaption.text(),
310 self.eMessage.toPlainText(), 311 self.eMessage.toPlainText(),
311 E5MessageBox.StandardButtons(buttons), 312 E5MessageBox.StandardButtons(buttons),
312 defaultButton 313 defaultButton
328 icon = E5MessageBox.Warning 329 icon = E5MessageBox.Warning
329 elif self.iconCritical.isChecked(): 330 elif self.iconCritical.isChecked():
330 icon = E5MessageBox.Critical 331 icon = E5MessageBox.Critical
331 332
332 if self.rYesNo.isChecked(): 333 if self.rYesNo.isChecked():
333 E5MessageBox.yesNo(self, 334 E5MessageBox.yesNo(self,
334 self.eCaption.text(), 335 self.eCaption.text(),
335 self.eMessage.toPlainText(), 336 self.eMessage.toPlainText(),
336 icon = icon, 337 icon=icon,
337 yesDefault = self.yesDefaultCheck.isChecked() 338 yesDefault=self.yesDefaultCheck.isChecked()
338 ) 339 )
339 elif self.rRetryAbort.isChecked(): 340 elif self.rRetryAbort.isChecked():
340 E5MessageBox.retryAbort(self, 341 E5MessageBox.retryAbort(self,
341 self.eCaption.text(), 342 self.eCaption.text(),
342 self.eMessage.toPlainText(), 343 self.eMessage.toPlainText(),
343 icon = icon 344 icon=icon
344 ) 345 )
345 elif self.rOkToClearData.isChecked(): 346 elif self.rOkToClearData.isChecked():
346 E5MessageBox.okToClearData(self, 347 E5MessageBox.okToClearData(self,
347 self.eCaption.text(), 348 self.eCaption.text(),
348 self.eMessage.toPlainText(), 349 self.eMessage.toPlainText(),
349 lambda: True 350 lambda: True
350 ) 351 )
351 352
352 def __getStandardButtonCode(self, istring, indString, withIntro = True): 353 def __getStandardButtonCode(self, istring, indString, withIntro=True):
353 """ 354 """
354 Private method to generate the button code for the standard buttons. 355 Private method to generate the button code for the standard buttons.
355 356
356 @param istring indentation string (string) 357 @param istring indentation string (string)
357 @param indString string used for indentation (space or tab) (string) 358 @param indString string used for indentation (space or tab) (string)
358 @keyparam withIntro flag indicating to generate a first line 359 @keyparam withIntro flag indicating to generate a first line
359 with introductory text (boolean) 360 with introductory text (boolean)
360 @return the button code (string) 361 @return the button code (string)
361 """ 362 """
362 buttons = [] 363 buttons = []
363 if self.abortCheck.isChecked(): 364 if self.abortCheck.isChecked():
418 @return the button code (string) 419 @return the button code (string)
419 """ 420 """
420 btnCode = "" 421 btnCode = ""
421 defaultIndex = self.defaultCombo.currentIndex() 422 defaultIndex = self.defaultCombo.currentIndex()
422 if defaultIndex: 423 if defaultIndex:
423 btnCode = ',{0}{1}{2}'.format(os.linesep, istring, 424 btnCode = ',{0}{1}{2}'.format(os.linesep, istring,
424 self.buttonsCodeListText[defaultIndex]) 425 self.buttonsCodeListText[defaultIndex])
425 return btnCode 426 return btnCode
426 427
427 def getCode(self, indLevel, indString): 428 def getCode(self, indLevel, indString):
428 """ 429 """
467 elif self.rQuestion.isChecked(): 468 elif self.rQuestion.isChecked():
468 msgdlg = "res = E5MessageBox.question({0},{1}".format(parent, os.linesep) 469 msgdlg = "res = E5MessageBox.question({0},{1}".format(parent, os.linesep)
469 elif self.rWarning.isChecked(): 470 elif self.rWarning.isChecked():
470 msgdlg = "res = E5MessageBox.warning({0},{1}".format(parent, os.linesep) 471 msgdlg = "res = E5MessageBox.warning({0},{1}".format(parent, os.linesep)
471 elif self.rCritical.isChecked(): 472 elif self.rCritical.isChecked():
472 msgdlg ="res = E5MessageBox.critical({0},{1}".format(parent, os.linesep) 473 msgdlg = "res = E5MessageBox.critical({0},{1}".format(parent, os.linesep)
473 elif self.rYesNo.isChecked(): 474 elif self.rYesNo.isChecked():
474 msgdlg ="res = E5MessageBox.yesNo({0},{1}".format(parent, os.linesep) 475 msgdlg = "res = E5MessageBox.yesNo({0},{1}".format(parent, os.linesep)
475 elif self.rRetryAbort.isChecked(): 476 elif self.rRetryAbort.isChecked():
476 msgdlg ="res = E5MessageBox.retryAbort({0},{1}".format(parent, os.linesep) 477 msgdlg = "res = E5MessageBox.retryAbort({0},{1}".format(parent, os.linesep)
477 elif self.rOkToClearData.isChecked(): 478 elif self.rOkToClearData.isChecked():
478 msgdlg ="res = E5MessageBox.okToClearData({0},{1}".format( 479 msgdlg = "res = E5MessageBox.okToClearData({0},{1}".format(
479 parent, os.linesep) 480 parent, os.linesep)
480 481
481 msgdlg += '{0}self.trUtf8("{1}")'.format(istring, self.eCaption.text()) 482 msgdlg += '{0}self.trUtf8("{1}")'.format(istring, self.eCaption.text())
482 483
483 if not self.rAboutQt.isChecked(): 484 if not self.rAboutQt.isChecked():
502 saveFunc = self.saveFuncEdit.text() 503 saveFunc = self.saveFuncEdit.text()
503 if saveFunc == "": 504 if saveFunc == "":
504 saveFunc = "lambda: True" 505 saveFunc = "lambda: True"
505 msgdlg += ',{0}{1}{2}'.format(os.linesep, istring, saveFunc) 506 msgdlg += ',{0}{1}{2}'.format(os.linesep, istring, saveFunc)
506 else: 507 else:
507 msgdlg ="E5MessageBox.E5MessageBox({0}, {1}".format(icon, os.linesep) 508 msgdlg = "E5MessageBox.E5MessageBox({0}, {1}".format(icon, os.linesep)
508 msgdlg += '{0}self.trUtf8("{1}")'.format(istring, self.eCaption.text()) 509 msgdlg += '{0}self.trUtf8("{1}")'.format(istring, self.eCaption.text())
509 msgdlg += ',{0}{1}self.trUtf8("""{2}""")'.format( 510 msgdlg += ',{0}{1}self.trUtf8("""{2}""")'.format(
510 os.linesep, istring, self.eMessage.toPlainText()) 511 os.linesep, istring, self.eMessage.toPlainText())
511 if self.modalCheck.isChecked(): 512 if self.modalCheck.isChecked():
512 msgdlg += ',{0}{1}modal = True'.format(os.linesep, istring) 513 msgdlg += ',{0}{1}modal = True'.format(os.linesep, istring)
513 btnCode = self.__getStandardButtonCode(istring, indString, withIntro = False) 514 btnCode = self.__getStandardButtonCode(istring, indString, withIntro=False)
514 if btnCode: 515 if btnCode:
515 msgdlg += ',{0}{1}buttons = {2}'.format(os.linesep, istring, btnCode) 516 msgdlg += ',{0}{1}buttons = {2}'.format(os.linesep, istring, btnCode)
516 if not self.parentNone.isChecked(): 517 if not self.parentNone.isChecked():
517 msgdlg += ',{0}{1}parent = {2}'.format(os.linesep, istring, parent) 518 msgdlg += ',{0}{1}parent = {2}'.format(os.linesep, istring, parent)
518 519
519 msgdlg +='){0}'.format(estring) 520 msgdlg += '){0}'.format(estring)
520 return msgdlg 521 return msgdlg

eric ide

mercurial