Copy to clipboard in messagelists

Fixes #142
This commit is contained in:
mailchuck 2015-12-14 12:21:00 +01:00
parent 82067802ac
commit a379c435f5
Signed by untrusted user who does not match committer: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -3703,6 +3703,31 @@ class MyForm(settingsmixin.SMainWindow):
address = self.getCurrentAccount()
clipboard = QtGui.QApplication.clipboard()
clipboard.setText(str(address))
def on_action_ClipboardMessagelist(self):
tableWidget = self.getCurrentMessagelist()
currentColumn = tableWidget.currentColumn()
currentRow = tableWidget.currentRow()
if currentColumn not in [0, 1, 2]: # to, from, subject
if self.getCurrentFolder() == "sent":
currentColumn = 0
else:
currentColumn = 1
if self.getCurrentFolder() == "sent":
myAddress = str(tableWidget.item(currentRow, 1).data(Qt.UserRole).toPyObject())
otherAddress = str(tableWidget.item(currentRow, 0).data(Qt.UserRole).toPyObject())
else:
myAddress = str(tableWidget.item(currentRow, 0).data(Qt.UserRole).toPyObject())
otherAddress = str(tableWidget.item(currentRow, 1).data(Qt.UserRole).toPyObject())
account = accountClass(myAddress)
if isinstance(account, GatewayAccount) and otherAddress == account.relayAddress and (
(currentColumn in [0, 2] and self.getCurrentFolder() == "sent") or
(currentColumn in [1, 2] and self.getCurrentFolder() != "sent")):
text = str(tableWidget.item(currentRow, currentColumn).text())
else:
text = str(tableWidget.item(currentRow, currentColumn).data(Qt.UserRole).toPyObject())
clipboard = QtGui.QApplication.clipboard()
clipboard.setText(str(text))
#set avatar functions
def on_action_TreeWidgetSetAvatar(self):
@ -3840,6 +3865,12 @@ class MyForm(settingsmixin.SMainWindow):
self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction(self.actionReply)
self.popMenuInbox.addAction(self.actionAddSenderToAddressBook)
self.actionClipboardMessagelist = self.ui.inboxContextMenuToolbar.addAction(
_translate("MainWindow",
"Copy subject to clipboard" if tableWidget.currentColumn() == 2 else "Copy address to clipboard"
),
self.on_action_ClipboardMessagelist)
self.popMenuInbox.addAction(self.actionClipboardMessagelist)
self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction(self.actionAddSenderToBlackList)
self.popMenuInbox.addSeparator()