- the name/label field will accept mixed content, e.g. "BM-...;Contact-Name"
- the address field accepts only addresses and namecoin ids - the next item in a multi-input (e.g. "BM-...;BM-...") will automatically display the corresponding label or address - set the new To-row to grey, to indicate that it is not in the recipients list yet. - don't send when there is still text in the "new recipients" row
This commit is contained in:
parent
bb9e3c551c
commit
d7bc65c8dc
|
@ -312,21 +312,23 @@ class MyForm(QtGui.QMainWindow):
|
||||||
# Add the New Recipient row
|
# Add the New Recipient row
|
||||||
self.ui.tableWidgetRecipients.insertRow(0)
|
self.ui.tableWidgetRecipients.insertRow(0)
|
||||||
self.ui.comboboxFindLabel = QtGui.QComboBox()
|
self.ui.comboboxFindLabel = QtGui.QComboBox()
|
||||||
self.ui.comboboxFindLabel.addItem('', 'BM-')
|
self.ui.comboboxFindLabel.addItem('', '')
|
||||||
self.ui.comboboxFindLabel.setFrame(False)
|
self.ui.comboboxFindLabel.setFrame(False)
|
||||||
self.ui.comboboxFindLabel.setEditable(True)
|
self.ui.comboboxFindLabel.setEditable(True)
|
||||||
|
self.ui.comboboxFindLabel.setStyleSheet("color: grey;")
|
||||||
self.ui.comboboxFindLabel.setInsertPolicy(0)
|
self.ui.comboboxFindLabel.setInsertPolicy(0)
|
||||||
self.ui.tableWidgetRecipients.setCellWidget(0, 0, self.ui.comboboxFindLabel)
|
self.ui.tableWidgetRecipients.setCellWidget(0, 0, self.ui.comboboxFindLabel)
|
||||||
self.ui.comboboxFindAddress = QtGui.QComboBox()
|
self.ui.comboboxFindAddress = QtGui.QComboBox()
|
||||||
self.ui.comboboxFindAddress.addItem('BM-', '')
|
self.ui.comboboxFindAddress.addItem('', '')
|
||||||
self.ui.comboboxFindAddress.setAutoCompletionCaseSensitivity(Qt.CaseSensitive)
|
self.ui.comboboxFindAddress.setAutoCompletionCaseSensitivity(Qt.CaseSensitive)
|
||||||
self.ui.comboboxFindAddress.setFrame(False)
|
self.ui.comboboxFindAddress.setFrame(False)
|
||||||
self.ui.comboboxFindAddress.setEditable(True)
|
self.ui.comboboxFindAddress.setEditable(True)
|
||||||
|
self.ui.comboboxFindAddress.setStyleSheet("color: grey;")
|
||||||
self.ui.comboboxFindAddress.setInsertPolicy(0)
|
self.ui.comboboxFindAddress.setInsertPolicy(0)
|
||||||
self.ui.tableWidgetRecipients.setCellWidget(0, 1, self.ui.comboboxFindAddress)
|
self.ui.tableWidgetRecipients.setCellWidget(0, 1, self.ui.comboboxFindAddress)
|
||||||
# keypress events
|
# keypress events
|
||||||
self.ui.comboboxFindLabel.keyPressEvent = self.on_comboboxFindLabel_enter
|
self.ui.comboboxFindLabel.keyPressEvent = self.on_comboboxFindLabel_event
|
||||||
self.ui.comboboxFindAddress.keyPressEvent = self.on_comboboxFindAddress_enter
|
self.ui.comboboxFindAddress.keyPressEvent = self.on_comboboxFindAddress_event
|
||||||
# combobox change events
|
# combobox change events
|
||||||
QtCore.QObject.connect(self.ui.comboboxFindLabel, QtCore.SIGNAL(
|
QtCore.QObject.connect(self.ui.comboboxFindLabel, QtCore.SIGNAL(
|
||||||
"currentIndexChanged(int)"), self.on_comboboxFindLabel_change)
|
"currentIndexChanged(int)"), self.on_comboboxFindLabel_change)
|
||||||
|
@ -833,8 +835,8 @@ class MyForm(QtGui.QMainWindow):
|
||||||
# reset the comboboxes
|
# reset the comboboxes
|
||||||
self.ui.comboboxFindLabel.clear()
|
self.ui.comboboxFindLabel.clear()
|
||||||
self.ui.comboboxFindAddress.clear()
|
self.ui.comboboxFindAddress.clear()
|
||||||
self.ui.comboboxFindLabel.addItem('', 'BM-')
|
self.ui.comboboxFindLabel.addItem('', '')
|
||||||
self.ui.comboboxFindAddress.addItem('BM-', '')
|
self.ui.comboboxFindAddress.addItem('', '')
|
||||||
for (tableWidget,widgetName) in [(self.ui.tableWidgetYourIdentities, _translate("MainWindow", "Your Identities")), (self.ui.tableWidgetAddressBook,_translate("MainWindow", "Address Book")), (self.ui.tableWidgetSubscriptions,_translate("MainWindow", "Subscriptions"))]:
|
for (tableWidget,widgetName) in [(self.ui.tableWidgetYourIdentities, _translate("MainWindow", "Your Identities")), (self.ui.tableWidgetAddressBook,_translate("MainWindow", "Address Book")), (self.ui.tableWidgetSubscriptions,_translate("MainWindow", "Subscriptions"))]:
|
||||||
# separator + label + separator
|
# separator + label + separator
|
||||||
self.ui.comboboxFindLabel.insertSeparator(self.ui.comboboxFindLabel.count())
|
self.ui.comboboxFindLabel.insertSeparator(self.ui.comboboxFindLabel.count())
|
||||||
|
@ -1613,8 +1615,22 @@ class MyForm(QtGui.QMainWindow):
|
||||||
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)
|
||||||
toAddressesList = self.get_recipient_addresses()
|
toAddressesList = self.get_recipient_addresses()
|
||||||
|
# ask what to do with the address in the current "new recipient" row
|
||||||
|
if (len(self.ui.comboboxFindLabel.currentText()) > 0) | (len(self.ui.comboboxFindAddress.currentText()) > 0):
|
||||||
|
for i in range(4):
|
||||||
|
time.sleep(0.1)
|
||||||
|
self.statusBar().showMessage('')
|
||||||
|
time.sleep(0.1)
|
||||||
|
self.statusBar().showMessage(_translate(
|
||||||
|
"MainWindow", "You are about to add another address to the 'To' field. You have to either submit or discard it before sending."))
|
||||||
|
return
|
||||||
|
|
||||||
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.
|
||||||
|
if len(toAddressesList) == 0:
|
||||||
|
self.statusBar().showMessage(_translate(
|
||||||
|
"MainWindow", "Your \'To\' field is empty."))
|
||||||
|
else:
|
||||||
for toAddress in toAddressesList:
|
for toAddress in toAddressesList:
|
||||||
if toAddress != '':
|
if toAddress != '':
|
||||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
|
||||||
|
@ -1682,9 +1698,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
self.ui.textEditMessage.setText('')
|
self.ui.textEditMessage.setText('')
|
||||||
self.ui.tabWidget.setCurrentIndex(2)
|
self.ui.tabWidget.setCurrentIndex(2)
|
||||||
self.ui.tableWidgetSent.setCurrentCell(0, 0)
|
self.ui.tableWidgetSent.setCurrentCell(0, 0)
|
||||||
else:
|
|
||||||
self.statusBar().showMessage(_translate(
|
|
||||||
"MainWindow", "Your \'To\' field is empty."))
|
|
||||||
else: # User selected 'Broadcast'
|
else: # User selected 'Broadcast'
|
||||||
if fromAddress == '':
|
if fromAddress == '':
|
||||||
self.statusBar().showMessage(_translate(
|
self.statusBar().showMessage(_translate(
|
||||||
|
@ -2638,69 +2652,115 @@ class MyForm(QtGui.QMainWindow):
|
||||||
|
|
||||||
# handle input on enter
|
# handle input on enter
|
||||||
|
|
||||||
def on_comboboxFindLabel_enter(self, event):
|
def on_comboboxFindLabel_event(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):
|
||||||
|
self.on_comboboxFindLabel_enter()
|
||||||
|
return QtGui.QComboBox.keyPressEvent(self.ui.comboboxFindLabel, event)
|
||||||
|
|
||||||
|
def on_comboboxFindLabel_enter(self):
|
||||||
index = self.ui.comboboxFindLabel.currentIndex()
|
index = self.ui.comboboxFindLabel.currentIndex()
|
||||||
currentText = str(self.ui.comboboxFindLabel.currentText())
|
currentText = str(self.ui.comboboxFindLabel.currentText())
|
||||||
|
currentAddressText = str(self.ui.comboboxFindAddress.currentText())
|
||||||
labelList = currentText.replace(',',';').split(';')
|
labelList = currentText.replace(',',';').split(';')
|
||||||
label = str(labelList[0])
|
label = str(labelList[0])
|
||||||
otherLabels = str(';'.join(labelList[1:]))
|
otherLabels = str(';'.join(labelList[1:]))
|
||||||
found = self.ui.comboboxFindLabel.findText(label, Qt.MatchCaseSensitive)
|
foundLabel = self.ui.comboboxFindLabel.findText(label, Qt.MatchCaseSensitive)
|
||||||
|
foundAddress = self.ui.comboboxFindLabel.findData(addBMIfNotPresent(label), Qt.UserRole, Qt.MatchCaseSensitive)
|
||||||
if (currentText=='') & (str(self.ui.comboboxFindLabel.itemText(index))==''):
|
if (currentText=='') & (str(self.ui.comboboxFindLabel.itemText(index))==''):
|
||||||
print 'workaround for empty labels'
|
# print 'workaround for empty labels. this is only relevant for addresses selected through the combobox'
|
||||||
address = str(self.ui.comboboxFindLabel.itemData(index).toString())
|
address = str(self.ui.comboboxFindLabel.itemData(index).toString())
|
||||||
# print 'empty label', address
|
|
||||||
self.on_addRecipient_submit(address)
|
|
||||||
elif (found > 0) & (index == found):
|
|
||||||
print 'label found'
|
|
||||||
address = str(self.ui.comboboxFindLabel.itemData(found).toString())
|
|
||||||
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.on_addRecipient_submit(address)
|
||||||
|
elif foundLabel > 0:
|
||||||
|
# print 'this label is in your list'
|
||||||
|
address = str(self.ui.comboboxFindLabel.itemData(foundLabel).toString())
|
||||||
|
if address != currentAddressText:
|
||||||
|
# print 'on the first "enter" only adapt the other combobox'
|
||||||
|
self.ui.comboboxFindAddress.setEditText(address)
|
||||||
|
else:
|
||||||
|
# print 'this must be the second "enter": accept it!'
|
||||||
|
if self.on_addRecipient_submit(address):
|
||||||
|
# leave the other labels for another try
|
||||||
self.ui.comboboxFindLabel.setEditText(otherLabels)
|
self.ui.comboboxFindLabel.setEditText(otherLabels)
|
||||||
|
# simulate "enter" to display the matching address of the next input item
|
||||||
|
self.on_comboboxFindLabel_enter()
|
||||||
|
elif foundAddress > 0:
|
||||||
|
# for mixed content, e.g. "BM-...;Frank" we also accept addresses in the label field
|
||||||
|
# print 'this address is in your list'
|
||||||
|
address = str(self.ui.comboboxFindLabel.itemData(foundAddress).toString())
|
||||||
|
if address != currentAddressText:
|
||||||
|
# on the first "enter" only adapt the other combobox
|
||||||
|
self.ui.comboboxFindAddress.setEditText(address)
|
||||||
else:
|
else:
|
||||||
status, a, b, c = decodeAddress(str(currentText))
|
# print 'this must be the second "enter": accept it!'
|
||||||
# check if the text is a BM-Address
|
if self.on_addRecipient_submit(address):
|
||||||
|
# leave the other labels for another try
|
||||||
|
self.ui.comboboxFindLabel.setEditText(otherLabels)
|
||||||
|
# simulate "enter" to display the matching address of the next input item
|
||||||
|
self.on_comboboxFindLabel_enter()
|
||||||
|
else:
|
||||||
|
# print 'no matching contact. Let's act as if someone put an unknown address in the label field.'
|
||||||
|
address = label
|
||||||
|
if address != currentAddressText:
|
||||||
|
status, addressVersionNumber, streamNumber, ripe = decodeAddress(str(address))
|
||||||
if status == 'success':
|
if status == 'success':
|
||||||
# try to find it in the list
|
self.ui.comboboxFindAddress.setEditText(address)
|
||||||
found = self.ui.comboboxFindLabel.findData(label, Qt.UserRole, Qt.MatchCaseSensitive)
|
|
||||||
if found > 0:
|
|
||||||
# found the element in the list
|
|
||||||
self.ui.comboboxFindLabel.setCurrentIndex(found if found > 0 else 0)
|
|
||||||
else:
|
else:
|
||||||
# reset the currentText
|
self.ui.comboboxFindAddress.setEditText('')
|
||||||
self.ui.comboboxFindLabel.setCurrentIndex(0)
|
self.throw_address_error(address, status, addressVersionNumber, streamNumber, ripe)
|
||||||
# copy the BM-address to the address field
|
else:
|
||||||
self.ui.comboboxFindAddress.setEditText(currentText)
|
if self.on_addRecipient_submit(label):
|
||||||
return QtGui.QComboBox.keyPressEvent(self.ui.comboboxFindLabel, event)
|
self.ui.comboboxFindLabel.setEditText(otherLabels)
|
||||||
|
self.on_comboboxFindLabel_enter()
|
||||||
|
|
||||||
def on_comboboxFindAddress_enter(self, event):
|
def on_comboboxFindAddress_event(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):
|
||||||
|
self.on_comboboxFindAddress_enter()
|
||||||
|
return QtGui.QComboBox.keyPressEvent(self.ui.comboboxFindAddress, event)
|
||||||
|
|
||||||
|
def on_comboboxFindAddress_enter(self):
|
||||||
index = self.ui.comboboxFindAddress.currentIndex()
|
index = self.ui.comboboxFindAddress.currentIndex()
|
||||||
currentText = str(self.ui.comboboxFindAddress.currentText())
|
currentText = str(self.ui.comboboxFindAddress.currentText())
|
||||||
|
currentLabelText = str(self.ui.comboboxFindLabel.currentText())
|
||||||
addressList = currentText.replace(',',';').split(';')
|
addressList = currentText.replace(',',';').split(';')
|
||||||
address = str(addressList[0])
|
address = str(addressList[0])
|
||||||
|
label = ''
|
||||||
otherAddresses = str(';'.join(addressList[1:]))
|
otherAddresses = str(';'.join(addressList[1:]))
|
||||||
found = self.ui.comboboxFindAddress.findText(addBMIfNotPresent(address), Qt.MatchCaseSensitive)
|
foundAddress = self.ui.comboboxFindAddress.findText(addBMIfNotPresent(address), Qt.MatchCaseSensitive)
|
||||||
if (found > 0) & (index == found):
|
if foundAddress > 0:
|
||||||
address = str(self.ui.comboboxFindAddress.itemText(found))
|
# print 'this address is in your list'
|
||||||
self.on_addRecipient_submit(address)
|
# address = str(self.ui.comboboxFindAddress.itemText(foundAddress)) # redundant
|
||||||
elif found > 0:
|
label = str(self.ui.comboboxFindAddress.itemData(foundAddress).toString())
|
||||||
address = str(self.ui.comboboxFindAddress.itemText(found))
|
print label, currentLabelText
|
||||||
self.on_addRecipient_submit(address)
|
if label != currentLabelText:
|
||||||
|
# on the first "enter" only adapt the other combobox
|
||||||
|
self.ui.comboboxFindLabel.setEditText(label)
|
||||||
|
else:
|
||||||
|
# print 'this must be the second "enter": accept it!'
|
||||||
|
if self.on_addRecipient_submit(address):
|
||||||
|
# leave the other addresses for another try
|
||||||
self.ui.comboboxFindAddress.setEditText(otherAddresses)
|
self.ui.comboboxFindAddress.setEditText(otherAddresses)
|
||||||
|
# simulate "enter" to display the matching label of the next input item
|
||||||
|
self.on_comboboxFindAddress_enter()
|
||||||
elif address[:3] == 'id/':
|
elif address[:3] == 'id/':
|
||||||
self.click_pushButtonFetchNamecoinID()
|
self.click_pushButtonFetchNamecoinID()
|
||||||
else:
|
else:
|
||||||
print 'no matching contact'
|
# print 'no matching contact.'
|
||||||
self.ui.comboboxFindLabel.setCurrentIndex(0)
|
if label != currentLabelText:
|
||||||
# but maybe the address is valid?
|
status, addressVersionNumber, streamNumber, ripe = decodeAddress(str(address))
|
||||||
self.ui.comboboxFindAddress.setEditText(currentText) # otherwise you will lose the text on enter
|
if status == 'success':
|
||||||
# random address for testing: BM-2DAArASbJckBdn3HvTt7kHAbPA5tGxc2R1
|
# on the first "enter" only adapt the other combobox
|
||||||
self.on_addRecipient_submit(addBMIfNotPresent(address))
|
label = _translate("MainWindow", "--unknown Address--")
|
||||||
return QtGui.QComboBox.keyPressEvent(self.ui.comboboxFindAddress, event)
|
self.ui.comboboxFindLabel.setEditText(label)
|
||||||
|
else:
|
||||||
|
self.ui.comboboxFindLabel.setEditText('')
|
||||||
|
self.throw_address_error(address, status, addressVersionNumber, streamNumber, ripe)
|
||||||
|
else:
|
||||||
|
# print 'this must be the second "enter": accept it!'
|
||||||
|
if self.on_addRecipient_submit(address):
|
||||||
|
# leave the other labels for another try
|
||||||
|
self.ui.comboboxFindAddress.setEditText(otherAddresses)
|
||||||
|
# simulate "enter" to display the matching label of the next input item
|
||||||
|
self.on_comboboxFindAddress_enter()
|
||||||
|
|
||||||
def get_recipient_addresses(self):
|
def get_recipient_addresses(self):
|
||||||
recipients = []
|
recipients = []
|
||||||
|
@ -2757,7 +2817,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
self.statusBar().showMessage(
|
self.statusBar().showMessage(
|
||||||
_translate(
|
_translate(
|
||||||
"MainWindow", "Error: The address you are trying to add, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. ").arg(address))
|
"MainWindow", "Error: The address you are trying to add, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. ").arg(address))
|
||||||
return
|
return False
|
||||||
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
|
||||||
if overwriteLabel:
|
if overwriteLabel:
|
||||||
|
@ -2780,10 +2840,7 @@ class MyForm(QtGui.QMainWindow):
|
||||||
if shared.safeConfigGetBoolean(address, 'chan'):
|
if shared.safeConfigGetBoolean(address, 'chan'):
|
||||||
newItem.setTextColor(QtGui.QColor(216, 119, 0)) # orange
|
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)
|
||||||
# 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
|
return True
|
||||||
# jump to the first item
|
|
||||||
self.ui.comboboxFindLabel.setCurrentIndex(0)
|
|
||||||
self.ui.comboboxFindAddress.setCurrentIndex(0)
|
|
||||||
else:
|
else:
|
||||||
if address == 'BM-':
|
if address == 'BM-':
|
||||||
for i in range(4):
|
for i in range(4):
|
||||||
|
@ -2792,8 +2849,10 @@ class MyForm(QtGui.QMainWindow):
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
self.statusBar().showMessage(_translate(
|
self.statusBar().showMessage(_translate(
|
||||||
"MainWindow", "Start typing a label or address from your Address Book, Identities or Subscriptions to find it in the list."))
|
"MainWindow", "Start typing a label or address from your Address Book, Identities or Subscriptions to find it in the list."))
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
self.throw_address_error(address, status, addressVersionNumber, streamNumber, ripe)
|
self.throw_address_error(address, status, addressVersionNumber, streamNumber, ripe)
|
||||||
|
return False
|
||||||
|
|
||||||
# Group of functions for the Address Book dialog box
|
# Group of functions for the Address Book dialog box
|
||||||
def on_action_AddressBookNew(self):
|
def on_action_AddressBookNew(self):
|
||||||
|
|
Reference in New Issue
Block a user