execptionform: code standards

This commit is contained in:
Andreas Preikschat 2013-03-05 15:02:56 +01:00
parent 5d68663c10
commit 4f1933dcfe
3 changed files with 54 additions and 54 deletions

View File

@ -189,7 +189,7 @@ class OpenLP(QtGui.QApplication):
log.exception(''.join(format_exception(exctype, value, traceback))) log.exception(''.join(format_exception(exctype, value, traceback)))
if not hasattr(self, u'exception_form'): if not hasattr(self, u'exception_form'):
self.exception_form = ExceptionForm(self.main_window) self.exception_form = ExceptionForm(self.main_window)
self.exception_form.exceptionTextEdit.setPlainText(''.join(format_exception(exctype, value, traceback))) self.exception_form.exception_text_edit.setPlainText(''.join(format_exception(exctype, value, traceback)))
self.set_normal_cursor() self.set_normal_cursor()
self.exception_form.exec_() self.exception_form.exec_()

View File

@ -40,67 +40,67 @@ class Ui_ExceptionDialog(object):
""" """
The GUI widgets of the exception dialog. The GUI widgets of the exception dialog.
""" """
def setupUi(self, exceptionDialog): def setupUi(self, exception_dialog):
""" """
Set up the UI. Set up the UI.
""" """
exceptionDialog.setObjectName(u'exceptionDialog') exception_dialog.setObjectName(u'exception_dialog')
self.exceptionLayout = QtGui.QVBoxLayout(exceptionDialog) self.exception_layout = QtGui.QVBoxLayout(exception_dialog)
self.exceptionLayout.setObjectName(u'exceptionLayout') self.exception_layout.setObjectName(u'exception_layout')
self.messageLayout = QtGui.QHBoxLayout() self.message_layout = QtGui.QHBoxLayout()
self.messageLayout.setObjectName(u'messageLayout') self.message_layout.setObjectName(u'messageLayout')
self.messageLayout.addSpacing(12) self.message_layout.addSpacing(12)
self.bugLabel = QtGui.QLabel(exceptionDialog) self.bug_label = QtGui.QLabel(exception_dialog)
self.bugLabel.setPixmap(QtGui.QPixmap(u':/graphics/exception.png')) self.bug_label.setPixmap(QtGui.QPixmap(u':/graphics/exception.png'))
self.bugLabel.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) self.bug_label.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
self.bugLabel.setObjectName(u'bugLabel') self.bug_label.setObjectName(u'bug_label')
self.messageLayout.addWidget(self.bugLabel) self.message_layout.addWidget(self.bug_label)
self.messageLayout.addSpacing(12) self.message_layout.addSpacing(12)
self.messageLabel = QtGui.QLabel(exceptionDialog) self.message_label = QtGui.QLabel(exception_dialog)
self.messageLabel.setWordWrap(True) self.message_label.setWordWrap(True)
self.messageLabel.setObjectName(u'messageLabel') self.message_label.setObjectName(u'message_label')
self.messageLayout.addWidget(self.messageLabel) self.message_layout.addWidget(self.message_label)
self.exceptionLayout.addLayout(self.messageLayout) self.exception_layout.addLayout(self.message_layout)
self.descriptionExplanation = QtGui.QLabel(exceptionDialog) self.description_explanation = QtGui.QLabel(exception_dialog)
self.descriptionExplanation.setObjectName(u'descriptionExplanation') self.description_explanation.setObjectName(u'description_explanation')
self.exceptionLayout.addWidget(self.descriptionExplanation) self.exception_layout.addWidget(self.description_explanation)
self.descriptionTextEdit = QtGui.QPlainTextEdit(exceptionDialog) self.description_text_edit = QtGui.QPlainTextEdit(exception_dialog)
self.descriptionTextEdit.setObjectName(u'descriptionTextEdit') self.description_text_edit.setObjectName(u'description_text_edit')
self.exceptionLayout.addWidget(self.descriptionTextEdit) self.exception_layout.addWidget(self.description_text_edit)
self.descriptionWordCount = QtGui.QLabel(exceptionDialog) self.description_word_count = QtGui.QLabel(exception_dialog)
self.descriptionWordCount.setObjectName(u'descriptionWordCount') self.description_word_count.setObjectName(u'description_word_count')
self.exceptionLayout.addWidget(self.descriptionWordCount) self.exception_layout.addWidget(self.description_word_count)
self.exceptionTextEdit = QtGui.QPlainTextEdit(exceptionDialog) self.exception_text_edit = QtGui.QPlainTextEdit(exception_dialog)
self.exceptionTextEdit.setReadOnly(True) self.exception_text_edit.setReadOnly(True)
self.exceptionTextEdit.setObjectName(u'exceptionTextEdit') self.exception_text_edit.setObjectName(u'exception_text_edit')
self.exceptionLayout.addWidget(self.exceptionTextEdit) self.exception_layout.addWidget(self.exception_text_edit)
self.sendReportButton = create_button(exceptionDialog, u'sendReportButton', self.send_report_button = create_button(exception_dialog, u'send_report_button',
icon=u':/general/general_email.png', click=self.onSendReportButtonClicked) icon=u':/general/general_email.png', click=self.onSendReportButtonClicked)
self.saveReportButton = create_button(exceptionDialog, u'saveReportButton', self.save_report_button = create_button(exception_dialog, u'save_report_button',
icon=u':/general/general_save.png', click=self.onSaveReportButtonClicked) icon=u':/general/general_save.png', click=self.onSaveReportButtonClicked)
self.attachFileButton = create_button(exceptionDialog, u'attachFileButton', self.attach_tile_button = create_button(exception_dialog, u'attach_tile_button',
icon=u':/general/general_open.png', click=self.onAttachFileButtonClicked) icon=u':/general/general_open.png', click=self.onAttachFileButtonClicked)
self.button_box = create_button_box(exceptionDialog, u'button_box', self.button_box = create_button_box(exception_dialog, u'button_box',
[u'close'], [self.sendReportButton, self.saveReportButton, self.attachFileButton]) [u'close'], [self.send_report_button, self.save_report_button, self.attach_tile_button])
self.exceptionLayout.addWidget(self.button_box) self.exception_layout.addWidget(self.button_box)
self.retranslateUi(exceptionDialog) self.retranslateUi(exception_dialog)
self.descriptionTextEdit.textChanged.connect(self.onDescriptionUpdated) self.description_text_edit.textChanged.connect(self.onDescriptionUpdated)
def retranslateUi(self, exceptionDialog): def retranslateUi(self, exception_dialog):
""" """
Translate the widgets on the fly. Translate the widgets on the fly.
""" """
exceptionDialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred')) exception_dialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred'))
self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog', self.description_explanation.setText(translate('OpenLP.ExceptionDialog',
'Please enter a description of what you were doing to cause this ' 'Please enter a description of what you were doing to cause this '
'error \n(Minimum 20 characters)')) 'error \n(Minimum 20 characters)'))
self.messageLabel.setText(translate('OpenLP.ExceptionDialog', 'Oops! ' self.message_label.setText(translate('OpenLP.ExceptionDialog', 'Oops! '
'OpenLP hit a problem, and couldn\'t recover. The text in the box ' 'OpenLP hit a problem, and couldn\'t recover. The text in the box '
'below contains information that might be helpful to the OpenLP ' 'below contains information that might be helpful to the OpenLP '
'developers, so please e-mail it to bugs@openlp.org, along with a ' 'developers, so please e-mail it to bugs@openlp.org, along with a '
'detailed description of what you were doing when the problem ' 'detailed description of what you were doing when the problem '
'occurred.')) 'occurred.'))
self.sendReportButton.setText(translate('OpenLP.ExceptionDialog', 'Send E-Mail')) self.send_report_button.setText(translate('OpenLP.ExceptionDialog', 'Send E-Mail'))
self.saveReportButton.setText(translate('OpenLP.ExceptionDialog', 'Save to File')) self.save_report_button.setText(translate('OpenLP.ExceptionDialog', 'Save to File'))
self.attachFileButton.setText(translate('OpenLP.ExceptionDialog', 'Attach File')) self.attach_tile_button.setText(translate('OpenLP.ExceptionDialog', 'Attach File'))

View File

@ -112,7 +112,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
""" """
Show the dialog. Show the dialog.
""" """
self.descriptionTextEdit.setPlainText(u'') self.description_text_edit.setPlainText(u'')
self.onDescriptionUpdated() self.onDescriptionUpdated()
self.fileAttachment = None self.fileAttachment = None
return QtGui.QDialog.exec_(self) return QtGui.QDialog.exec_(self)
@ -122,8 +122,8 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
Create an exception report. Create an exception report.
""" """
openlp_version = get_application_version() openlp_version = get_application_version()
description = self.descriptionTextEdit.toPlainText() description = self.description_text_edit.toPlainText()
traceback = self.exceptionTextEdit.toPlainText() traceback = self.exception_text_edit.toPlainText()
system = translate('OpenLP.ExceptionForm', 'Platform: %s\n') % platform.platform() system = translate('OpenLP.ExceptionForm', 'Platform: %s\n') % platform.platform()
libraries = u'Python: %s\n' % platform.python_version() + \ libraries = u'Python: %s\n' % platform.python_version() + \
u'Qt4: %s\n' % Qt.qVersion() + \ u'Qt4: %s\n' % Qt.qVersion() + \
@ -214,13 +214,13 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
""" """
Update the minimum number of characters needed in the description. Update the minimum number of characters needed in the description.
""" """
count = int(20 - len(self.descriptionTextEdit.toPlainText())) count = int(20 - len(self.description_text_edit.toPlainText()))
if count < 0: if count < 0:
count = 0 count = 0
self.__buttonState(True) self.__buttonState(True)
else: else:
self.__buttonState(False) self.__buttonState(False)
self.descriptionWordCount.setText( self.description_word_count.setText(
translate('OpenLP.ExceptionDialog', 'Description characters to enter : %s') % count) translate('OpenLP.ExceptionDialog', 'Description characters to enter : %s') % count)
def onAttachFileButtonClicked(self): def onAttachFileButtonClicked(self):
@ -238,5 +238,5 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
""" """
Toggle the button state. Toggle the button state.
""" """
self.saveReportButton.setEnabled(state) self.save_report_button.setEnabled(state)
self.sendReportButton.setEnabled(state) self.send_report_button.setEnabled(state)