In html mode, just select an image and you can save it

This commit is contained in:
N0U 2014-04-06 20:33:37 -07:00
parent 9917bf2030
commit fe73f673e3

View File

@ -268,6 +268,11 @@ class MyForm(QtGui.QMainWindow):
self.popMenuInbox.addSeparator() self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction(self.actionSaveMessageAs) self.popMenuInbox.addAction(self.actionSaveMessageAs)
self.popMenuInbox.addAction(self.actionTrashInboxMessage) self.popMenuInbox.addAction(self.actionTrashInboxMessage)
# Text browser actions
self.ui.textEditInboxMessage.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.connect(self.ui.textEditInboxMessage, QtCore.SIGNAL(
'customContextMenuRequested(const QPoint&)'),
self.on_context_inboxMessage)
def init_identities_popup_menu(self): def init_identities_popup_menu(self):
# Popup menu for the Your Identities tab # Popup menu for the Your Identities tab
@ -2790,6 +2795,23 @@ class MyForm(QtGui.QMainWindow):
else: else:
self.ui.tableWidgetSent.selectRow(currentRow - 1) self.ui.tableWidgetSent.selectRow(currentRow - 1)
def on_action_InboxMessageSaveAs(self):
cursor=self.ui.textEditInboxMessage.textCursor()
text_block=cursor.block()
i=text_block.begin()
while not i.atEnd():
frag=i.fragment()
if frag.charFormat().isImageFormat():
img_frag=frag.charFormat().toImageFormat()
image_data=self.ui.textEditInboxMessage.document().resource(
QtGui.QTextDocument.ImageResource,QtCore.QUrl(img_frag.name()))
file_name=QtGui.QFileDialog.getSaveFileName(self,"Save image",self.images_dir,"Image ( *.png *.jpg *.jepg *.gif)")
if not file_name.isNull():
img=QImage(image_data)
img.save(file_name)
return
i+=1
def on_action_ForceSend(self): def on_action_ForceSend(self):
currentRow = self.ui.tableWidgetSent.currentRow() currentRow = self.ui.tableWidgetSent.currentRow()
addressAtCurrentRow = str(self.ui.tableWidgetSent.item( addressAtCurrentRow = str(self.ui.tableWidgetSent.item(
@ -3138,7 +3160,13 @@ class MyForm(QtGui.QMainWindow):
def on_context_menuInbox(self, point): def on_context_menuInbox(self, point):
self.popMenuInbox.exec_(self.ui.tableWidgetInbox.mapToGlobal(point)) self.popMenuInbox.exec_(self.ui.tableWidgetInbox.mapToGlobal(point))
def on_context_inboxMessage(self, point):
popMenuInboxMessage = self.ui.textEditInboxMessage.createStandardContextMenu()
popMenuInboxMessage.addAction(_translate("MainWindow", "Save as"),
self.on_action_InboxMessageSaveAs)
popMenuInboxMessage.exec_(self.ui.textEditInboxMessage.mapToGlobal(point))
def on_context_menuSent(self, point): def on_context_menuSent(self, point):
self.popMenuSent = QtGui.QMenu(self) self.popMenuSent = QtGui.QMenu(self)
self.popMenuSent.addAction(self.actionSentClipboard) self.popMenuSent.addAction(self.actionSentClipboard)