various changes to Identicon code

This commit is contained in:
Jonathan Warren 2013-11-01 19:25:24 -04:00
parent 753155aa86
commit f7ef2b4e05
5 changed files with 288 additions and 448 deletions

View File

@ -29,6 +29,7 @@ import sys
from time import strftime, localtime, gmtime
import time
import os
import hashlib
from pyelliptic.openssl import OpenSSL
import pickle
import platform
@ -64,20 +65,19 @@ def identiconize(address):
# 3fd4bf901b9d4ea1394f0fb358725b28
try:
identicon_lib = shared.config.get('bitmessagesettings', 'identicon')
identicon_lib = shared.config.get('bitmessagesettings', 'identiconlib')
except:
# default to no identicons
identicon_lib = False
# default to qidenticon_two_x
identicon_lib = 'qidenticon_two_x'
try:
# As an 'identiconsuffix' you could put "@bitmessge.ch" or "@bm.addr" to make it compatible with other identicon generators. (Note however, that E-Mail programs might convert the BM-address to lowercase first.)
# It can be used as a pseudo-password to salt the generation of the identicons to decrease the risk
# of attacks where someone creates an address to mimic someone else's identicon.
# If not set yet it will be filled by a random string.
# Another good idea would be to fill it with the private key of one of your addresses (because you don't need to memorize it then).
identiconsuffix = shared.config.get('bitmessagesettings', 'identiconsuffix')
except:
identiconsuffix = ''
# As an 'identiconsuffix' you could put "@bitmessge.ch" or "@bm.addr" to make it compatible with other identicon generators. (Note however, that E-Mail programs might convert the BM-address to lowercase first.)
# It can be used as a pseudo-password to salt the generation of the identicons to decrease the risk
# of attacks where someone creates an address to mimic someone else's identicon.
identiconsuffix = shared.config.get('bitmessagesettings', 'identiconsuffix')
if not shared.config.getboolean('bitmessagesettings', 'useidenticons'):
idcon = QtGui.QIcon()
return idcon
if (identicon_lib[:len('qidenticon')] == 'qidenticon'):
# print identicon_lib
@ -86,7 +86,6 @@ def identiconize(address):
# Licesensed under FreeBSD License.
# stripped from PIL and uses QT instead (by sendiulo, same license)
import qidenticon
import hashlib
hash = hashlib.md5(addBMIfNotPresent(address)+identiconsuffix).hexdigest()
use_two_colors = (identicon_lib[:len('qidenticon_two')] == 'qidenticon_two')
opacity = int(not((identicon_lib == 'qidenticon_x') | (identicon_lib == 'qidenticon_two_x') | (identicon_lib == 'qidenticon_b') | (identicon_lib == 'qidenticon_two_b')))*255
@ -113,66 +112,50 @@ def identiconize(address):
idcon = QtGui.QIcon()
idcon.addPixmap(pix, QtGui.QIcon.Normal, QtGui.QIcon.Off)
return idcon
elif identicon_lib in ['False', 'false', 'None', 'none']:
idcon = QtGui.QIcon()
return idcon
else:
# default to no identicons
idcon = QtGui.QIcon()
return idcon
def avatarize(address, fallBackToIdenticon = False):
def avatarize(address):
"""
loads a supported image for the given address' hash form 'avatars' folder
falls back to default avatar if 'default.*' file exists
falls back to identiconize(address) if second argument fallBackToIdenticon == True
falls back to identiconize(address)
"""
idcon = QtGui.QIcon()
if shared.safeConfigGetBoolean('bitmessagesettings', 'avatars'):
import hashlib
hash = hashlib.md5(addBMIfNotPresent(address)).hexdigest()
str_broadcast_subscribers = '[Broadcast subscribers]'
if address == str_broadcast_subscribers:
# don't hash [Broadcast subscribers]
hash = address
# http://pyqt.sourceforge.net/Docs/PyQt4/qimagereader.html#supportedImageFormats
# print QImageReader.supportedImageFormats ()
# QImageReader.supportedImageFormats ()
extensions = ['PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'MNG', 'PBM', 'PGM', 'PPM', 'TIFF', 'XBM', 'XPM', 'TGA']
# try to find a specific avatar
for ext in extensions:
lower_hash = shared.appdata + 'avatars/' + hash + '.' + ext.lower()
upper_hash = shared.appdata + 'avatars/' + hash + '.' + ext.upper()
if os.path.isfile(lower_hash):
# print 'found avatar of ', address
idcon.addFile(lower_hash)
return idcon
elif os.path.isfile(upper_hash):
# print 'found avatar of ', address
idcon.addFile(upper_hash)
return idcon
# if we haven't found any, try to find a default avatar
for ext in extensions:
lower_default = shared.appdata + 'avatars/' + 'default.' + ext.lower()
upper_default = shared.appdata + 'avatars/' + 'default.' + ext.upper()
if os.path.isfile(lower_default):
default = lower_default
idcon.addFile(lower_default)
return idcon
elif os.path.isfile(upper_default):
default = upper_default
idcon.addFile(upper_default)
return idcon
# if avatars are deactivated or none found
if fallBackToIdenticon:
return identiconize(address)
else:
try:
identicon_lib = shared.config.get('bitmessagesettings', 'identicon')
except:
# default to no identicons
identicon_lib = False
return idcon
hash = hashlib.md5(addBMIfNotPresent(address)).hexdigest()
str_broadcast_subscribers = '[Broadcast subscribers]'
if address == str_broadcast_subscribers:
# don't hash [Broadcast subscribers]
hash = address
# http://pyqt.sourceforge.net/Docs/PyQt4/qimagereader.html#supportedImageFormats
# print QImageReader.supportedImageFormats ()
# QImageReader.supportedImageFormats ()
extensions = ['PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'MNG', 'PBM', 'PGM', 'PPM', 'TIFF', 'XBM', 'XPM', 'TGA']
# try to find a specific avatar
for ext in extensions:
lower_hash = shared.appdata + 'avatars/' + hash + '.' + ext.lower()
upper_hash = shared.appdata + 'avatars/' + hash + '.' + ext.upper()
if os.path.isfile(lower_hash):
# print 'found avatar of ', address
idcon.addFile(lower_hash)
return idcon
elif os.path.isfile(upper_hash):
# print 'found avatar of ', address
idcon.addFile(upper_hash)
return idcon
# if we haven't found any, try to find a default avatar
for ext in extensions:
lower_default = shared.appdata + 'avatars/' + 'default.' + ext.lower()
upper_default = shared.appdata + 'avatars/' + 'default.' + ext.upper()
if os.path.isfile(lower_default):
default = lower_default
idcon.addFile(lower_default)
return idcon
elif os.path.isfile(upper_default):
default = upper_default
idcon.addFile(upper_default)
return idcon
# If no avatar is found
return identiconize(address)
class MyForm(QtGui.QMainWindow):
@ -462,7 +445,6 @@ class MyForm(QtGui.QMainWindow):
newItem.setTextColor(QtGui.QColor(128, 128, 128))
if shared.safeConfigGetBoolean(addressInKeysFile, 'mailinglist'):
newItem.setTextColor(QtGui.QColor(137, 04, 177)) # magenta
newItem.setIcon(identiconize(addressInKeysFile))
self.ui.tableWidgetYourIdentities.setItem(0, 1, newItem)
newItem = QtGui.QTableWidgetItem(str(
decodeAddress(addressInKeysFile)[2]))
@ -531,7 +513,6 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetYourIdentities.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.ui.tableWidgetSubscriptions.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.ui.tableWidgetAddressBook.setIconSize(QtCore.QSize(identicon_size, identicon_size))
#self.ui.tableWidgetWhitelist.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.ui.tableWidgetBlacklist.setIconSize(QtCore.QSize(identicon_size, identicon_size))
self.UISignalThread = UISignaler()
@ -713,30 +694,29 @@ class MyForm(QtGui.QMainWindow):
for row in queryreturn:
toAddress, fromAddress, subject, status, ackdata, lastactiontime = row
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
#message = shared.fixPotentiallyInvalidUTF8Data(message)
try:
if shared.config.has_section(fromAddress):
fromLabel = shared.config.get(fromAddress, 'label')
except:
fromLabel = ''
if fromLabel == '':
fromLabel = fromAddress
toLabel = ''
queryreturn = sqlQuery(
'''select label from addressbook where address=?''', toAddress)
if queryreturn != []:
for row in queryreturn:
toLabel, = row
self.ui.tableWidgetSent.insertRow(0)
if toLabel == '':
newItem = QtGui.QTableWidgetItem(unicode(toAddress, 'utf-8'))
newItem.setToolTip(unicode(toAddress, 'utf-8'))
else:
newItem = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
newItem.setToolTip(unicode(toLabel, 'utf-8'))
newItem.setIcon(avatarize(toAddress, True))
if shared.config.has_section(toAddress):
toLabel = shared.config.get(toAddress, 'label')
if toLabel == '':
toLabel = toAddress
self.ui.tableWidgetSent.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
newItem.setToolTip(unicode(toLabel, 'utf-8'))
newItem.setIcon(avatarize(toAddress))
newItem.setData(Qt.UserRole, str(toAddress))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
@ -748,7 +728,7 @@ class MyForm(QtGui.QMainWindow):
else:
newItem = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8'))
newItem.setToolTip(unicode(fromLabel, 'utf-8'))
newItem.setIcon(avatarize(fromAddress, True))
newItem.setIcon(avatarize(fromAddress))
newItem.setData(Qt.UserRole, str(fromAddress))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
@ -837,7 +817,6 @@ class MyForm(QtGui.QMainWindow):
for row in queryreturn:
msgid, toAddress, fromAddress, subject, received, read = row
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
#message = shared.fixPotentiallyInvalidUTF8Data(message)
try:
if toAddress == self.str_broadcast_subscribers:
toLabel = self.str_broadcast_subscribers
@ -848,17 +827,13 @@ class MyForm(QtGui.QMainWindow):
if toLabel == '':
toLabel = toAddress
try: # try to get the from label fom YourIdentites (for chan messages)
fromLabel = ''
if shared.config.has_section(fromAddress):
fromLabel = shared.config.get(fromAddress, 'label')
checkIfChan = True
except:
fromLabel = ''
checkIfChan = False
if fromLabel == '': # If this address wasn't in our address book...
if fromLabel == '': # If the fromAddress isn't one of our addresses
queryreturn = sqlQuery(
'''select label from addressbook where address=?''', fromAddress)
if queryreturn != []:
for row in queryreturn:
fromLabel, = row
@ -866,16 +841,17 @@ class MyForm(QtGui.QMainWindow):
if fromLabel == '': # If this address wasn't in our address book...
queryReturn = sqlQuery(
'''select label from subscriptions where address=?''', fromAddress)
if queryreturn != []:
for row in queryreturn:
fromLabel, = row
if fromLabel == '':
fromLabel = fromAddress
# message row
self.ui.tableWidgetInbox.insertRow(0)
# to
newItem = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
newItem.setToolTip(unicode(toLabel, 'utf-8'))
# to
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read:
@ -885,24 +861,19 @@ class MyForm(QtGui.QMainWindow):
newItem.setTextColor(QtGui.QColor(137, 04, 177)) # magenta
if shared.safeConfigGetBoolean(str(toAddress), 'chan'):
newItem.setTextColor(QtGui.QColor(216, 119, 0)) # orange
newItem.setIcon(avatarize(toAddress, True))
newItem.setIcon(avatarize(toAddress))
self.ui.tableWidgetInbox.setItem(0, 0, newItem)
# from
if fromLabel == '':
newItem = QtGui.QTableWidgetItem(
unicode(fromAddress, 'utf-8'))
newItem.setToolTip(unicode(fromAddress, 'utf-8'))
else:
newItem = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8'))
newItem.setToolTip(unicode(fromLabel, 'utf-8'))
newItem = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8'))
newItem.setToolTip(unicode(fromLabel, 'utf-8'))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not read:
newItem.setFont(font)
newItem.setData(Qt.UserRole, str(fromAddress))
if checkIfChan & shared.safeConfigGetBoolean(str(toAddress), 'chan'):
if shared.safeConfigGetBoolean(str(fromAddress), 'chan'):
newItem.setTextColor(QtGui.QColor(216, 119, 0)) # orange
newItem.setIcon(avatarize(fromAddress, True))
newItem.setIcon(avatarize(fromAddress))
self.ui.tableWidgetInbox.setItem(0, 1, newItem)
# subject
newItem = QtGui.QTableWidgetItem(unicode(subject, 'utf-8'))
@ -1585,11 +1556,8 @@ class MyForm(QtGui.QMainWindow):
if queryreturn != []:
for row in queryreturn:
fromLabel, = row
self.ui.tableWidgetInbox.item(
i, 1).setText(unicode(fromLabel, 'utf-8'))
self.ui.tableWidgetInbox.item(
i, 1).setIcon(avatarize(addressToLookup, True))
else:
if fromLabel == '':
# It might be a broadcast message. We should check for that
# label.
queryreturn = sqlQuery(
@ -1598,46 +1566,38 @@ class MyForm(QtGui.QMainWindow):
if queryreturn != []:
for row in queryreturn:
fromLabel, = row
self.ui.tableWidgetInbox.item(
i, 1).setText(unicode(fromLabel, 'utf-8'))
self.ui.tableWidgetInbox.item(
i, 1).setIcon(avatarize(addressToLookup, True))
else:
# It might be a chan message. We should check for that
# label.
try:
fromLabel = shared.config.get(addressToLookup, 'label')
except:
fromLabel = ''
if fromLabel == '':
fromLabel = addressToLookup
self.ui.tableWidgetInbox.item(
i, 1).setText(unicode(fromLabel, 'utf-8'))
self.ui.tableWidgetInbox.item(
i, 1).setIcon(avatarize(addressToLookup, True))
# Set the color according to whether it is the address of a mailing
# list or not.
if shared.safeConfigGetBoolean(addressToLookup, 'chan'):
self.ui.tableWidgetInbox.item(i, 1).setTextColor(QtGui.QColor(216, 119, 0)) # orange
else:
self.ui.tableWidgetInbox.item(
i, 1).setTextColor(QApplication.palette().text().color())
if fromLabel == '':
# Message might be from an address we own like a chan address. Let's look for that label.
if shared.config.has_section(addressToLookup):
fromLabel = shared.config.get(addressToLookup, 'label')
if fromLabel == '':
fromLabel = addressToLookup
self.ui.tableWidgetInbox.item(
i, 1).setText(unicode(fromLabel, 'utf-8'))
self.ui.tableWidgetInbox.item(
i, 1).setIcon(avatarize(addressToLookup))
# Set the color according to whether it is the address of a mailing
# list or not.
if shared.safeConfigGetBoolean(addressToLookup, 'chan'):
self.ui.tableWidgetInbox.item(i, 1).setTextColor(QtGui.QColor(216, 119, 0)) # orange
else:
self.ui.tableWidgetInbox.item(
i, 1).setTextColor(QApplication.palette().text().color())
def rerenderInboxToLabels(self):
for i in range(self.ui.tableWidgetInbox.rowCount()):
toAddress = str(self.ui.tableWidgetInbox.item(
i, 0).data(Qt.UserRole).toPyObject())
try:
# Message might be to an address we own like a chan address. Let's look for that label.
if shared.config.has_section(toAddress):
toLabel = shared.config.get(toAddress, 'label')
except:
toLabel = ''
if toLabel == '':
else:
toLabel = toAddress
self.ui.tableWidgetInbox.item(
i, 0).setText(unicode(toLabel, 'utf-8'))
self.ui.tableWidgetInbox.item(
i, 0).setIcon(avatarize(toAddress, True))
i, 0).setIcon(avatarize(toAddress))
# Set the color according to whether it is the address of a mailing
# list, a chan or neither.
if shared.safeConfigGetBoolean(toAddress, 'chan'):
@ -1652,16 +1612,15 @@ class MyForm(QtGui.QMainWindow):
for i in range(self.ui.tableWidgetSent.rowCount()):
fromAddress = str(self.ui.tableWidgetSent.item(
i, 1).data(Qt.UserRole).toPyObject())
try:
# Message might be from an address we own like a chan address. Let's look for that label.
if shared.config.has_section(fromAddress):
fromLabel = shared.config.get(fromAddress, 'label')
except:
fromLabel = ''
if fromLabel == '':
else:
fromLabel = fromAddress
self.ui.tableWidgetSent.item(
i, 1).setText(unicode(fromLabel, 'utf-8'))
self.ui.tableWidgetSent.item(
i, 1).setIcon(avatarize(fromAddress, True))
i, 1).setIcon(avatarize(fromAddress))
def rerenderSentToLabels(self):
for i in range(self.ui.tableWidgetSent.rowCount()):
@ -1670,12 +1629,17 @@ class MyForm(QtGui.QMainWindow):
toLabel = ''
queryreturn = sqlQuery(
'''select label from addressbook where address=?''', addressToLookup)
if queryreturn != []:
for row in queryreturn:
toLabel, = row
self.ui.tableWidgetSent.item(
i, 0).setText(unicode(toLabel, 'utf-8'))
if toLabel == '':
# Message might be to an address we own like a chan address. Let's look for that label.
if shared.config.has_section(addressToLookup):
toLabel = shared.config.get(addressToLookup, 'label')
toLabel = addressToLookup
self.ui.tableWidgetSent.item(
i, 0).setText(unicode(toLabel, 'utf-8'))
def rerenderAddressBook(self):
self.ui.tableWidgetAddressBook.setRowCount(0)
@ -1684,6 +1648,7 @@ class MyForm(QtGui.QMainWindow):
label, address = row
self.ui.tableWidgetAddressBook.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
newItem.setIcon(avatarize(address))
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(address)
newItem.setFlags(
@ -1706,7 +1671,6 @@ class MyForm(QtGui.QMainWindow):
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not enabled:
newItem.setTextColor(QtGui.QColor(128, 128, 128))
newItem.setIcon(identiconize(address))
self.ui.tableWidgetSubscriptions.setItem(0, 1, newItem)
def click_pushButtonSend(self):
@ -1881,7 +1845,7 @@ class MyForm(QtGui.QMainWindow):
isEnabled = shared.config.getboolean(
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
if isEnabled:
self.ui.comboBoxSendFrom.insertItem(0, avatarize(addressInKeysFile, True), unicode(shared.config.get(
self.ui.comboBoxSendFrom.insertItem(0, avatarize(addressInKeysFile), unicode(shared.config.get(
addressInKeysFile, 'label'), 'utf-8'), addressInKeysFile)
self.ui.comboBoxSendFrom.insertItem(0, '', '')
if(self.ui.comboBoxSendFrom.count() == 2):
@ -1913,7 +1877,7 @@ class MyForm(QtGui.QMainWindow):
newItem = QtGui.QTableWidgetItem(unicode(toLabel, 'utf-8'))
newItem.setToolTip(unicode(toLabel, 'utf-8'))
newItem.setData(Qt.UserRole, str(toAddress))
newItem.setIcon(avatarize(toAddress, True))
newItem.setIcon(avatarize(toAddress))
self.ui.tableWidgetSent.setItem(0, 0, newItem)
if fromLabel == '':
newItem = QtGui.QTableWidgetItem(unicode(fromAddress, 'utf-8'))
@ -1922,7 +1886,7 @@ class MyForm(QtGui.QMainWindow):
newItem = QtGui.QTableWidgetItem(unicode(fromLabel, 'utf-8'))
newItem.setToolTip(unicode(fromLabel, 'utf-8'))
newItem.setData(Qt.UserRole, str(fromAddress))
newItem.setIcon(avatarize(fromAddress, True))
newItem.setIcon(avatarize(fromAddress))
self.ui.tableWidgetSent.setItem(0, 1, newItem)
newItem = QtGui.QTableWidgetItem(unicode(subject, 'utf-8)'))
newItem.setToolTip(unicode(subject, 'utf-8)'))
@ -1944,7 +1908,6 @@ class MyForm(QtGui.QMainWindow):
def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject, message):
subject = shared.fixPotentiallyInvalidUTF8Data(subject)
#message = shared.fixPotentiallyInvalidUTF8Data(message)
fromLabel = ''
queryreturn = sqlQuery(
'''select label from addressbook where address=?''', fromAddress)
@ -1981,7 +1944,7 @@ class MyForm(QtGui.QMainWindow):
if shared.safeConfigGetBoolean(str(toAddress), 'chan'):
newItem.setTextColor(QtGui.QColor(216, 119, 0)) # orange
self.ui.tableWidgetInbox.insertRow(0)
newItem.setIcon(avatarize(toAddress, True))
newItem.setIcon(avatarize(toAddress))
self.ui.tableWidgetInbox.setItem(0, 0, newItem)
if fromLabel == '':
@ -1996,7 +1959,7 @@ class MyForm(QtGui.QMainWindow):
self.notifierShow(unicode(_translate("MainWindow",'New Message').toUtf8(),'utf-8'), unicode(_translate("MainWindow",'From ').toUtf8(),'utf-8') + unicode(fromLabel, 'utf-8'), self.SOUND_KNOWN, unicode(fromLabel, 'utf-8'))
newItem.setData(Qt.UserRole, str(fromAddress))
newItem.setFont(font)
newItem.setIcon(avatarize(fromAddress, True))
newItem.setIcon(avatarize(fromAddress))
self.ui.tableWidgetInbox.setItem(0, 1, newItem)
newItem = QtGui.QTableWidgetItem(unicode(subject, 'utf-8)'))
newItem.setToolTip(unicode(subject, 'utf-8)'))
@ -2038,7 +2001,6 @@ class MyForm(QtGui.QMainWindow):
newItem.setIcon(avatarize(address))
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(address)
newItem.setIcon(identiconize(address))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
@ -2062,7 +2024,6 @@ class MyForm(QtGui.QMainWindow):
newItem.setIcon(avatarize(address))
self.ui.tableWidgetSubscriptions.setItem(0,0,newItem)
newItem = QtGui.QTableWidgetItem(address)
newItem.setIcon(identiconize(address))
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
self.ui.tableWidgetSubscriptions.setItem(0,1,newItem)
self.ui.tableWidgetSubscriptions.setSortingEnabled(True)
@ -2101,7 +2062,6 @@ class MyForm(QtGui.QMainWindow):
newItem.setIcon(avatarize(address))
self.ui.tableWidgetBlacklist.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(address)
newItem.setIcon(identiconize(address))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if not enabled:
@ -2135,19 +2095,13 @@ class MyForm(QtGui.QMainWindow):
self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
shared.config.set('bitmessagesettings', 'willinglysendtomobile', str(
self.settingsDialogInstance.ui.checkBoxWillinglySendToMobile.isChecked()))
shared.config.set('bitmessagesettings', 'useidenticons', str(
self.settingsDialogInstance.ui.checkBoxUseIdenticons.isChecked()))
lang_ind = int(self.settingsDialogInstance.ui.languageComboBox.currentIndex())
if not languages[lang_ind] == 'other':
shared.config.set('bitmessagesettings', 'userlocale', languages[lang_ind])
curr_index = self.settingsDialogInstance.ui.comboBoxIdenticonStyle.currentIndex()
shared.config.set('bitmessagesettings', 'identicon', str(self.settingsDialogInstance.ui.comboBoxIdenticonStyle.itemData(
curr_index , Qt.UserRole).toString()))
shared.config.set('bitmessagesettings', 'identiconsuffix', str(
self.settingsDialogInstance.ui.lineEditIdenticonSuffix.text()))
shared.config.set('bitmessagesettings', 'avatars', str(
self.settingsDialogInstance.ui.checkBoxLoadAvatars.isChecked()))
if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
if not shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'):
QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
@ -2297,11 +2251,12 @@ class MyForm(QtGui.QMainWindow):
self.NewBlacklistDialogInstance = NewSubscriptionDialog(self)
if self.NewBlacklistDialogInstance.exec_():
if self.NewBlacklistDialogInstance.ui.labelSubscriptionAddressCheck.text() == _translate("MainWindow", "Address is valid."):
address = addBMIfNotPresent(str(
self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text()))
# First we must check to see if the address is already in the
# address book. The user cannot add it again or else it will
# cause problems when updating and deleting the entry.
t = (addBMIfNotPresent(str(
self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())),)
t = (address,)
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
sql = '''select * from blacklist where address=?'''
else:
@ -2312,15 +2267,14 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetBlacklist.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(
self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8(), 'utf-8'))
newItem.setIcon(avatarize(address))
self.ui.tableWidgetBlacklist.setItem(0, 0, newItem)
newItem = QtGui.QTableWidgetItem(addBMIfNotPresent(
self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text()))
newItem = QtGui.QTableWidgetItem(address)
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetBlacklist.setItem(0, 1, newItem)
self.ui.tableWidgetBlacklist.setSortingEnabled(True)
t = (str(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8()), addBMIfNotPresent(
str(self.NewBlacklistDialogInstance.ui.lineEditSubscriptionAddress.text())), True)
t = (str(self.NewBlacklistDialogInstance.ui.newsubscriptionlabel.text().toUtf8()), address, True)
if shared.config.get('bitmessagesettings', 'blackwhitelist') == 'black':
sql = '''INSERT INTO blacklist VALUES (?,?,?)'''
else:
@ -2529,6 +2483,7 @@ class MyForm(QtGui.QMainWindow):
newItem = QtGui.QTableWidgetItem(
'--New entry. Change label in Address Book.--')
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem.setIcon(avatarize(addressAtCurrentInboxRow))
newItem = QtGui.QTableWidgetItem(addressAtCurrentInboxRow)
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
@ -2880,10 +2835,11 @@ class MyForm(QtGui.QMainWindow):
def on_action_SetAvatar(self, thisTableWidget):
# thisTableWidget = self.ui.tableWidgetYourIdentities
if not os.path.exists(shared.appdata + 'avatars/'):
os.makedirs(shared.appdata + 'avatars/')
currentRow = thisTableWidget.currentRow()
addressAtCurrentRow = thisTableWidget.item(
currentRow, 1).text()
import hashlib
hash = hashlib.md5(addBMIfNotPresent(addressAtCurrentRow)).hexdigest()
extensions = ['PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'MNG', 'PBM', 'PGM', 'PPM', 'TIFF', 'XBM', 'XPM', 'TGA']
# http://pyqt.sourceforge.net/Docs/PyQt4/qimagereader.html#supportedImageFormats
@ -2938,7 +2894,6 @@ class MyForm(QtGui.QMainWindow):
# set the icon
thisTableWidget.item(
currentRow, 0).setIcon(avatarize(addressAtCurrentRow))
shared.reloadBroadcastSendersForWhichImWatching()
self.rerenderSubscriptions()
self.rerenderComboBoxSendFrom()
self.rerenderInboxFromLabels()
@ -3001,6 +2956,7 @@ class MyForm(QtGui.QMainWindow):
if queryreturn != []:
for row in queryreturn:
messageText, = row
messageText = shared.fixPotentiallyInvalidUTF8Data(messageText)
messageText = unicode(messageText, 'utf-8)')
if len(messageText) > 30000:
messageText = (
@ -3090,7 +3046,6 @@ class MyForm(QtGui.QMainWindow):
self.ui.tableWidgetYourIdentities.setItem(
0, 0, newItem)
newItem = QtGui.QTableWidgetItem(address)
newItem.setIcon(identiconize(address))
newItem.setFlags(
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
if shared.safeConfigGetBoolean(address, 'chan'):
@ -3166,6 +3121,8 @@ class settingsDialog(QtGui.QDialog):
shared.config.getboolean('bitmessagesettings', 'startintray'))
self.ui.checkBoxWillinglySendToMobile.setChecked(
shared.safeConfigGetBoolean('bitmessagesettings', 'willinglysendtomobile'))
self.ui.checkBoxUseIdenticons.setChecked(
shared.safeConfigGetBoolean('bitmessagesettings', 'useidenticons'))
global languages
languages = ['system','en','eo','fr','de','es','ru','en_pirate','other']
@ -3176,18 +3133,6 @@ class settingsDialog(QtGui.QDialog):
curr_index = languages.index('other')
self.ui.languageComboBox.setCurrentIndex(curr_index)
self.ui.comboBoxIdenticonStyle.addItem(_translate("settingsDialog", "None"), "none")
self.ui.comboBoxIdenticonStyle.addItem(QIcon(":/newPrefix/images/qidenticon.png"), _translate("settingsDialog", "QIdenticon"), "qidenticon")
self.ui.comboBoxIdenticonStyle.addItem(QIcon(":/newPrefix/images/qidenticon_x.png"), _translate("settingsDialog", "QIdenticon (transparent)"), "qidenticon_x")
self.ui.comboBoxIdenticonStyle.addItem(QIcon(":/newPrefix/images/qidenticon_two.png"), _translate("settingsDialog", "QIdenticon bicolored"), "qidenticon_two")
self.ui.comboBoxIdenticonStyle.addItem(QIcon(":/newPrefix/images/qidenticon_two_x.png"), _translate("settingsDialog", "QIdenticon bicolored (transparent)"), "qidenticon_two_x")
curr_index = self.ui.comboBoxIdenticonStyle.findData(str(shared.config.get('bitmessagesettings', 'identicon')), Qt.UserRole)
self.ui.comboBoxIdenticonStyle.setCurrentIndex(curr_index)
self.ui.lineEditIdenticonSuffix.setText(
str(shared.config.get('bitmessagesettings', 'identiconsuffix')))
self.ui.checkBoxLoadAvatars.setChecked(
shared.safeConfigGetBoolean('bitmessagesettings', 'avatars'))
if shared.appdata == '':
self.ui.checkBoxPortableMode.setChecked(True)
if 'darwin' in sys.platform:
@ -3199,8 +3144,6 @@ class settingsDialog(QtGui.QDialog):
elif 'linux' in sys.platform:
self.ui.checkBoxStartOnLogon.setDisabled(True)
self.ui.checkBoxMinimizeToTray.setDisabled(True)
self.ui.labelSettingsNote.setText(_translate(
"MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implemented for your operating system."))
# On the Network settings tab:
self.ui.lineEditTCPPort.setText(str(
shared.config.get('bitmessagesettings', 'port')))

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'settings.ui'
#
# Created: Sat Sep 21 16:16:22 2013
# by: PyQt4 UI code generator 4.10.2
# Created: Fri Nov 1 19:14:45 2013
# by: PyQt4 UI code generator 4.10
#
# WARNING! All changes made in this file will be lost!
@ -26,7 +26,7 @@ except AttributeError:
class Ui_settingsDialog(object):
def setupUi(self, settingsDialog):
settingsDialog.setObjectName(_fromUtf8("settingsDialog"))
settingsDialog.resize(600, 407)
settingsDialog.resize(646, 473)
self.gridLayout = QtGui.QGridLayout(settingsDialog)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.buttonBox = QtGui.QDialogButtonBox(settingsDialog)
@ -39,12 +39,43 @@ class Ui_settingsDialog(object):
self.tabUserInterface = QtGui.QWidget()
self.tabUserInterface.setEnabled(True)
self.tabUserInterface.setObjectName(_fromUtf8("tabUserInterface"))
self.gridLayout_5 = QtGui.QGridLayout(self.tabUserInterface)
self.gridLayout_5.setObjectName(_fromUtf8("gridLayout_5"))
self.formLayout = QtGui.QFormLayout(self.tabUserInterface)
self.formLayout.setObjectName(_fromUtf8("formLayout"))
self.checkBoxStartOnLogon = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxStartOnLogon.setObjectName(_fromUtf8("checkBoxStartOnLogon"))
self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.checkBoxStartOnLogon)
self.checkBoxStartInTray = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxStartInTray.setObjectName(_fromUtf8("checkBoxStartInTray"))
self.formLayout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.checkBoxStartInTray)
self.checkBoxMinimizeToTray = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxMinimizeToTray.setChecked(True)
self.checkBoxMinimizeToTray.setObjectName(_fromUtf8("checkBoxMinimizeToTray"))
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.checkBoxMinimizeToTray)
self.checkBoxShowTrayNotifications = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxShowTrayNotifications.setObjectName(_fromUtf8("checkBoxShowTrayNotifications"))
self.formLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.checkBoxShowTrayNotifications)
self.checkBoxPortableMode = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxPortableMode.setObjectName(_fromUtf8("checkBoxPortableMode"))
self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.checkBoxPortableMode)
self.PortableModeDescription = QtGui.QLabel(self.tabUserInterface)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.PortableModeDescription.sizePolicy().hasHeightForWidth())
self.PortableModeDescription.setSizePolicy(sizePolicy)
self.PortableModeDescription.setWordWrap(True)
self.PortableModeDescription.setObjectName(_fromUtf8("PortableModeDescription"))
self.formLayout.setWidget(5, QtGui.QFormLayout.SpanningRole, self.PortableModeDescription)
self.checkBoxWillinglySendToMobile = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxWillinglySendToMobile.setObjectName(_fromUtf8("checkBoxWillinglySendToMobile"))
self.formLayout.setWidget(6, QtGui.QFormLayout.SpanningRole, self.checkBoxWillinglySendToMobile)
self.checkBoxUseIdenticons = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxUseIdenticons.setObjectName(_fromUtf8("checkBoxUseIdenticons"))
self.formLayout.setWidget(7, QtGui.QFormLayout.LabelRole, self.checkBoxUseIdenticons)
self.groupBox = QtGui.QGroupBox(self.tabUserInterface)
self.groupBox.setObjectName(_fromUtf8("groupBox"))
self.horizontalLayout_2 = QtGui.QHBoxLayout(self.groupBox)
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
self.formLayout_2 = QtGui.QFormLayout(self.groupBox)
self.formLayout_2.setObjectName(_fromUtf8("formLayout_2"))
self.languageComboBox = QtGui.QComboBox(self.groupBox)
self.languageComboBox.setMinimumSize(QtCore.QSize(100, 0))
self.languageComboBox.setObjectName(_fromUtf8("languageComboBox"))
@ -57,63 +88,8 @@ class Ui_settingsDialog(object):
self.languageComboBox.addItem(_fromUtf8(""))
self.languageComboBox.addItem(_fromUtf8(""))
self.languageComboBox.addItem(_fromUtf8(""))
self.horizontalLayout_2.addWidget(self.languageComboBox)
self.gridLayout_5.addWidget(self.groupBox, 7, 1, 4, 1)
self.checkBoxMinimizeToTray = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxMinimizeToTray.setChecked(True)
self.checkBoxMinimizeToTray.setObjectName(_fromUtf8("checkBoxMinimizeToTray"))
self.gridLayout_5.addWidget(self.checkBoxMinimizeToTray, 2, 0, 1, 1)
self.checkBoxStartOnLogon = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxStartOnLogon.setObjectName(_fromUtf8("checkBoxStartOnLogon"))
self.gridLayout_5.addWidget(self.checkBoxStartOnLogon, 0, 0, 1, 1)
self.checkBoxShowTrayNotifications = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxShowTrayNotifications.setObjectName(_fromUtf8("checkBoxShowTrayNotifications"))
self.gridLayout_5.addWidget(self.checkBoxShowTrayNotifications, 3, 0, 1, 1)
self.checkBoxPortableMode = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxPortableMode.setObjectName(_fromUtf8("checkBoxPortableMode"))
self.gridLayout_5.addWidget(self.checkBoxPortableMode, 4, 0, 1, 1)
self.checkBoxStartInTray = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxStartInTray.setObjectName(_fromUtf8("checkBoxStartInTray"))
self.gridLayout_5.addWidget(self.checkBoxStartInTray, 1, 0, 1, 1)
self.PortableModeDescription = QtGui.QLabel(self.tabUserInterface)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.PortableModeDescription.sizePolicy().hasHeightForWidth())
self.PortableModeDescription.setSizePolicy(sizePolicy)
self.PortableModeDescription.setWordWrap(True)
self.PortableModeDescription.setObjectName(_fromUtf8("PortableModeDescription"))
self.gridLayout_5.addWidget(self.PortableModeDescription, 5, 0, 1, 2)
self.checkBoxWillinglySendToMobile = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxWillinglySendToMobile.setObjectName(_fromUtf8("checkBoxWillinglySendToMobile"))
self.gridLayout_5.addWidget(self.checkBoxWillinglySendToMobile, 6, 0, 1, 2)
self.groupBox_3 = QtGui.QGroupBox(self.tabUserInterface)
self.groupBox_3.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.groupBox_3.setFlat(False)
self.groupBox_3.setCheckable(False)
self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
self.gridLayout_9 = QtGui.QGridLayout(self.groupBox_3)
self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9"))
self.checkBoxLoadAvatars = QtGui.QCheckBox(self.groupBox_3)
self.checkBoxLoadAvatars.setObjectName(_fromUtf8("checkBoxLoadAvatars"))
self.gridLayout_9.addWidget(self.checkBoxLoadAvatars, 1, 0, 1, 1)
self.lineEditIdenticonSuffix = QtGui.QLineEdit(self.groupBox_3)
self.lineEditIdenticonSuffix.setObjectName(_fromUtf8("lineEditIdenticonSuffix"))
self.gridLayout_9.addWidget(self.lineEditIdenticonSuffix, 1, 1, 1, 1)
self.comboBoxIdenticonStyle = QtGui.QComboBox(self.groupBox_3)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.comboBoxIdenticonStyle.sizePolicy().hasHeightForWidth())
self.comboBoxIdenticonStyle.setSizePolicy(sizePolicy)
self.comboBoxIdenticonStyle.setIconSize(QtCore.QSize(24, 24))
self.comboBoxIdenticonStyle.setObjectName(_fromUtf8("comboBoxIdenticonStyle"))
self.gridLayout_9.addWidget(self.comboBoxIdenticonStyle, 0, 0, 1, 2)
self.gridLayout_5.addWidget(self.groupBox_3, 7, 0, 5, 1)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_5.addItem(spacerItem, 12, 0, 1, 1)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_5.addItem(spacerItem1, 11, 1, 2, 1)
self.formLayout_2.setWidget(0, QtGui.QFormLayout.LabelRole, self.languageComboBox)
self.formLayout.setWidget(8, QtGui.QFormLayout.FieldRole, self.groupBox)
self.tabWidgetSettings.addTab(self.tabUserInterface, _fromUtf8(""))
self.tabNetworkSettings = QtGui.QWidget()
self.tabNetworkSettings.setObjectName(_fromUtf8("tabNetworkSettings"))
@ -123,8 +99,8 @@ class Ui_settingsDialog(object):
self.groupBox1.setObjectName(_fromUtf8("groupBox1"))
self.gridLayout_3 = QtGui.QGridLayout(self.groupBox1)
self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
spacerItem2 = QtGui.QSpacerItem(125, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_3.addItem(spacerItem2, 0, 0, 1, 1)
spacerItem = QtGui.QSpacerItem(125, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_3.addItem(spacerItem, 0, 0, 1, 1)
self.label = QtGui.QLabel(self.groupBox1)
self.label.setObjectName(_fromUtf8("label"))
self.gridLayout_3.addWidget(self.label, 0, 1, 1, 1)
@ -181,8 +157,8 @@ class Ui_settingsDialog(object):
self.comboBoxProxyType.addItem(_fromUtf8(""))
self.gridLayout_2.addWidget(self.comboBoxProxyType, 0, 1, 1, 1)
self.gridLayout_4.addWidget(self.groupBox_2, 1, 0, 1, 1)
spacerItem3 = QtGui.QSpacerItem(20, 70, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_4.addItem(spacerItem3, 2, 0, 1, 1)
spacerItem1 = QtGui.QSpacerItem(20, 70, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_4.addItem(spacerItem1, 2, 0, 1, 1)
self.tabWidgetSettings.addTab(self.tabNetworkSettings, _fromUtf8(""))
self.tab = QtGui.QWidget()
self.tab.setObjectName(_fromUtf8("tab"))
@ -192,8 +168,8 @@ class Ui_settingsDialog(object):
self.label_8.setWordWrap(True)
self.label_8.setObjectName(_fromUtf8("label_8"))
self.gridLayout_6.addWidget(self.label_8, 0, 0, 1, 3)
spacerItem4 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_6.addItem(spacerItem4, 1, 0, 1, 1)
spacerItem2 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_6.addItem(spacerItem2, 1, 0, 1, 1)
self.label_9 = QtGui.QLabel(self.tab)
self.label_9.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_9.setObjectName(_fromUtf8("label_9"))
@ -207,8 +183,8 @@ class Ui_settingsDialog(object):
self.lineEditTotalDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
self.lineEditTotalDifficulty.setObjectName(_fromUtf8("lineEditTotalDifficulty"))
self.gridLayout_6.addWidget(self.lineEditTotalDifficulty, 1, 2, 1, 1)
spacerItem5 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_6.addItem(spacerItem5, 3, 0, 1, 1)
spacerItem3 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_6.addItem(spacerItem3, 3, 0, 1, 1)
self.label_11 = QtGui.QLabel(self.tab)
self.label_11.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_11.setObjectName(_fromUtf8("label_11"))
@ -239,8 +215,8 @@ class Ui_settingsDialog(object):
self.label_15.setWordWrap(True)
self.label_15.setObjectName(_fromUtf8("label_15"))
self.gridLayout_7.addWidget(self.label_15, 0, 0, 1, 3)
spacerItem6 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_7.addItem(spacerItem6, 1, 0, 1, 1)
spacerItem4 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_7.addItem(spacerItem4, 1, 0, 1, 1)
self.label_13 = QtGui.QLabel(self.tab_2)
self.label_13.setLayoutDirection(QtCore.Qt.LeftToRight)
self.label_13.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
@ -255,8 +231,8 @@ class Ui_settingsDialog(object):
self.lineEditMaxAcceptableTotalDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
self.lineEditMaxAcceptableTotalDifficulty.setObjectName(_fromUtf8("lineEditMaxAcceptableTotalDifficulty"))
self.gridLayout_7.addWidget(self.lineEditMaxAcceptableTotalDifficulty, 1, 2, 1, 1)
spacerItem7 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_7.addItem(spacerItem7, 2, 0, 1, 1)
spacerItem5 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_7.addItem(spacerItem5, 2, 0, 1, 1)
self.label_14 = QtGui.QLabel(self.tab_2)
self.label_14.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_14.setObjectName(_fromUtf8("label_14"))
@ -270,15 +246,15 @@ class Ui_settingsDialog(object):
self.lineEditMaxAcceptableSmallMessageDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
self.lineEditMaxAcceptableSmallMessageDifficulty.setObjectName(_fromUtf8("lineEditMaxAcceptableSmallMessageDifficulty"))
self.gridLayout_7.addWidget(self.lineEditMaxAcceptableSmallMessageDifficulty, 2, 2, 1, 1)
spacerItem8 = QtGui.QSpacerItem(20, 147, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_7.addItem(spacerItem8, 3, 1, 1, 1)
spacerItem6 = QtGui.QSpacerItem(20, 147, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_7.addItem(spacerItem6, 3, 1, 1, 1)
self.tabWidgetSettings.addTab(self.tab_2, _fromUtf8(""))
self.tabNamecoin = QtGui.QWidget()
self.tabNamecoin.setObjectName(_fromUtf8("tabNamecoin"))
self.gridLayout_8 = QtGui.QGridLayout(self.tabNamecoin)
self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8"))
spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem9, 2, 0, 1, 1)
spacerItem7 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem7, 2, 0, 1, 1)
self.label_16 = QtGui.QLabel(self.tabNamecoin)
self.label_16.setWordWrap(True)
self.label_16.setObjectName(_fromUtf8("label_16"))
@ -290,10 +266,10 @@ class Ui_settingsDialog(object):
self.lineEditNamecoinHost = QtGui.QLineEdit(self.tabNamecoin)
self.lineEditNamecoinHost.setObjectName(_fromUtf8("lineEditNamecoinHost"))
self.gridLayout_8.addWidget(self.lineEditNamecoinHost, 2, 2, 1, 1)
spacerItem10 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem10, 3, 0, 1, 1)
spacerItem11 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem11, 4, 0, 1, 1)
spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem8, 3, 0, 1, 1)
spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem9, 4, 0, 1, 1)
self.label_18 = QtGui.QLabel(self.tabNamecoin)
self.label_18.setEnabled(True)
self.label_18.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
@ -302,8 +278,8 @@ class Ui_settingsDialog(object):
self.lineEditNamecoinPort = QtGui.QLineEdit(self.tabNamecoin)
self.lineEditNamecoinPort.setObjectName(_fromUtf8("lineEditNamecoinPort"))
self.gridLayout_8.addWidget(self.lineEditNamecoinPort, 3, 2, 1, 1)
spacerItem12 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_8.addItem(spacerItem12, 8, 1, 1, 1)
spacerItem10 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_8.addItem(spacerItem10, 8, 1, 1, 1)
self.labelNamecoinUser = QtGui.QLabel(self.tabNamecoin)
self.labelNamecoinUser.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.labelNamecoinUser.setObjectName(_fromUtf8("labelNamecoinUser"))
@ -311,8 +287,8 @@ class Ui_settingsDialog(object):
self.lineEditNamecoinUser = QtGui.QLineEdit(self.tabNamecoin)
self.lineEditNamecoinUser.setObjectName(_fromUtf8("lineEditNamecoinUser"))
self.gridLayout_8.addWidget(self.lineEditNamecoinUser, 4, 2, 1, 1)
spacerItem13 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem13, 5, 0, 1, 1)
spacerItem11 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem11, 5, 0, 1, 1)
self.labelNamecoinPassword = QtGui.QLabel(self.tabNamecoin)
self.labelNamecoinPassword.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.labelNamecoinPassword.setObjectName(_fromUtf8("labelNamecoinPassword"))
@ -354,8 +330,7 @@ class Ui_settingsDialog(object):
settingsDialog.setTabOrder(self.tabWidgetSettings, self.checkBoxStartOnLogon)
settingsDialog.setTabOrder(self.checkBoxStartOnLogon, self.checkBoxStartInTray)
settingsDialog.setTabOrder(self.checkBoxStartInTray, self.checkBoxMinimizeToTray)
settingsDialog.setTabOrder(self.checkBoxMinimizeToTray, self.checkBoxShowTrayNotifications)
settingsDialog.setTabOrder(self.checkBoxShowTrayNotifications, self.lineEditTCPPort)
settingsDialog.setTabOrder(self.checkBoxMinimizeToTray, self.lineEditTCPPort)
settingsDialog.setTabOrder(self.lineEditTCPPort, self.comboBoxProxyType)
settingsDialog.setTabOrder(self.comboBoxProxyType, self.lineEditSocksHostname)
settingsDialog.setTabOrder(self.lineEditSocksHostname, self.lineEditSocksPort)
@ -367,6 +342,14 @@ class Ui_settingsDialog(object):
def retranslateUi(self, settingsDialog):
settingsDialog.setWindowTitle(_translate("settingsDialog", "Settings", None))
self.checkBoxStartOnLogon.setText(_translate("settingsDialog", "Start Bitmessage on user login", None))
self.checkBoxStartInTray.setText(_translate("settingsDialog", "Start Bitmessage in the tray (don\'t show main window)", None))
self.checkBoxMinimizeToTray.setText(_translate("settingsDialog", "Minimize to tray", None))
self.checkBoxShowTrayNotifications.setText(_translate("settingsDialog", "Show notification when message received", None))
self.checkBoxPortableMode.setText(_translate("settingsDialog", "Run in Portable Mode", None))
self.PortableModeDescription.setText(_translate("settingsDialog", "In Portable Mode, messages and config files are stored in the same directory as the program rather than the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.", None))
self.checkBoxWillinglySendToMobile.setText(_translate("settingsDialog", "Willingly include unencrypted destination address when sending to a mobile device", None))
self.checkBoxUseIdenticons.setText(_translate("settingsDialog", "Use Identicons", None))
self.groupBox.setTitle(_translate("settingsDialog", "Interface Language", None))
self.languageComboBox.setItemText(0, _translate("settingsDialog", "System Settings", "system"))
self.languageComboBox.setItemText(1, _translate("settingsDialog", "English", "en"))
@ -377,16 +360,6 @@ class Ui_settingsDialog(object):
self.languageComboBox.setItemText(6, _translate("settingsDialog", "русский язык", "ru"))
self.languageComboBox.setItemText(7, _translate("settingsDialog", "Pirate English", "en_pirate"))
self.languageComboBox.setItemText(8, _translate("settingsDialog", "Other (set in keys.dat)", "other"))
self.checkBoxMinimizeToTray.setText(_translate("settingsDialog", "Minimize to tray", None))
self.checkBoxStartOnLogon.setText(_translate("settingsDialog", "Start Bitmessage on user login", None))
self.checkBoxShowTrayNotifications.setText(_translate("settingsDialog", "Show notification when message received", None))
self.checkBoxPortableMode.setText(_translate("settingsDialog", "Run in Portable Mode", None))
self.checkBoxStartInTray.setText(_translate("settingsDialog", "Start Bitmessage in the tray (don\'t show main window)", None))
self.PortableModeDescription.setText(_translate("settingsDialog", "In Portable Mode, messages and config files are stored in the same directory as the program rather than the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.", None))
self.checkBoxWillinglySendToMobile.setText(_translate("settingsDialog", "Willingly include unencrypted destination address when sending to a mobile device", None))
self.groupBox_3.setTitle(_translate("settingsDialog", "Identicons (with example image)", None))
self.checkBoxLoadAvatars.setText(_translate("settingsDialog", "Load avatar images", None))
self.lineEditIdenticonSuffix.setToolTip(_translate("settingsDialog", "<html><head/><body><p>The content of this text field will be appended to the BM-address before creating the hash for the identicons. By default it is filled with a random string to make the identicons in your client unique, otherwise the identicon could be an attack vector if an adversary creates an address resulting in a similar identicon. If you keep this string (or any other random or non-random string) you will be able to keep the same identicons.</p></body></html>", None))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), _translate("settingsDialog", "User Interface", None))
self.groupBox1.setTitle(_translate("settingsDialog", "Listening port", None))
self.label.setText(_translate("settingsDialog", "Listen for connections on port:", None))
@ -424,13 +397,3 @@ class Ui_settingsDialog(object):
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNamecoin), _translate("settingsDialog", "Namecoin integration", None))
import bitmessage_icons_rc
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
settingsDialog = QtGui.QDialog()
ui = Ui_settingsDialog()
ui.setupUi(settingsDialog)
settingsDialog.show()
sys.exit(app.exec_())

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>407</height>
<width>646</width>
<height>473</height>
</rect>
</property>
<property name="windowTitle">
@ -36,14 +36,82 @@
<attribute name="title">
<string>User Interface</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="7" column="1" rowspan="4">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxStartOnLogon">
<property name="text">
<string>Start Bitmessage on user login</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxStartInTray">
<property name="text">
<string>Start Bitmessage in the tray (don't show main window)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxMinimizeToTray">
<property name="text">
<string>Minimize to tray</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxShowTrayNotifications">
<property name="text">
<string>Show notification when message received</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBoxPortableMode">
<property name="text">
<string>Run in Portable Mode</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="PortableModeDescription">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>In Portable Mode, messages and config files are stored in the same directory as the program rather than the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxWillinglySendToMobile">
<property name="text">
<string>Willingly include unencrypted destination address when sending to a mobile device</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="checkBoxUseIdenticons">
<property name="text">
<string>Use Identicons</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Interface Language</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QComboBox" name="languageComboBox">
<property name="minimumSize">
<size>
@ -101,141 +169,6 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxMinimizeToTray">
<property name="text">
<string>Minimize to tray</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxStartOnLogon">
<property name="text">
<string>Start Bitmessage on user login</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxShowTrayNotifications">
<property name="text">
<string>Show notification when message received</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="checkBoxPortableMode">
<property name="text">
<string>Run in Portable Mode</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxStartInTray">
<property name="text">
<string>Start Bitmessage in the tray (don't show main window)</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="PortableModeDescription">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>In Portable Mode, messages and config files are stored in the same directory as the program rather than the normal application-data folder. This makes it convenient to run Bitmessage from a USB thumb drive.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxWillinglySendToMobile">
<property name="text">
<string>Willingly include unencrypted destination address when sending to a mobile device</string>
</property>
</widget>
</item>
<item row="7" column="0" rowspan="5">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Identicons (with example image)</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxLoadAvatars">
<property name="text">
<string>Load avatar images</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEditIdenticonSuffix">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The content of this text field will be appended to the BM-address before creating the hash for the identicons. By default it is filled with a random string to make the identicons in your client unique, otherwise the identicon could be an attack vector if an adversary creates an address resulting in a similar identicon. If you keep this string (or any other random or non-random string) you will be able to keep the same identicons.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QComboBox" name="comboBoxIdenticonStyle">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="12" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="11" column="1" rowspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabNetworkSettings">
@ -818,7 +751,6 @@
<tabstop>checkBoxStartOnLogon</tabstop>
<tabstop>checkBoxStartInTray</tabstop>
<tabstop>checkBoxMinimizeToTray</tabstop>
<tabstop>checkBoxShowTrayNotifications</tabstop>
<tabstop>lineEditTCPPort</tabstop>
<tabstop>comboBoxProxyType</tabstop>
<tabstop>lineEditSocksHostname</tabstop>

View File

@ -7,6 +7,8 @@ import sys
import os
from debug import logger
from namecoin import ensureNamecoinOptions
import random
import string
import tr#anslate
# This thread exists because SQLITE3 is so un-threadsafe that we must
@ -242,13 +244,6 @@ class sqlThread(threading.Thread):
if not shared.config.has_option('bitmessagesettings', 'userlocale'):
shared.config.set('bitmessagesettings', 'userlocale', 'system')
if not shared.config.has_option('bitmessagesettings', 'identicon'):
shared.config.set('bitmessagesettings', 'identicon', 'None')
if not shared.config.has_option('bitmessagesettings', 'identiconsuffix'):
import random, string
shared.config.set('bitmessagesettings', 'identiconsuffix', ''.join(random.choice("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") for x in range(12))) # a twelve character pseudo-password to salt the identicons
if not shared.config.has_option('bitmessagesettings', 'avatars'):
shared.config.set('bitmessagesettings', 'avatars', 'false')
if not shared.config.has_option('bitmessagesettings', 'sendoutgoingconnections'):
shared.config.set('bitmessagesettings', 'sendoutgoingconnections', 'True')
@ -276,6 +271,13 @@ class sqlThread(threading.Thread):
parameters = (5,)
self.cur.execute(item, parameters)
if not shared.config.has_option('bitmessagesettings', 'useidenticons'):
shared.config.set('bitmessagesettings', 'useidenticons', 'True')
if not shared.config.has_option('bitmessagesettings', 'identiconsuffix'): # acts as a salt
shared.config.set('bitmessagesettings', 'identiconsuffix', ''.join(random.choice("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") for x in range(12))) # a twelve character pseudo-password to salt the identicons
with open(shared.appdata + 'keys.dat', 'wb') as configfile:
shared.config.write(configfile)
# Are you hoping to add a new option to the keys.dat file of existing
# Bitmessage users? Add it right above this line!

View File

@ -3,6 +3,8 @@ import ConfigParser
import sys
import os
import locale
import random
import string
from namecoin import ensureNamecoinOptions
@ -84,10 +86,8 @@ def loadConfig():
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', '0')
shared.config.set('bitmessagesettings', 'dontconnect', 'true')
shared.config.set('bitmessagesettings', 'userlocale', 'system')
shared.config.set('bitmessagesettings', 'identicon', 'None')
import random, string
shared.config.set('bitmessagesettings', 'useidenticons', 'True')
shared.config.set('bitmessagesettings', 'identiconsuffix', ''.join(random.choice("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz") for x in range(12))) # a twelve character pseudo-password to salt the identicons
shared.config.set('bitmessagesettings', 'avatars', 'false')
# Are you hoping to add a new option to the keys.dat file? You're in
# the right place for adding it to users who install the software for