forked from openlp/openlp
execptionform: code standards
This commit is contained in:
parent
5d68663c10
commit
4f1933dcfe
@ -189,7 +189,7 @@ class OpenLP(QtGui.QApplication):
|
||||
log.exception(''.join(format_exception(exctype, value, traceback)))
|
||||
if not hasattr(self, u'exception_form'):
|
||||
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.exception_form.exec_()
|
||||
|
||||
|
@ -40,67 +40,67 @@ class Ui_ExceptionDialog(object):
|
||||
"""
|
||||
The GUI widgets of the exception dialog.
|
||||
"""
|
||||
def setupUi(self, exceptionDialog):
|
||||
def setupUi(self, exception_dialog):
|
||||
"""
|
||||
Set up the UI.
|
||||
"""
|
||||
exceptionDialog.setObjectName(u'exceptionDialog')
|
||||
self.exceptionLayout = QtGui.QVBoxLayout(exceptionDialog)
|
||||
self.exceptionLayout.setObjectName(u'exceptionLayout')
|
||||
self.messageLayout = QtGui.QHBoxLayout()
|
||||
self.messageLayout.setObjectName(u'messageLayout')
|
||||
self.messageLayout.addSpacing(12)
|
||||
self.bugLabel = QtGui.QLabel(exceptionDialog)
|
||||
self.bugLabel.setPixmap(QtGui.QPixmap(u':/graphics/exception.png'))
|
||||
self.bugLabel.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.bugLabel.setObjectName(u'bugLabel')
|
||||
self.messageLayout.addWidget(self.bugLabel)
|
||||
self.messageLayout.addSpacing(12)
|
||||
self.messageLabel = QtGui.QLabel(exceptionDialog)
|
||||
self.messageLabel.setWordWrap(True)
|
||||
self.messageLabel.setObjectName(u'messageLabel')
|
||||
self.messageLayout.addWidget(self.messageLabel)
|
||||
self.exceptionLayout.addLayout(self.messageLayout)
|
||||
self.descriptionExplanation = QtGui.QLabel(exceptionDialog)
|
||||
self.descriptionExplanation.setObjectName(u'descriptionExplanation')
|
||||
self.exceptionLayout.addWidget(self.descriptionExplanation)
|
||||
self.descriptionTextEdit = QtGui.QPlainTextEdit(exceptionDialog)
|
||||
self.descriptionTextEdit.setObjectName(u'descriptionTextEdit')
|
||||
self.exceptionLayout.addWidget(self.descriptionTextEdit)
|
||||
self.descriptionWordCount = QtGui.QLabel(exceptionDialog)
|
||||
self.descriptionWordCount.setObjectName(u'descriptionWordCount')
|
||||
self.exceptionLayout.addWidget(self.descriptionWordCount)
|
||||
self.exceptionTextEdit = QtGui.QPlainTextEdit(exceptionDialog)
|
||||
self.exceptionTextEdit.setReadOnly(True)
|
||||
self.exceptionTextEdit.setObjectName(u'exceptionTextEdit')
|
||||
self.exceptionLayout.addWidget(self.exceptionTextEdit)
|
||||
self.sendReportButton = create_button(exceptionDialog, u'sendReportButton',
|
||||
exception_dialog.setObjectName(u'exception_dialog')
|
||||
self.exception_layout = QtGui.QVBoxLayout(exception_dialog)
|
||||
self.exception_layout.setObjectName(u'exception_layout')
|
||||
self.message_layout = QtGui.QHBoxLayout()
|
||||
self.message_layout.setObjectName(u'messageLayout')
|
||||
self.message_layout.addSpacing(12)
|
||||
self.bug_label = QtGui.QLabel(exception_dialog)
|
||||
self.bug_label.setPixmap(QtGui.QPixmap(u':/graphics/exception.png'))
|
||||
self.bug_label.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
self.bug_label.setObjectName(u'bug_label')
|
||||
self.message_layout.addWidget(self.bug_label)
|
||||
self.message_layout.addSpacing(12)
|
||||
self.message_label = QtGui.QLabel(exception_dialog)
|
||||
self.message_label.setWordWrap(True)
|
||||
self.message_label.setObjectName(u'message_label')
|
||||
self.message_layout.addWidget(self.message_label)
|
||||
self.exception_layout.addLayout(self.message_layout)
|
||||
self.description_explanation = QtGui.QLabel(exception_dialog)
|
||||
self.description_explanation.setObjectName(u'description_explanation')
|
||||
self.exception_layout.addWidget(self.description_explanation)
|
||||
self.description_text_edit = QtGui.QPlainTextEdit(exception_dialog)
|
||||
self.description_text_edit.setObjectName(u'description_text_edit')
|
||||
self.exception_layout.addWidget(self.description_text_edit)
|
||||
self.description_word_count = QtGui.QLabel(exception_dialog)
|
||||
self.description_word_count.setObjectName(u'description_word_count')
|
||||
self.exception_layout.addWidget(self.description_word_count)
|
||||
self.exception_text_edit = QtGui.QPlainTextEdit(exception_dialog)
|
||||
self.exception_text_edit.setReadOnly(True)
|
||||
self.exception_text_edit.setObjectName(u'exception_text_edit')
|
||||
self.exception_layout.addWidget(self.exception_text_edit)
|
||||
self.send_report_button = create_button(exception_dialog, u'send_report_button',
|
||||
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)
|
||||
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)
|
||||
self.button_box = create_button_box(exceptionDialog, u'button_box',
|
||||
[u'close'], [self.sendReportButton, self.saveReportButton, self.attachFileButton])
|
||||
self.exceptionLayout.addWidget(self.button_box)
|
||||
self.button_box = create_button_box(exception_dialog, u'button_box',
|
||||
[u'close'], [self.send_report_button, self.save_report_button, self.attach_tile_button])
|
||||
self.exception_layout.addWidget(self.button_box)
|
||||
|
||||
self.retranslateUi(exceptionDialog)
|
||||
self.descriptionTextEdit.textChanged.connect(self.onDescriptionUpdated)
|
||||
self.retranslateUi(exception_dialog)
|
||||
self.description_text_edit.textChanged.connect(self.onDescriptionUpdated)
|
||||
|
||||
def retranslateUi(self, exceptionDialog):
|
||||
def retranslateUi(self, exception_dialog):
|
||||
"""
|
||||
Translate the widgets on the fly.
|
||||
"""
|
||||
exceptionDialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred'))
|
||||
self.descriptionExplanation.setText(translate('OpenLP.ExceptionDialog',
|
||||
exception_dialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred'))
|
||||
self.description_explanation.setText(translate('OpenLP.ExceptionDialog',
|
||||
'Please enter a description of what you were doing to cause this '
|
||||
'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 '
|
||||
'below contains information that might be helpful to the OpenLP '
|
||||
'developers, so please e-mail it to bugs@openlp.org, along with a '
|
||||
'detailed description of what you were doing when the problem '
|
||||
'occurred.'))
|
||||
self.sendReportButton.setText(translate('OpenLP.ExceptionDialog', 'Send E-Mail'))
|
||||
self.saveReportButton.setText(translate('OpenLP.ExceptionDialog', 'Save to File'))
|
||||
self.attachFileButton.setText(translate('OpenLP.ExceptionDialog', 'Attach File'))
|
||||
self.send_report_button.setText(translate('OpenLP.ExceptionDialog', 'Send E-Mail'))
|
||||
self.save_report_button.setText(translate('OpenLP.ExceptionDialog', 'Save to File'))
|
||||
self.attach_tile_button.setText(translate('OpenLP.ExceptionDialog', 'Attach File'))
|
||||
|
@ -112,7 +112,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
|
||||
"""
|
||||
Show the dialog.
|
||||
"""
|
||||
self.descriptionTextEdit.setPlainText(u'')
|
||||
self.description_text_edit.setPlainText(u'')
|
||||
self.onDescriptionUpdated()
|
||||
self.fileAttachment = None
|
||||
return QtGui.QDialog.exec_(self)
|
||||
@ -122,8 +122,8 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
|
||||
Create an exception report.
|
||||
"""
|
||||
openlp_version = get_application_version()
|
||||
description = self.descriptionTextEdit.toPlainText()
|
||||
traceback = self.exceptionTextEdit.toPlainText()
|
||||
description = self.description_text_edit.toPlainText()
|
||||
traceback = self.exception_text_edit.toPlainText()
|
||||
system = translate('OpenLP.ExceptionForm', 'Platform: %s\n') % platform.platform()
|
||||
libraries = u'Python: %s\n' % platform.python_version() + \
|
||||
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.
|
||||
"""
|
||||
count = int(20 - len(self.descriptionTextEdit.toPlainText()))
|
||||
count = int(20 - len(self.description_text_edit.toPlainText()))
|
||||
if count < 0:
|
||||
count = 0
|
||||
self.__buttonState(True)
|
||||
else:
|
||||
self.__buttonState(False)
|
||||
self.descriptionWordCount.setText(
|
||||
self.description_word_count.setText(
|
||||
translate('OpenLP.ExceptionDialog', 'Description characters to enter : %s') % count)
|
||||
|
||||
def onAttachFileButtonClicked(self):
|
||||
@ -238,5 +238,5 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
|
||||
"""
|
||||
Toggle the button state.
|
||||
"""
|
||||
self.saveReportButton.setEnabled(state)
|
||||
self.sendReportButton.setEnabled(state)
|
||||
self.save_report_button.setEnabled(state)
|
||||
self.send_report_button.setEnabled(state)
|
||||
|
Loading…
Reference in New Issue
Block a user