From 4f1933dcfeb13f7cb6dd709de2418a45510685d9 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Tue, 5 Mar 2013 15:02:56 +0100 Subject: [PATCH] execptionform: code standards --- openlp/core/__init__.py | 2 +- openlp/core/ui/exceptiondialog.py | 92 +++++++++++++++---------------- openlp/core/ui/exceptionform.py | 14 ++--- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 9b5eef8a2..cb3fafcc7 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -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_() diff --git a/openlp/core/ui/exceptiondialog.py b/openlp/core/ui/exceptiondialog.py index 7b9339237..b71c28f2d 100644 --- a/openlp/core/ui/exceptiondialog.py +++ b/openlp/core/ui/exceptiondialog.py @@ -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')) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 50885b15b..29acf4f2a 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -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)