From 999f40ffc9ab0b5ca204fe6a5d3c759f8612802e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 3 Feb 2011 19:07:27 +0000 Subject: [PATCH] Exception Form has attachments --- openlp/core/ui/exceptionform.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index f9a9c59e0..a92967b6c 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -72,6 +72,7 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): def exec_(self): self.onDescriptionUpdated() + self.fileAttachment = None return QtGui.QDialog.exec_(self) def _createReport(self): @@ -152,9 +153,9 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): if u':' in line: exception = line.split(u'\n')[-1].split(u':')[0] subject = u'Bug report: %s in %s' % (exception, source) - if attach: + if self.fileAttachment: mailto(address=u'bugs@openlp.org', subject=subject, - body=body % content, attach=attach) + body=body % content, attach=self.fileAttachment) else: mailto(address=u'bugs@openlp.org', subject=subject, body=body % content) @@ -163,9 +164,24 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): count = int(20 - len(self.descriptionTextEdit.toPlainText())) if count < 0: count = 0 + self.__buttonState(True) + else: + self.__buttonState(False) self.descriptionWordCount.setText( unicode(translate('OpenLP.ExceptionDialog', 'Characters to Enter : %s')) % count ) def onAttachFileButtonPressed(self): - print self.descriptionTextEdit.toPlainText() + files = QtGui.QFileDialog.getOpenFileName( + self,translate('ImagePlugin.ExceptionDialog', + 'Select Attachment'), + SettingsManager.get_last_dir(u'exceptions'), + u'%s (*.*) (*)' % + unicode(translate('ImagePlugin.MediaItem', 'All Files'))) + log.info(u'New files(s) %s', unicode(files)) + if files: + self.fileAttachment = unicode(files) + + def __buttonState(self, state): + self.saveReportButton.setEnabled(state) + self.sendReportButton.setEnabled(state)