From 234aa4dfec16e002a0418ebd6bea70a8494076eb Mon Sep 17 00:00:00 2001 From: delicatebits Date: Mon, 1 Apr 2013 19:29:30 -0400 Subject: [PATCH] Add context menu action to view message as richtext --- bitmessagemain.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bitmessagemain.py b/bitmessagemain.py index 2b30ea56..60dd894f 100755 --- a/bitmessagemain.py +++ b/bitmessagemain.py @@ -3426,9 +3426,12 @@ class MyForm(QtGui.QMainWindow): self.actionReply = self.ui.inboxContextMenuToolbar.addAction("Reply", self.on_action_InboxReply) self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction("Add sender to your Address Book", self.on_action_InboxAddSenderToAddressBook) self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction("Move to Trash", self.on_action_InboxTrash) + self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction("View as Richtext", self.on_action_InboxMsgForceHtml) 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 ) + self.popMenuInbox.addAction( self.actionForceHtml ) + self.popMenuInbox.addSeparator() self.popMenuInbox.addAction( self.actionReply ) self.popMenuInbox.addAction( self.actionAddSenderToAddressBook ) self.popMenuInbox.addSeparator() @@ -4637,6 +4640,16 @@ class MyForm(QtGui.QMainWindow): event.accept() raise SystemExit + def on_action_InboxMsgForceHtml(self): + lines = str(self.ui.textEditInboxMessage.toPlainText()).split('\n') + from_prefix = 'Message ostensibly from ' + for i in xrange(len(lines)): + if lines[i].find(from_prefix) != -1: + lines[i] = '

%s%s

' % (from_prefix,lines[i][24:-1]) + elif lines[i] == '------------------------------------------------------': + lines[i] = '
' + content = '\n'.join(lines) + self.ui.textEditInboxMessage.setHtml(QtCore.QString(content)) def on_action_InboxReply(self): currentInboxRow = self.ui.tableWidgetInbox.currentRow()