Ability to input multiple labels or addresses separated by ; or ,

Automatically querry namecoin if address field input starts with "id/"
This commit is contained in:
sendiulo 2013-09-14 19:02:48 +02:00
parent eb22914d10
commit bb9e3c551c
4 changed files with 222 additions and 272 deletions

View File

@ -390,12 +390,12 @@ class MyForm(QtGui.QMainWindow):
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem) self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
# Initialize the Recipients
self.loadPossibleRecipients()
# Initialize the Subscriptions # Initialize the Subscriptions
self.rerenderSubscriptions() self.rerenderSubscriptions()
# Initialize the Recipients
self.renderPossibleRecipients()
# Initialize the inbox search # Initialize the inbox search
QtCore.QObject.connect(self.ui.inboxSearchLineEdit, QtCore.SIGNAL( QtCore.QObject.connect(self.ui.inboxSearchLineEdit, QtCore.SIGNAL(
"returnPressed()"), self.inboxSearchLineEditPressed) "returnPressed()"), self.inboxSearchLineEditPressed)
@ -829,41 +829,38 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetInbox.sortItems(3, Qt.DescendingOrder) self.ui.tableWidgetInbox.sortItems(3, Qt.DescendingOrder)
self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetInboxKeyPressEvent self.ui.tableWidgetInbox.keyPressEvent = self.tableWidgetInboxKeyPressEvent
def loadPossibleRecipients(self): def renderPossibleRecipients(self):
### # reset the comboboxes
# create a dictionary of addresses self.ui.comboboxFindLabel.clear()
# overwrite labels self.ui.comboboxFindAddress.clear()
listAddresses = {} self.ui.comboboxFindLabel.addItem('', 'BM-')
# fetch addresses from Subscriptions self.ui.comboboxFindAddress.addItem('BM-', '')
for currentRow in range(self.ui.tableWidgetSubscriptions.rowCount()): for (tableWidget,widgetName) in [(self.ui.tableWidgetYourIdentities, _translate("MainWindow", "Your Identities")), (self.ui.tableWidgetAddressBook,_translate("MainWindow", "Address Book")), (self.ui.tableWidgetSubscriptions,_translate("MainWindow", "Subscriptions"))]:
label = str(self.ui.tableWidgetSubscriptions.item(currentRow,0).text()) # separator + label + separator
address = str(self.ui.tableWidgetSubscriptions.item(currentRow,1).text()) self.ui.comboboxFindLabel.insertSeparator(self.ui.comboboxFindLabel.count())
listAddresses[address] = label self.ui.comboboxFindLabel.addItem(widgetName)
# fetch addresses from AddressBook self.ui.comboboxFindLabel.insertSeparator(self.ui.comboboxFindLabel.count())
for currentRow in range(self.ui.tableWidgetAddressBook.rowCount()): # separator + address + separator
label = str(self.ui.tableWidgetAddressBook.item(currentRow,0).text()) self.ui.comboboxFindAddress.insertSeparator(self.ui.comboboxFindAddress.count())
address = str(self.ui.tableWidgetAddressBook.item(currentRow,1).text()) self.ui.comboboxFindAddress.addItem(widgetName)
# overwrite Subscriptions self.ui.comboboxFindAddress.insertSeparator(self.ui.comboboxFindAddress.count())
listAddresses[address] = label # fetch addresses from the respective tableWidget
# fetch addresses from YourIdentities for currentRow in range(tableWidget.rowCount()):
for currentRow in range(self.ui.tableWidgetYourIdentities.rowCount()): label = str(tableWidget.item(currentRow,0).text())
label = str(self.ui.tableWidgetYourIdentities.item(currentRow,0).text()) address = str(tableWidget.item(currentRow,1).text())
address = str(self.ui.tableWidgetYourIdentities.item(currentRow,1).text()) if address in shared.config.sections():
# overwrite Subscriptions and AddressBook # this is one of your addresses
listAddresses[address] = label if shared.safeConfigGetBoolean(address, 'enabled'):
listAddresses_by_label = [(label, address) for address, label in listAddresses.iteritems()]
listAddresses_by_address = [(address, label) for address, label in listAddresses.iteritems()]
listAddresses_by_label.sort()
listAddresses_by_address.sort()
# put the labels and addresses into the comboboxes
for element in listAddresses_by_label:
label, address = element
self.ui.comboboxFindLabel.addItem(label, address) self.ui.comboboxFindLabel.addItem(label, address)
for element in listAddresses_by_address:
address, label = element
self.ui.comboboxFindAddress.addItem(address,label) self.ui.comboboxFindAddress.addItem(address,label)
else:
pass
#print label, address, 'is disabled'
else:
# print label, address, 'is a foreign address'
self.ui.comboboxFindLabel.addItem(label, address)
self.ui.comboboxFindAddress.addItem(address,label)
self.ui.tableWidgetRecipients.keyPressEvent = self.tableWidgetRecipientsKeyPressEvent
# create application indicator # create application indicator
def appIndicatorInit(self, app): def appIndicatorInit(self, app):
@ -1188,6 +1185,11 @@ class MyForm(QtGui.QMainWindow):
self.on_action_SentTrash() self.on_action_SentTrash()
return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetSent, event) return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetSent, event)
def tableWidgetRecipientsKeyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Delete:
self.on_action_RecipientsDelte()
return QtGui.QTableWidget.keyPressEvent(self.ui.tableWidgetInbox, event)
def click_actionManageKeys(self): def click_actionManageKeys(self):
if 'darwin' in sys.platform or 'linux' in sys.platform: if 'darwin' in sys.platform or 'linux' in sys.platform:
if shared.appdata == '': if shared.appdata == '':
@ -1605,14 +1607,11 @@ class MyForm(QtGui.QMainWindow):
def click_pushButtonSend(self): def click_pushButtonSend(self):
self.statusBar().showMessage('') self.statusBar().showMessage('')
toAddresses = str(self.ui.lineEditTo.text())
fromAddress = str(self.ui.labelFrom.text()) fromAddress = str(self.ui.labelFrom.text())
subject = str(self.ui.lineEditSubject.text().toUtf8()) subject = str(self.ui.lineEditSubject.text().toUtf8())
message = str( message = str(
self.ui.textEditMessage.document().toPlainText().toUtf8()) self.ui.textEditMessage.document().toPlainText().toUtf8())
if self.ui.radioButtonSpecific.isChecked(): # To send a message to specific people (rather than broadcast) if self.ui.radioButtonSpecific.isChecked(): # To send a message to specific people (rather than broadcast)
use_tableWidgetRecipients = True # this is just to keep the old To-Field until finally tested
if use_tableWidgetRecipients:
toAddressesList = self.get_recipient_addresses() toAddressesList = self.get_recipient_addresses()
toAddressesList = list(set( toAddressesList = list(set(
toAddressesList)) # remove duplicate addresses. If the user has one address with a BM- and the same address without the BM-, this will not catch it. They'll send the message to the person twice. However, the tableWidgetRecipients should have already caught them. toAddressesList)) # remove duplicate addresses. If the user has one address with a BM- and the same address without the BM-, this will not catch it. They'll send the message to the person twice. However, the tableWidgetRecipients should have already caught them.
@ -1677,81 +1676,8 @@ class MyForm(QtGui.QMainWindow):
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.comboBoxSendFrom.setCurrentIndex(0)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
self.ui.lineEditTo.setText('') while self.ui.tableWidgetRecipients.rowCount() > 1:
self.ui.lineEditSubject.setText('') self.ui.tableWidgetRecipients.removeRow(int(not self.addToBottom))
self.ui.textEditMessage.setText('')
self.ui.tabWidget.setCurrentIndex(2)
self.ui.tableWidgetSent.setCurrentCell(0, 0)
else:
self.statusBar().showMessage(_translate(
"MainWindow", "Your \'To\' field is empty."))
else:
toAddressesList = [s.strip()
for s in toAddresses.replace(',', ';').split(';')]
toAddressesList = list(set(
toAddressesList)) # remove duplicate addresses. If the user has one address with a BM- and the same address without the BM-, this will not catch it. They'll send the message to the person twice.
for toAddress in toAddressesList:
if toAddress != '':
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress)
if status != 'success':
self.throw_address_error(toAddress, status, addressVersionNumber, streamNumber, ripe)
elif fromAddress == '':
self.statusBar().showMessage(_translate(
"MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab."))
else:
toAddress = addBMIfNotPresent(toAddress)
try:
shared.config.get(toAddress, 'enabled')
# The toAddress is one owned by me.
if not shared.safeConfigGetBoolean(toAddress, 'chan'):
QMessageBox.about(self, _translate("MainWindow", "Sending to your address"), _translate(
"MainWindow", "Error: One of the addresses to which you are sending a message, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM.").arg(toAddress))
continue
except:
pass
if addressVersionNumber > 3 or addressVersionNumber <= 1:
QMessageBox.about(self, _translate("MainWindow", "Address version number"), _translate(
"MainWindow", "Concerning the address %1, Bitmessage cannot understand address version numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(addressVersionNumber)))
continue
if streamNumber > 1 or streamNumber == 0:
QMessageBox.about(self, _translate("MainWindow", "Stream number"), _translate(
"MainWindow", "Concerning the address %1, Bitmessage cannot handle stream numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(streamNumber)))
continue
self.statusBar().showMessage('')
if shared.statusIconColor == 'red':
self.statusBar().showMessage(_translate(
"MainWindow", "Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect."))
ackdata = OpenSSL.rand(32)
shared.sqlLock.acquire()
t = ('', toAddress, ripe, fromAddress, subject, message, ackdata, int(
time.time()), 'msgqueued', 1, 1, 'sent', 2)
shared.sqlSubmitQueue.put(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)''')
shared.sqlSubmitQueue.put(t)
shared.sqlReturnQueue.get()
shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release()
toLabel = ''
t = (toAddress,)
shared.sqlLock.acquire()
shared.sqlSubmitQueue.put(
'''select label from addressbook where address=?''')
shared.sqlSubmitQueue.put(t)
queryreturn = shared.sqlReturnQueue.get()
shared.sqlLock.release()
if queryreturn != []:
for row in queryreturn:
toLabel, = row
self.displayNewSentMessage(
toAddress, toLabel, fromAddress, subject, message, ackdata)
shared.workerQueue.put(('sendmessage', toAddress))
self.ui.comboBoxSendFrom.setCurrentIndex(0)
self.ui.labelFrom.setText('')
self.ui.lineEditTo.setText('')
self.ui.lineEditSubject.setText('') self.ui.lineEditSubject.setText('')
self.ui.textEditMessage.setText('') self.ui.textEditMessage.setText('')
self.ui.tabWidget.setCurrentIndex(2) self.ui.tabWidget.setCurrentIndex(2)
@ -1822,7 +1748,8 @@ class MyForm(QtGui.QMainWindow):
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.comboBoxSendFrom.setCurrentIndex(0)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
self.ui.lineEditTo.setText('') while self.ui.tableWidgetRecipients.rowCount() > 1:
self.ui.tableWidgetRecipients.removeRow(int(not self.addToBottom))
self.ui.lineEditSubject.setText('') self.ui.lineEditSubject.setText('')
self.ui.textEditMessage.setText('') self.ui.textEditMessage.setText('')
self.ui.tabWidget.setCurrentIndex(2) self.ui.tabWidget.setCurrentIndex(2)
@ -1838,13 +1765,23 @@ class MyForm(QtGui.QMainWindow):
"MainWindow", "Right click one or more entries in your address book and select \'Send message to this address\'.")) "MainWindow", "Right click one or more entries in your address book and select \'Send message to this address\'."))
def click_pushButtonFetchNamecoinID(self): def click_pushButtonFetchNamecoinID(self):
currentText = str(self.ui.comboboxFindAddress.currentText())
addressList = currentText.replace(',',';').split(';')
address = str(addressList[0])
otherAddresses = str(';'.join(addressList[1:]))
if address[:3] == 'id/':
address = address[3:]
self.statusBar().showMessage(_translate(
"MainWindow", "Namecoin querry..."))
nc = namecoinConnection() nc = namecoinConnection()
err, addr = nc.query(str(self.ui.lineEditTo.text())) err, addr = nc.query(address)
if err is not None: if err is not None:
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: " + err)) "MainWindow", "Error: " + err))
else: else:
self.ui.lineEditTo.setText(addr) self.on_addRecipient_submit(addr, address)
self.ui.comboboxFindAddress.setEditText(otherAddresses)
# self.ui.comboboxFindAddress.setEditText(addr)
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "Fetched address from namecoin identity.")) "MainWindow", "Fetched address from namecoin identity."))
@ -2054,6 +1991,7 @@ class MyForm(QtGui.QMainWindow):
shared.sqlLock.release() shared.sqlLock.release()
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
self.rerenderSentToLabels() self.rerenderSentToLabels()
self.renderPossibleRecipients()
else: else:
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.")) "MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want."))
@ -2081,6 +2019,7 @@ class MyForm(QtGui.QMainWindow):
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
self.renderPossibleRecipients()
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
def click_pushButtonAddSubscription(self): def click_pushButtonAddSubscription(self):
@ -2499,21 +2438,25 @@ class MyForm(QtGui.QMainWindow):
currentInboxRow, 1).data(Qt.UserRole).toPyObject()) currentInboxRow, 1).data(Qt.UserRole).toPyObject())
if toAddressAtCurrentInboxRow == self.str_broadcast_subscribers: if toAddressAtCurrentInboxRow == self.str_broadcast_subscribers:
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
self.ui.comboBoxSendFrom.setCurrentIndex(0)
elif not shared.config.has_section(toAddressAtCurrentInboxRow): elif not shared.config.has_section(toAddressAtCurrentInboxRow):
QtGui.QMessageBox.information(self, _translate("MainWindow", "Address is gone"), _translate( QtGui.QMessageBox.information(self, _translate("MainWindow", "Address is gone"), _translate(
"MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(toAddressAtCurrentInboxRow), QMessageBox.Ok) "MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(toAddressAtCurrentInboxRow), QMessageBox.Ok)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
self.ui.comboBoxSendFrom.setCurrentIndex(0)
elif not shared.config.getboolean(toAddressAtCurrentInboxRow, 'enabled'): elif not shared.config.getboolean(toAddressAtCurrentInboxRow, 'enabled'):
QtGui.QMessageBox.information(self, _translate("MainWindow", "Address disabled"), _translate( QtGui.QMessageBox.information(self, _translate("MainWindow", "Address disabled"), _translate(
"MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok) "MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
self.ui.comboBoxSendFrom.setCurrentIndex(0)
else: else:
self.ui.labelFrom.setText(toAddressAtCurrentInboxRow) self.ui.labelFrom.setText(toAddressAtCurrentInboxRow)
self.ui.comboBoxSendFrom.setEditText(fromLabelAtCurrentInboxRow)
self.setBroadcastEnablementDependingOnWhetherThisIsAChanAddress(toAddressAtCurrentInboxRow) self.setBroadcastEnablementDependingOnWhetherThisIsAChanAddress(toAddressAtCurrentInboxRow)
self.ui.lineEditTo.setText(str(fromAddressAtCurrentInboxRow)) # remove all recipients
self.on_addRecipient_submit(fromLabelAtCurrentInboxRow, fromAddressAtCurrentInboxRow) while self.ui.tableWidgetRecipients.rowCount() > 1:
self.ui.comboBoxSendFrom.setCurrentIndex(0) self.ui.tableWidgetRecipients.removeRow(int(not self.addToBottom))
# self.ui.comboBoxSendFrom.setEditText(str(self.ui.tableWidgetInbox.item(currentInboxRow,0).text)) self.on_addRecipient_submit(fromAddressAtCurrentInboxRow)
self.ui.textEditMessage.setText('\n\n------------------------------------------------------\n' + self.ui.tableWidgetInbox.item( self.ui.textEditMessage.setText('\n\n------------------------------------------------------\n' + self.ui.tableWidgetInbox.item(
currentInboxRow, 2).data(Qt.UserRole).toPyObject()) currentInboxRow, 2).data(Qt.UserRole).toPyObject())
if self.ui.tableWidgetInbox.item(currentInboxRow, 2).text()[0:3] in ['Re:', 'RE:']: if self.ui.tableWidgetInbox.item(currentInboxRow, 2).text()[0:3] in ['Re:', 'RE:']:
@ -2633,6 +2576,16 @@ class MyForm(QtGui.QMainWindow):
else: else:
self.ui.tableWidgetSent.selectRow(currentRow - 1) self.ui.tableWidgetSent.selectRow(currentRow - 1)
# Remove Recipient row from the list
def on_action_RecipientsDelte(self):
while self.ui.tableWidgetRecipients.selectedIndexes() != []:
currentRow = self.ui.tableWidgetRecipients.selectedIndexes()[0].row()
self.ui.tableWidgetRecipients.removeRow(currentRow)
if currentRow == 0:
self.ui.tableWidgetSent.selectRow(currentRow)
else:
self.ui.tableWidgetSent.selectRow(currentRow - 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(
@ -2688,24 +2641,31 @@ class MyForm(QtGui.QMainWindow):
def on_comboboxFindLabel_enter(self, event): def on_comboboxFindLabel_enter(self, event):
if (event.key() == QtCore.Qt.Key_Enter) | (event.key() == QtCore.Qt.Key_Return): if (event.key() == QtCore.Qt.Key_Enter) | (event.key() == QtCore.Qt.Key_Return):
index = self.ui.comboboxFindLabel.currentIndex() index = self.ui.comboboxFindLabel.currentIndex()
print index
currentText = str(self.ui.comboboxFindLabel.currentText()) currentText = str(self.ui.comboboxFindLabel.currentText())
found = self.ui.comboboxFindLabel.findText(currentText, Qt.MatchCaseSensitive) labelList = currentText.replace(',',';').split(';')
label = str(labelList[0])
otherLabels = str(';'.join(labelList[1:]))
found = self.ui.comboboxFindLabel.findText(label, Qt.MatchCaseSensitive)
if (currentText=='') & (str(self.ui.comboboxFindLabel.itemText(index))==''): if (currentText=='') & (str(self.ui.comboboxFindLabel.itemText(index))==''):
# workaround for empty labels print 'workaround for empty labels'
address = str(self.ui.comboboxFindLabel.itemData(index).toString()) address = str(self.ui.comboboxFindLabel.itemData(index).toString())
# print 'empty label', address # print 'empty label', address
self.on_addRecipient_submit(address) self.on_addRecipient_submit(address)
elif (found > 0) & (index == found): elif (found > 0) & (index == found):
address = self.ui.comboboxFindLabel.itemData(found).toString() print 'label found'
address = str(self.ui.comboboxFindLabel.itemData(found).toString())
self.on_addRecipient_submit(address) self.on_addRecipient_submit(address)
elif found > 0:
print 'label found for the first item'
address = str(self.ui.comboboxFindLabel.itemData(found).toString())
self.on_addRecipient_submit(address)
self.ui.comboboxFindLabel.setEditText(otherLabels)
else: else:
status, a, b, c = decodeAddress(str(currentText)) status, a, b, c = decodeAddress(str(currentText))
# check if the text is a BM-Address # check if the text is a BM-Address
if status == 'success': if status == 'success':
# try to find it in the list # try to find it in the list
found = self.ui.comboboxFindLabel.findData(currentText, Qt.UserRole, Qt.MatchCaseSensitive) found = self.ui.comboboxFindLabel.findData(label, Qt.UserRole, Qt.MatchCaseSensitive)
if found > 0: if found > 0:
# found the element in the list # found the element in the list
self.ui.comboboxFindLabel.setCurrentIndex(found if found > 0 else 0) self.ui.comboboxFindLabel.setCurrentIndex(found if found > 0 else 0)
@ -2714,32 +2674,38 @@ class MyForm(QtGui.QMainWindow):
self.ui.comboboxFindLabel.setCurrentIndex(0) self.ui.comboboxFindLabel.setCurrentIndex(0)
# copy the BM-address to the address field # copy the BM-address to the address field
self.ui.comboboxFindAddress.setEditText(currentText) self.ui.comboboxFindAddress.setEditText(currentText)
self.statusBar().showMessage(_translate(
"MainWindow", "You typed the address in the wrong field. It was copied to the correct field."))
return QtGui.QComboBox.keyPressEvent(self.ui.comboboxFindLabel, event) return QtGui.QComboBox.keyPressEvent(self.ui.comboboxFindLabel, event)
def on_comboboxFindAddress_enter(self, event): def on_comboboxFindAddress_enter(self, event):
if (event.key() == QtCore.Qt.Key_Enter) | (event.key() == QtCore.Qt.Key_Return): if (event.key() == QtCore.Qt.Key_Enter) | (event.key() == QtCore.Qt.Key_Return):
index = self.ui.comboboxFindAddress.currentIndex() index = self.ui.comboboxFindAddress.currentIndex()
address = str(addBMIfNotPresent(self.ui.comboboxFindAddress.currentText())) currentText = str(self.ui.comboboxFindAddress.currentText())
found = self.ui.comboboxFindAddress.findText(address, Qt.MatchCaseSensitive) addressList = currentText.replace(',',';').split(';')
address = str(addressList[0])
otherAddresses = str(';'.join(addressList[1:]))
found = self.ui.comboboxFindAddress.findText(addBMIfNotPresent(address), Qt.MatchCaseSensitive)
if (found > 0) & (index == found): if (found > 0) & (index == found):
address = str(self.ui.comboboxFindAddress.itemText(found)) address = str(self.ui.comboboxFindAddress.itemText(found))
self.on_addRecipient_submit(address) self.on_addRecipient_submit(address)
else: elif found > 0:
# print 'no matching contact' address = str(self.ui.comboboxFindAddress.itemText(found))
self.ui.comboboxFindLabel.setCurrentIndex(0)
self.ui.comboboxFindAddress.setEditText(address) # otherwise you will lose the text on enter
# but maybe the address is valid?
# random address for testing: BM-2DAArASbJckBdn3HvTt7kHAbPA5tGxc2R1
self.on_addRecipient_submit(address) self.on_addRecipient_submit(address)
self.ui.comboboxFindAddress.setEditText(otherAddresses)
elif address[:3] == 'id/':
self.click_pushButtonFetchNamecoinID()
else:
print 'no matching contact'
self.ui.comboboxFindLabel.setCurrentIndex(0)
# but maybe the address is valid?
self.ui.comboboxFindAddress.setEditText(currentText) # otherwise you will lose the text on enter
# random address for testing: BM-2DAArASbJckBdn3HvTt7kHAbPA5tGxc2R1
self.on_addRecipient_submit(addBMIfNotPresent(address))
return QtGui.QComboBox.keyPressEvent(self.ui.comboboxFindAddress, event) return QtGui.QComboBox.keyPressEvent(self.ui.comboboxFindAddress, event)
def get_recipient_addresses(self): def get_recipient_addresses(self):
recipients = [] recipients = []
for row in range(1,self.ui.tableWidgetRecipients.rowCount()): for row in range(1-int(self.addToBottom),self.ui.tableWidgetRecipients.rowCount()-int(self.addToBottom)):
recipients += [str(self.ui.tableWidgetRecipients.item( recipients += [str(self.ui.tableWidgetRecipients.item(row, 1).text())]
row, 1).text())]
return recipients return recipients
def throw_address_error(self, address, status, addressVersionNumber, streamNumber, ripe): def throw_address_error(self, address, status, addressVersionNumber, streamNumber, ripe):
@ -2767,26 +2733,41 @@ class MyForm(QtGui.QMainWindow):
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: Something is wrong with the address %1.").arg(address)) "MainWindow", "Error: Something is wrong with the address %1.").arg(address))
def on_addRecipient_submit(self, address): addToBottom = False # determines whether the recipient addresses get added on top or on the bottom of the list. Default should imho be on top.
def on_addRecipient_submit(self, address, overwriteLabel = False):
# check whether address already in TO list # check whether address already in TO list
address = addBMIfNotPresent(address) address = addBMIfNotPresent(address)
recipients = self.get_recipient_addresses() recipients = self.get_recipient_addresses()
if address in recipients: if address in recipients:
for i in range(4):
time.sleep(0.1)
self.statusBar().showMessage('')
time.sleep(0.1)
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "Address already in Recipients.")) "MainWindow", "Address already in Recipients."))
else: else:
status, addressVersionNumber, streamNumber, ripe = decodeAddress(str(address)) status, addressVersionNumber, streamNumber, ripe = decodeAddress(str(address))
if status == 'success': if status == 'success':
print 'success' if (address in shared.config.sections()) & (not shared.safeConfigGetBoolean(address, 'chan')):
for i in range(4):
time.sleep(0.1)
self.statusBar().showMessage('')
time.sleep(0.1)
self.statusBar().showMessage(
_translate(
"MainWindow", "Error: The address you are trying to add, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. ").arg(address))
return
found_address_index = self.ui.comboboxFindAddress.findText(address, Qt.MatchCaseSensitive) found_address_index = self.ui.comboboxFindAddress.findText(address, Qt.MatchCaseSensitive)
# get the label string # get the label string
label = str(self.ui.comboboxFindAddress.itemData(found_address_index).toString()) if overwriteLabel:
print found_address_index, label label = str(overwriteLabel)
if found_address_index == -1: elif found_address_index == -1:
label = _translate("MainWindow", "--unknown Address--") label = _translate("MainWindow", "--unknown Address--")
else:
label = str(self.ui.comboboxFindAddress.itemData(found_address_index).toString())
# add the label and address as a row # add the label and address as a row
addToBottom = False rowIndex = self.ui.tableWidgetRecipients.rowCount()-1 if self.addToBottom else 1
rowIndex = self.ui.tableWidgetRecipients.rowCount()-1 if addToBottom else 1
self.ui.tableWidgetRecipients.insertRow(rowIndex) self.ui.tableWidgetRecipients.insertRow(rowIndex)
newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
newItem.setFlags( newItem.setFlags(
@ -2795,10 +2776,11 @@ class MyForm(QtGui.QMainWindow):
newItem = QtGui.QTableWidgetItem(unicode(address, 'utf-8')) newItem = QtGui.QTableWidgetItem(unicode(address, 'utf-8'))
newItem.setFlags( newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetRecipients.setItem(rowIndex, 1, newItem)# remove them so we won't add them again self.ui.tableWidgetRecipients.setItem(rowIndex, 1, newItem)
if shared.safeConfigGetBoolean(address, 'chan'):
newItem.setTextColor(QtGui.QColor(216, 119, 0)) # orange
found_label_index = self.ui.comboboxFindLabel.findData(address, Qt.UserRole, Qt.MatchCaseSensitive) found_label_index = self.ui.comboboxFindLabel.findData(address, Qt.UserRole, Qt.MatchCaseSensitive)
self.ui.comboboxFindLabel.removeItem(found_label_index) # we could remove them (so we don't add them again), but i prefer to keep them so the user knows then name of the address if he or she pastes the same BM-address again
self.ui.comboboxFindAddress.removeItem(found_address_index)
# jump to the first item # jump to the first item
self.ui.comboboxFindLabel.setCurrentIndex(0) self.ui.comboboxFindLabel.setCurrentIndex(0)
self.ui.comboboxFindAddress.setCurrentIndex(0) self.ui.comboboxFindAddress.setCurrentIndex(0)
@ -2836,7 +2818,7 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetAddressBook.removeRow(currentRow) self.ui.tableWidgetAddressBook.removeRow(currentRow)
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
self.rerenderSentToLabels() self.rerenderSentToLabels()
self.loadPossibleRecipients() self.renderPossibleRecipients()
def on_action_AddressBookClipboard(self): def on_action_AddressBookClipboard(self):
fullStringOfAddresses = '' fullStringOfAddresses = ''
@ -2864,14 +2846,7 @@ class MyForm(QtGui.QMainWindow):
currentRow, 0).text() currentRow, 0).text()
addressAtCurrentRow = self.ui.tableWidgetAddressBook.item( addressAtCurrentRow = self.ui.tableWidgetAddressBook.item(
currentRow, 1).text() currentRow, 1).text()
if self.ui.lineEditTo.text() == '': self.on_addRecipient_submit(addressAtCurrentRow)
self.ui.lineEditTo.setText(str(addressAtCurrentRow))
else:
self.ui.lineEditTo.setText(str(
self.ui.lineEditTo.text()) + '; ' + str(addressAtCurrentRow))
# add the addresses to the To-Tableview ###
self.on_addRecipient_submit(labelAtCurrentRow, addressAtCurrentRow)
if listOfSelectedRows == {}: if listOfSelectedRows == {}:
self.statusBar().showMessage(_translate( self.statusBar().showMessage(_translate(
"MainWindow", "No addresses selected.")) "MainWindow", "No addresses selected."))
@ -2918,7 +2893,7 @@ class MyForm(QtGui.QMainWindow):
shared.sqlLock.release() shared.sqlLock.release()
self.ui.tableWidgetSubscriptions.removeRow(currentRow) self.ui.tableWidgetSubscriptions.removeRow(currentRow)
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
self.loadPossibleRecipients() self.renderPossibleRecipients()
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
def on_action_SubscriptionsClipboard(self): def on_action_SubscriptionsClipboard(self):
@ -3582,8 +3557,6 @@ class NewAddressDialog(QtGui.QDialog):
# the 'Your Identities' tab. # the 'Your Identities' tab.
while self.parent.ui.tableWidgetYourIdentities.item(row - 1, 1): while self.parent.ui.tableWidgetYourIdentities.item(row - 1, 1):
self.ui.radioButtonExisting.click() self.ui.radioButtonExisting.click()
# print
# self.parent.ui.tableWidgetYourIdentities.item(row-1,1).text()
self.ui.comboBoxExisting.addItem( self.ui.comboBoxExisting.addItem(
self.parent.ui.tableWidgetYourIdentities.item(row - 1, 1).text()) self.parent.ui.tableWidgetYourIdentities.item(row - 1, 1).text())
row += 1 row += 1

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'bitmessageui.ui' # Form implementation generated from reading ui file 'bitmessageui.ui'
# #
# Created: Tue Sep 10 09:45:02 2013 # Created: Wed Sep 11 21:08:23 2013
# by: PyQt4 UI code generator 4.10.2 # by: PyQt4 UI code generator 4.10.2
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -122,18 +122,12 @@ class Ui_MainWindow(object):
self.gridLayout_2.addWidget(self.label_4, 15, 0, 1, 1) self.gridLayout_2.addWidget(self.label_4, 15, 0, 1, 1)
spacerItem = QtGui.QSpacerItem(20, 297, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) spacerItem = QtGui.QSpacerItem(20, 297, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_2.addItem(spacerItem, 16, 0, 1, 1) self.gridLayout_2.addItem(spacerItem, 16, 0, 1, 1)
self.label = QtGui.QLabel(self.send)
self.label.setObjectName(_fromUtf8("label"))
self.gridLayout_2.addWidget(self.label, 5, 0, 1, 1)
self.label_2 = QtGui.QLabel(self.send) self.label_2 = QtGui.QLabel(self.send)
self.label_2.setObjectName(_fromUtf8("label_2")) self.label_2.setObjectName(_fromUtf8("label_2"))
self.gridLayout_2.addWidget(self.label_2, 2, 0, 1, 1) self.gridLayout_2.addWidget(self.label_2, 2, 0, 1, 1)
self.label_3 = QtGui.QLabel(self.send) self.label_3 = QtGui.QLabel(self.send)
self.label_3.setObjectName(_fromUtf8("label_3")) self.label_3.setObjectName(_fromUtf8("label_3"))
self.gridLayout_2.addWidget(self.label_3, 14, 0, 1, 1) self.gridLayout_2.addWidget(self.label_3, 14, 0, 1, 1)
self.lineEditTo = QtGui.QLineEdit(self.send)
self.lineEditTo.setObjectName(_fromUtf8("lineEditTo"))
self.gridLayout_2.addWidget(self.lineEditTo, 5, 2, 1, 1)
self.lineEditSubject = QtGui.QLineEdit(self.send) self.lineEditSubject = QtGui.QLineEdit(self.send)
self.lineEditSubject.setText(_fromUtf8("")) self.lineEditSubject.setText(_fromUtf8(""))
self.lineEditSubject.setObjectName(_fromUtf8("lineEditSubject")) self.lineEditSubject.setObjectName(_fromUtf8("lineEditSubject"))
@ -206,6 +200,9 @@ class Ui_MainWindow(object):
self.labelFrom = QtGui.QLabel(self.send) self.labelFrom = QtGui.QLabel(self.send)
self.labelFrom.setObjectName(_fromUtf8("labelFrom")) self.labelFrom.setObjectName(_fromUtf8("labelFrom"))
self.gridLayout_2.addWidget(self.labelFrom, 2, 4, 1, 1) self.gridLayout_2.addWidget(self.labelFrom, 2, 4, 1, 1)
self.label = QtGui.QLabel(self.send)
self.label.setObjectName(_fromUtf8("label"))
self.gridLayout_2.addWidget(self.label, 11, 0, 1, 1)
icon2 = QtGui.QIcon() icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/send.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/send.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.tabWidget.addTab(self.send, icon2, _fromUtf8("")) self.tabWidget.addTab(self.send, icon2, _fromUtf8(""))
@ -527,7 +524,6 @@ class Ui_MainWindow(object):
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(1) self.tabWidget.setCurrentIndex(1)
QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), self.lineEditTo.setEnabled)
QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.labelSendBroadcastWarning.hide) QtCore.QObject.connect(self.radioButtonSpecific, QtCore.SIGNAL(_fromUtf8("clicked(bool)")), self.labelSendBroadcastWarning.hide)
QtCore.QObject.connect(self.radioButtonBroadcast, QtCore.SIGNAL(_fromUtf8("clicked()")), self.labelSendBroadcastWarning.show) QtCore.QObject.connect(self.radioButtonBroadcast, QtCore.SIGNAL(_fromUtf8("clicked()")), self.labelSendBroadcastWarning.show)
QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
@ -572,7 +568,6 @@ class Ui_MainWindow(object):
self.tabWidget.setTabText(self.tabWidget.indexOf(self.inbox), _translate("MainWindow", "Inbox", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.inbox), _translate("MainWindow", "Inbox", None))
self.pushButtonFetchNamecoinID.setText(_translate("MainWindow", "Fetch Namecoin ID", None)) self.pushButtonFetchNamecoinID.setText(_translate("MainWindow", "Fetch Namecoin ID", None))
self.label_4.setText(_translate("MainWindow", "Message:", None)) self.label_4.setText(_translate("MainWindow", "Message:", None))
self.label.setText(_translate("MainWindow", "To:", None))
self.label_2.setText(_translate("MainWindow", "From:", None)) self.label_2.setText(_translate("MainWindow", "From:", None))
self.label_3.setText(_translate("MainWindow", "Subject:", None)) self.label_3.setText(_translate("MainWindow", "Subject:", None))
self.radioButtonSpecific.setText(_translate("MainWindow", "Send to one or more specific people", None)) self.radioButtonSpecific.setText(_translate("MainWindow", "Send to one or more specific people", None))
@ -591,6 +586,7 @@ class Ui_MainWindow(object):
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None)) "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None))
self.pushButtonSend.setText(_translate("MainWindow", "Send", None)) self.pushButtonSend.setText(_translate("MainWindow", "Send", None))
self.labelFrom.setText(_translate("MainWindow", "BM-…", None)) self.labelFrom.setText(_translate("MainWindow", "BM-…", None))
self.label.setText(_translate("MainWindow", "To:", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.send), _translate("MainWindow", "Send", None)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.send), _translate("MainWindow", "Send", None))
self.sentSearchLineEdit.setPlaceholderText(_translate("MainWindow", "Search", None)) self.sentSearchLineEdit.setPlaceholderText(_translate("MainWindow", "Search", None))
self.sentSearchOptionCB.setItemText(0, _translate("MainWindow", "All", None)) self.sentSearchOptionCB.setItemText(0, _translate("MainWindow", "All", None))

View File

@ -236,13 +236,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>To:</string>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@ -257,9 +250,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="2">
<widget class="QLineEdit" name="lineEditTo"/>
</item>
<item row="14" column="2" colspan="3"> <item row="14" column="2" colspan="3">
<widget class="QLineEdit" name="lineEditSubject"> <widget class="QLineEdit" name="lineEditSubject">
<property name="text"> <property name="text">
@ -424,6 +414,13 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>To:</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="sent"> <widget class="QWidget" name="sent">
@ -1259,22 +1256,6 @@ p, li { white-space: pre-wrap; }
<include location="bitmessage_icons.qrc"/> <include location="bitmessage_icons.qrc"/>
</resources> </resources>
<connections> <connections>
<connection>
<sender>radioButtonSpecific</sender>
<signal>toggled(bool)</signal>
<receiver>lineEditTo</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>121</x>
<y>60</y>
</hint>
<hint type="destinationlabel">
<x>175</x>
<y>147</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>radioButtonSpecific</sender> <sender>radioButtonSpecific</sender>
<signal>clicked(bool)</signal> <signal>clicked(bool)</signal>

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'settings.ui' # Form implementation generated from reading ui file 'settings.ui'
# #
# Created: Tue Sep 10 09:45:03 2013 # Created: Wed Sep 11 21:08:23 2013
# by: PyQt4 UI code generator 4.10.2 # by: PyQt4 UI code generator 4.10.2
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!