11 |
11 |
12 from PyQt4.QtCore import * |
12 from PyQt4.QtCore import * |
13 from PyQt4.QtGui import * |
13 from PyQt4.QtGui import * |
14 |
14 |
15 from .Ui_MessageBoxWizardDialog import Ui_MessageBoxWizardDialog |
15 from .Ui_MessageBoxWizardDialog import Ui_MessageBoxWizardDialog |
|
16 |
16 |
17 |
17 class MessageBoxWizardDialog(QDialog, Ui_MessageBoxWizardDialog): |
18 class MessageBoxWizardDialog(QDialog, Ui_MessageBoxWizardDialog): |
18 """ |
19 """ |
19 Class implementing the message box wizard dialog. |
20 Class implementing the message box wizard dialog. |
20 |
21 |
30 QDialog.__init__(self, parent) |
31 QDialog.__init__(self, parent) |
31 self.setupUi(self) |
32 self.setupUi(self) |
32 |
33 |
33 # keep the following three lists in sync |
34 # keep the following three lists in sync |
34 self.buttonsList = [ |
35 self.buttonsList = [ |
35 self.trUtf8("No button"), |
36 self.trUtf8("No button"), |
36 self.trUtf8("Abort"), |
37 self.trUtf8("Abort"), |
37 self.trUtf8("Apply"), |
38 self.trUtf8("Apply"), |
38 self.trUtf8("Cancel"), |
39 self.trUtf8("Cancel"), |
39 self.trUtf8("Close"), |
40 self.trUtf8("Close"), |
40 self.trUtf8("Discard"), |
41 self.trUtf8("Discard"), |
41 self.trUtf8("Help"), |
42 self.trUtf8("Help"), |
42 self.trUtf8("Ignore"), |
43 self.trUtf8("Ignore"), |
43 self.trUtf8("No"), |
44 self.trUtf8("No"), |
44 self.trUtf8("No to all"), |
45 self.trUtf8("No to all"), |
45 self.trUtf8("Ok"), |
46 self.trUtf8("Ok"), |
46 self.trUtf8("Open"), |
47 self.trUtf8("Open"), |
47 self.trUtf8("Reset"), |
48 self.trUtf8("Reset"), |
48 self.trUtf8("Restore defaults"), |
49 self.trUtf8("Restore defaults"), |
49 self.trUtf8("Retry"), |
50 self.trUtf8("Retry"), |
50 self.trUtf8("Save"), |
51 self.trUtf8("Save"), |
51 self.trUtf8("Save all"), |
52 self.trUtf8("Save all"), |
52 self.trUtf8("Yes"), |
53 self.trUtf8("Yes"), |
53 self.trUtf8("Yes to all"), |
54 self.trUtf8("Yes to all"), |
54 ] |
55 ] |
55 self.buttonsCodeListBinary = [ |
56 self.buttonsCodeListBinary = [ |
56 QMessageBox.NoButton, |
57 QMessageBox.NoButton, |
57 QMessageBox.Abort, |
58 QMessageBox.Abort, |
58 QMessageBox.Apply, |
59 QMessageBox.Apply, |
158 self.eCaption.text(), |
159 self.eCaption.text(), |
159 self.eMessage.toPlainText(), |
160 self.eMessage.toPlainText(), |
160 QMessageBox.StandardButtons(buttons), |
161 QMessageBox.StandardButtons(buttons), |
161 defaultButton |
162 defaultButton |
162 ) |
163 ) |
163 elif self.rWarning.isChecked(): |
164 elif self.rWarning.isChecked(): |
164 QMessageBox.warning(self, |
165 QMessageBox.warning(self, |
165 self.eCaption.text(), |
166 self.eCaption.text(), |
166 self.eMessage.toPlainText(), |
167 self.eMessage.toPlainText(), |
167 QMessageBox.StandardButtons(buttons), |
168 QMessageBox.StandardButtons(buttons), |
168 defaultButton |
169 defaultButton |
279 joinstring = ' | \\{0}{1}'.format(os.linesep, istring2) |
280 joinstring = ' | \\{0}{1}'.format(os.linesep, istring2) |
280 btnCode = ',{0}{1}QMessageBox.StandardButtons('.format(os.linesep, istring) |
281 btnCode = ',{0}{1}QMessageBox.StandardButtons('.format(os.linesep, istring) |
281 btnCode += '{0}{1}{2})'.format(os.linesep, istring2, joinstring.join(buttons)) |
282 btnCode += '{0}{1}{2})'.format(os.linesep, istring2, joinstring.join(buttons)) |
282 defaultIndex = self.defaultCombo.currentIndex() |
283 defaultIndex = self.defaultCombo.currentIndex() |
283 if defaultIndex: |
284 if defaultIndex: |
284 btnCode += ',{0}{1}{2}'.format(os.linesep, istring, |
285 btnCode += ',{0}{1}{2}'.format(os.linesep, istring, |
285 self.buttonsCodeListText[defaultIndex]) |
286 self.buttonsCodeListText[defaultIndex]) |
286 return btnCode |
287 return btnCode |
287 |
288 |
288 def getCode(self, indLevel, indString): |
289 def getCode(self, indLevel, indString): |
289 """ |
290 """ |
317 elif self.rQuestion.isChecked(): |
318 elif self.rQuestion.isChecked(): |
318 msgdlg = "res = QMessageBox.question({0},{1}".format(parent, os.linesep) |
319 msgdlg = "res = QMessageBox.question({0},{1}".format(parent, os.linesep) |
319 elif self.rWarning.isChecked(): |
320 elif self.rWarning.isChecked(): |
320 msgdlg = "res = QMessageBox.warning({0},{1}".format(parent, os.linesep) |
321 msgdlg = "res = QMessageBox.warning({0},{1}".format(parent, os.linesep) |
321 else: |
322 else: |
322 msgdlg ="res = QMessageBox.critical({0},{1}".format(parent, os.linesep) |
323 msgdlg = "res = QMessageBox.critical({0},{1}".format(parent, os.linesep) |
323 |
324 |
324 msgdlg += '{0}self.trUtf8("{1}")'.format(istring, self.eCaption.text()) |
325 msgdlg += '{0}self.trUtf8("{1}")'.format(istring, self.eCaption.text()) |
325 if not self.rAboutQt.isChecked(): |
326 if not self.rAboutQt.isChecked(): |
326 msgdlg += ',{0}{1}self.trUtf8("""{2}""")'.format( |
327 msgdlg += ',{0}{1}self.trUtf8("""{2}""")'.format( |
327 os.linesep, istring, self.eMessage.toPlainText()) |
328 os.linesep, istring, self.eMessage.toPlainText()) |
328 if not self.rAbout.isChecked() and not self.rAboutQt.isChecked(): |
329 if not self.rAbout.isChecked() and not self.rAboutQt.isChecked(): |
329 msgdlg += self.__getButtonCode(istring, indString) |
330 msgdlg += self.__getButtonCode(istring, indString) |
330 msgdlg +='){0}'.format(estring) |
331 msgdlg += '){0}'.format(estring) |
331 return msgdlg |
332 return msgdlg |