Improve exception dialog

This commit is contained in:
Samuel Mehrbrodt 2015-08-26 10:20:55 +02:00
parent 0c9f23a875
commit 2df4dad39c
2 changed files with 11 additions and 19 deletions

View File

@ -90,14 +90,15 @@ class Ui_ExceptionDialog(object):
""" """
exception_dialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred')) exception_dialog.setWindowTitle(translate('OpenLP.ExceptionDialog', 'Error Occurred'))
self.description_explanation.setText( self.description_explanation.setText(
translate('OpenLP.ExceptionDialog', 'Please enter a description of what you were doing to cause this error ' translate('OpenLP.ExceptionDialog', 'Please enter a description of what you were doing to cause this error.'
' If possible, write in English.'
'\n(Minimum 20 characters)')) '\n(Minimum 20 characters)'))
self.message_label.setText( self.message_label.setText(
translate('OpenLP.ExceptionDialog', 'Oops! OpenLP hit a problem, and couldn\'t recover. The text in the ' 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 ' 'box 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. Also attach any files that triggered the problem.'))
self.send_report_button.setText(translate('OpenLP.ExceptionDialog', 'Send E-Mail')) self.send_report_button.setText(translate('OpenLP.ExceptionDialog', 'Send E-Mail'))
self.save_report_button.setText(translate('OpenLP.ExceptionDialog', 'Save to File')) self.save_report_button.setText(translate('OpenLP.ExceptionDialog', 'Save to File'))
self.attach_tile_button.setText(translate('OpenLP.ExceptionDialog', 'Attach File')) self.attach_tile_button.setText(translate('OpenLP.ExceptionDialog', 'Attach File'))

View File

@ -97,6 +97,12 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties):
super(ExceptionForm, self).__init__() super(ExceptionForm, self).__init__()
self.setupUi(self) self.setupUi(self)
self.settings_section = 'crashreport' self.settings_section = 'crashreport'
self.report_text = '**OpenLP Bug Report**\n' \
'Version: %s\n\n' \
'--- Details of the Exception. ---\n\n%s\n\n ' \
'--- Exception Traceback ---\n%s\n' \
'--- System information ---\n%s\n' \
'--- Library Versions ---\n%s\n'
def exec_(self): def exec_(self):
""" """
@ -143,13 +149,6 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties):
""" """
Saving exception log and system information to a file. Saving exception log and system information to a file.
""" """
report_text = translate('OpenLP.ExceptionForm',
'**OpenLP Bug Report**\n'
'Version: %s\n\n'
'--- Details of the Exception. ---\n\n%s\n\n '
'--- Exception Traceback ---\n%s\n'
'--- System information ---\n%s\n'
'--- Library Versions ---\n%s\n')
filename = QtGui.QFileDialog.getSaveFileName( filename = QtGui.QFileDialog.getSaveFileName(
self, self,
translate('OpenLP.ExceptionForm', 'Save Crash Report'), translate('OpenLP.ExceptionForm', 'Save Crash Report'),
@ -158,7 +157,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties):
if filename: if filename:
filename = str(filename).replace('/', os.path.sep) filename = str(filename).replace('/', os.path.sep)
Settings().setValue(self.settings_section + '/last directory', os.path.dirname(filename)) Settings().setValue(self.settings_section + '/last directory', os.path.dirname(filename))
report_text = report_text % self._create_report() report_text = self.report_text % self._create_report()
try: try:
report_file = open(filename, 'w') report_file = open(filename, 'w')
try: try:
@ -178,14 +177,6 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties):
""" """
Opening systems default email client and inserting exception log and system information. Opening systems default email client and inserting exception log and system information.
""" """
body = translate('OpenLP.ExceptionForm',
'*OpenLP Bug Report*\n'
'Version: %s\n\n'
'--- Details of the Exception. ---\n\n%s\n\n '
'--- Exception Traceback ---\n%s\n'
'--- System information ---\n%s\n'
'--- Library Versions ---\n%s\n',
'Please add the information that bug reports are favoured written in English.')
content = self._create_report() content = self._create_report()
source = '' source = ''
exception = '' exception = ''
@ -197,7 +188,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties):
subject = 'Bug report: %s in %s' % (exception, source) subject = 'Bug report: %s in %s' % (exception, source)
mail_to_url = QtCore.QUrl('mailto:bugs@openlp.org') mail_to_url = QtCore.QUrl('mailto:bugs@openlp.org')
mail_to_url.addQueryItem('subject', subject) mail_to_url.addQueryItem('subject', subject)
mail_to_url.addQueryItem('body', body % content) mail_to_url.addQueryItem('body', self.report_text % content)
if self.file_attachment: if self.file_attachment:
mail_to_url.addQueryItem('attach', self.file_attachment) mail_to_url.addQueryItem('attach', self.file_attachment)
QtGui.QDesktopServices.openUrl(mail_to_url) QtGui.QDesktopServices.openUrl(mail_to_url)