From 3865d3cb9f35c17c7e5f739f4bbf6f2df22e4b79 Mon Sep 17 00:00:00 2001 From: nimda Date: Sun, 16 Jun 2013 18:28:18 -0400 Subject: [PATCH] 'Save message as...' option in Inbox --- src/bitmessageqt/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 195403ea..98d5467a 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -104,6 +104,7 @@ class MyForm(QtGui.QMainWindow): self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Add sender to your Address Book"), self.on_action_InboxAddSenderToAddressBook) self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Move to Trash"), self.on_action_InboxTrash) self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "View HTML code as formatted text"), self.on_action_InboxMessageForceHtml) + self.actionSaveMessageAs = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate("MainWindow", "Save message as..."), self.on_action_InboxSaveMessageAs) self.ui.tableWidgetInbox.setContextMenuPolicy( QtCore.Qt.CustomContextMenu ) self.connect(self.ui.tableWidgetInbox, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menuInbox) self.popMenuInbox = QtGui.QMenu( self ) @@ -112,6 +113,7 @@ class MyForm(QtGui.QMainWindow): self.popMenuInbox.addAction( self.actionReply ) self.popMenuInbox.addAction( self.actionAddSenderToAddressBook ) self.popMenuInbox.addSeparator() + self.popMenuInbox.addAction( self.actionSaveMessageAs ) self.popMenuInbox.addAction( self.actionTrashInboxMessage ) @@ -1787,6 +1789,24 @@ class MyForm(QtGui.QMainWindow): else: self.ui.tableWidgetInbox.selectRow(currentRow-1) + def on_action_InboxSaveMessageAs(self): + currentInboxRow = self.ui.tableWidgetInbox.currentRow() + subjectAtCurrentInboxRow = str(self.ui.tableWidgetInbox.item(currentInboxRow,2).text()) + defaultFilename = "".join(x for x in subjectAtCurrentInboxRow if x.isalnum()) + '.txt' + data = self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject() + filename = QFileDialog.getSaveFileName(self, "Save As...", defaultFilename, "Text files (*.txt);;All files (*.*)") + if filename == '': + return + try: + f = open(filename, 'w') + f.write( self.ui.tableWidgetInbox.item(currentInboxRow,2).data(Qt.UserRole).toPyObject() ) + f.close() + except Exception, e: + print 'Write error' + print e + self.statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Write error.")) + + #Send item on the Sent tab to trash def on_action_SentTrash(self): while self.ui.tableWidgetSent.selectedIndexes() != []: