nonfunctional identicon settings-GUI

This commit is contained in:
sendiulo 2013-09-18 17:39:45 +02:00
parent 0959c9c07c
commit 86485a9b09
6 changed files with 222 additions and 65 deletions

View File

@ -56,7 +56,7 @@ def _translate(context, text):
return QtGui.QApplication.translate(context, text) return QtGui.QApplication.translate(context, text)
def identiconize(address): def identiconize(address):
size = 1 size = 48
str_broadcast_subscribers = '[Broadcast subscribers]' str_broadcast_subscribers = '[Broadcast subscribers]'
if address == str_broadcast_subscribers: if address == str_broadcast_subscribers:
@ -71,11 +71,15 @@ def identiconize(address):
# Attacks where someone creates an address to mimic someone else's identicon should be impossible then # Attacks where someone creates an address to mimic someone else's identicon should be impossible then
# i think it should generate a random string by default # i think it should generate a random string by default
# If you include another identicon library, please generate an
# example identicon with the following md5 hash:
# 3fd4bf901b9d4ea1394f0fb358725b28
try: try:
identicon_lib = shared.config.get('bitmessagesettings', 'identicon') identicon_lib = shared.config.get('bitmessagesettings', 'identicon')
except: except:
identicon_lib = 'qidenticon' # default to no identicons
identicon_lib = False
if (identicon_lib[:len('qidenticon')] == 'qidenticon'): if (identicon_lib[:len('qidenticon')] == 'qidenticon'):
# print identicon_lib # print identicon_lib
@ -87,11 +91,13 @@ def identiconize(address):
import hashlib import hashlib
hash = hashlib.md5(addBMIfNotPresent(address)+identiconsuffix).hexdigest() hash = hashlib.md5(addBMIfNotPresent(address)+identiconsuffix).hexdigest()
use_two_colors = (identicon_lib[:len('qidenticon_two')] == 'qidenticon_two') use_two_colors = (identicon_lib[:len('qidenticon_two')] == 'qidenticon_two')
transparent = (identicon_lib == 'qidenticon_x') | (identicon_lib == 'qidenticon_two_x') opacity = int(not((identicon_lib == 'qidenticon_x') | (identicon_lib == 'qidenticon_two_x') | (identicon_lib == 'qidenticon_b') | (identicon_lib == 'qidenticon_two_b')))*255
penwidth = 0 penwidth = 0
pixmap = qidenticon.render_identicon(int(hash, 16), 48, use_two_colors, transparent, penwidth) image = qidenticon.render_identicon(int(hash, 16), size, use_two_colors, opacity, penwidth)
idcon = QtGui.QIcon() # filename = './images/identicons/'+hash+'.png'
idcon.addPixmap(pixmap, QtGui.QIcon.Normal, QtGui.QIcon.Off) # image.save(filename)
idcon = QIcon()
idcon.addPixmap(image, QtGui.QIcon.Normal, QtGui.QIcon.Off)
return idcon return idcon
elif identicon_lib == 'pydenticon': elif identicon_lib == 'pydenticon':
# print identicon_lib # print identicon_lib
@ -101,7 +107,7 @@ def identiconize(address):
# GPLv3 is a copyleft license that would influence our licensing # GPLv3 is a copyleft license that would influence our licensing
# Find the source here: http://boottunes.googlecode.com/svn-history/r302/trunk/src/pydenticon.py # Find the source here: http://boottunes.googlecode.com/svn-history/r302/trunk/src/pydenticon.py
# note that it requires PIL to be installed: http://www.pythonware.com/products/pil/ # note that it requires PIL to be installed: http://www.pythonware.com/products/pil/
idcon_render = Pydenticon(addBMIfNotPresent(address)+identiconsuffix, size) idcon_render = Pydenticon(addBMIfNotPresent(address)+identiconsuffix, size*3)
rendering = idcon_render._render() rendering = idcon_render._render()
data = rendering.convert("RGBA").tostring("raw", "RGBA") data = rendering.convert("RGBA").tostring("raw", "RGBA")
qim = QImage(data, size, size, QImage.Format_ARGB32) qim = QImage(data, size, size, QImage.Format_ARGB32)
@ -116,6 +122,7 @@ def identiconize(address):
if identicon_lib & len(identicon_lib) > 0: if identicon_lib & len(identicon_lib) > 0:
print 'Error: couldn\'t find this identicon library: ', identicon_lib print 'Error: couldn\'t find this identicon library: ', identicon_lib
print 'Control for typos!' print 'Control for typos!'
# default to no identicons
idcon = QtGui.QIcon() idcon = QtGui.QIcon()
return idcon return idcon

View File

@ -1,5 +1,10 @@
<RCC> <RCC>
<qresource prefix="newPrefix"> <qresource prefix="newPrefix">
<file>../images/no_identicons.png</file>
<file>../images/qidenticon_x.png</file>
<file>../images/qidenticon.png</file>
<file>../images/qidenticon_two.png</file>
<file>../images/qidenticon_two_x.png</file>
<file>../images/can-icon-24px-yellow.png</file> <file>../images/can-icon-24px-yellow.png</file>
<file>../images/can-icon-24px-red.png</file> <file>../images/can-icon-24px-red.png</file>
<file>../images/can-icon-24px-green.png</file> <file>../images/can-icon-24px-green.png</file>

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: Mon Aug 12 00:08:20 2013 # Created: Wed Sep 18 17:38:54 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!
@ -630,3 +630,13 @@ class Ui_MainWindow(object):
self.actionJoinChan.setText(_translate("MainWindow", "Join / Create chan", None)) self.actionJoinChan.setText(_translate("MainWindow", "Join / Create chan", None))
import bitmessage_icons_rc import bitmessage_icons_rc
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())

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: Sun Aug 25 18:09:38 2013 # Created: Wed Sep 18 17:38:55 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!
@ -45,8 +45,6 @@ class Ui_settingsDialog(object):
self.checkBoxMinimizeToTray.setChecked(True) self.checkBoxMinimizeToTray.setChecked(True)
self.checkBoxMinimizeToTray.setObjectName(_fromUtf8("checkBoxMinimizeToTray")) self.checkBoxMinimizeToTray.setObjectName(_fromUtf8("checkBoxMinimizeToTray"))
self.gridLayout_5.addWidget(self.checkBoxMinimizeToTray, 2, 0, 1, 1) self.gridLayout_5.addWidget(self.checkBoxMinimizeToTray, 2, 0, 1, 1)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_5.addItem(spacerItem, 10, 0, 1, 1)
self.checkBoxStartOnLogon = QtGui.QCheckBox(self.tabUserInterface) self.checkBoxStartOnLogon = QtGui.QCheckBox(self.tabUserInterface)
self.checkBoxStartOnLogon.setObjectName(_fromUtf8("checkBoxStartOnLogon")) self.checkBoxStartOnLogon.setObjectName(_fromUtf8("checkBoxStartOnLogon"))
self.gridLayout_5.addWidget(self.checkBoxStartOnLogon, 0, 0, 1, 1) self.gridLayout_5.addWidget(self.checkBoxStartOnLogon, 0, 0, 1, 1)
@ -82,7 +80,35 @@ class Ui_settingsDialog(object):
self.languageComboBox.addItem(_fromUtf8("")) self.languageComboBox.addItem(_fromUtf8(""))
self.languageComboBox.addItem(_fromUtf8("")) self.languageComboBox.addItem(_fromUtf8(""))
self.horizontalLayout_2.addWidget(self.languageComboBox) self.horizontalLayout_2.addWidget(self.languageComboBox)
self.gridLayout_5.addWidget(self.groupBox, 10, 1, 1, 1) self.gridLayout_5.addWidget(self.groupBox, 7, 1, 4, 1)
self.groupBox_3 = QtGui.QGroupBox(self.tabUserInterface)
self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
self.comboBox = QtGui.QComboBox(self.groupBox_3)
self.comboBox.setGeometry(QtCore.QRect(20, 20, 251, 31))
self.comboBox.setIconSize(QtCore.QSize(24, 24))
self.comboBox.setObjectName(_fromUtf8("comboBox"))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/no_identicons.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.comboBox.addItem(icon, _fromUtf8(""))
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/qidenticon.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.comboBox.addItem(icon1, _fromUtf8(""))
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/qidenticon_x.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.comboBox.addItem(icon2, _fromUtf8(""))
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/qidenticon_two.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.comboBox.addItem(icon3, _fromUtf8(""))
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/qidenticon_two_x.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.comboBox.addItem(icon4, _fromUtf8(""))
self.checkBoxLoadAvatars = QtGui.QCheckBox(self.groupBox_3)
self.checkBoxLoadAvatars.setGeometry(QtCore.QRect(20, 50, 121, 18))
self.checkBoxLoadAvatars.setObjectName(_fromUtf8("checkBoxLoadAvatars"))
self.lineEdit = QtGui.QLineEdit(self.groupBox_3)
self.lineEdit.setGeometry(QtCore.QRect(140, 50, 131, 16))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.gridLayout_5.addWidget(self.groupBox_3, 7, 0, 4, 1)
self.tabWidgetSettings.addTab(self.tabUserInterface, _fromUtf8("")) self.tabWidgetSettings.addTab(self.tabUserInterface, _fromUtf8(""))
self.tabNetworkSettings = QtGui.QWidget() self.tabNetworkSettings = QtGui.QWidget()
self.tabNetworkSettings.setObjectName(_fromUtf8("tabNetworkSettings")) self.tabNetworkSettings.setObjectName(_fromUtf8("tabNetworkSettings"))
@ -92,8 +118,8 @@ class Ui_settingsDialog(object):
self.groupBox1.setObjectName(_fromUtf8("groupBox1")) self.groupBox1.setObjectName(_fromUtf8("groupBox1"))
self.gridLayout_3 = QtGui.QGridLayout(self.groupBox1) self.gridLayout_3 = QtGui.QGridLayout(self.groupBox1)
self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3")) self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
spacerItem1 = QtGui.QSpacerItem(125, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) spacerItem = QtGui.QSpacerItem(125, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_3.addItem(spacerItem1, 0, 0, 1, 1) self.gridLayout_3.addItem(spacerItem, 0, 0, 1, 1)
self.label = QtGui.QLabel(self.groupBox1) self.label = QtGui.QLabel(self.groupBox1)
self.label.setObjectName(_fromUtf8("label")) self.label.setObjectName(_fromUtf8("label"))
self.gridLayout_3.addWidget(self.label, 0, 1, 1, 1) self.gridLayout_3.addWidget(self.label, 0, 1, 1, 1)
@ -150,8 +176,8 @@ class Ui_settingsDialog(object):
self.checkBoxSocksListen.setObjectName(_fromUtf8("checkBoxSocksListen")) self.checkBoxSocksListen.setObjectName(_fromUtf8("checkBoxSocksListen"))
self.gridLayout_2.addWidget(self.checkBoxSocksListen, 3, 1, 1, 4) self.gridLayout_2.addWidget(self.checkBoxSocksListen, 3, 1, 1, 4)
self.gridLayout_4.addWidget(self.groupBox_2, 1, 0, 1, 1) self.gridLayout_4.addWidget(self.groupBox_2, 1, 0, 1, 1)
spacerItem2 = QtGui.QSpacerItem(20, 70, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) spacerItem1 = QtGui.QSpacerItem(20, 70, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_4.addItem(spacerItem2, 2, 0, 1, 1) self.gridLayout_4.addItem(spacerItem1, 2, 0, 1, 1)
self.tabWidgetSettings.addTab(self.tabNetworkSettings, _fromUtf8("")) self.tabWidgetSettings.addTab(self.tabNetworkSettings, _fromUtf8(""))
self.tab = QtGui.QWidget() self.tab = QtGui.QWidget()
self.tab.setObjectName(_fromUtf8("tab")) self.tab.setObjectName(_fromUtf8("tab"))
@ -161,8 +187,8 @@ class Ui_settingsDialog(object):
self.label_8.setWordWrap(True) self.label_8.setWordWrap(True)
self.label_8.setObjectName(_fromUtf8("label_8")) self.label_8.setObjectName(_fromUtf8("label_8"))
self.gridLayout_6.addWidget(self.label_8, 0, 0, 1, 3) self.gridLayout_6.addWidget(self.label_8, 0, 0, 1, 3)
spacerItem3 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) spacerItem2 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_6.addItem(spacerItem3, 1, 0, 1, 1) self.gridLayout_6.addItem(spacerItem2, 1, 0, 1, 1)
self.label_9 = QtGui.QLabel(self.tab) self.label_9 = QtGui.QLabel(self.tab)
self.label_9.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.label_9.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_9.setObjectName(_fromUtf8("label_9")) self.label_9.setObjectName(_fromUtf8("label_9"))
@ -176,8 +202,8 @@ class Ui_settingsDialog(object):
self.lineEditTotalDifficulty.setMaximumSize(QtCore.QSize(70, 16777215)) self.lineEditTotalDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
self.lineEditTotalDifficulty.setObjectName(_fromUtf8("lineEditTotalDifficulty")) self.lineEditTotalDifficulty.setObjectName(_fromUtf8("lineEditTotalDifficulty"))
self.gridLayout_6.addWidget(self.lineEditTotalDifficulty, 1, 2, 1, 1) self.gridLayout_6.addWidget(self.lineEditTotalDifficulty, 1, 2, 1, 1)
spacerItem4 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) spacerItem3 = QtGui.QSpacerItem(203, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_6.addItem(spacerItem4, 3, 0, 1, 1) self.gridLayout_6.addItem(spacerItem3, 3, 0, 1, 1)
self.label_11 = QtGui.QLabel(self.tab) self.label_11 = QtGui.QLabel(self.tab)
self.label_11.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.label_11.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_11.setObjectName(_fromUtf8("label_11")) self.label_11.setObjectName(_fromUtf8("label_11"))
@ -208,8 +234,8 @@ class Ui_settingsDialog(object):
self.label_15.setWordWrap(True) self.label_15.setWordWrap(True)
self.label_15.setObjectName(_fromUtf8("label_15")) self.label_15.setObjectName(_fromUtf8("label_15"))
self.gridLayout_7.addWidget(self.label_15, 0, 0, 1, 3) self.gridLayout_7.addWidget(self.label_15, 0, 0, 1, 3)
spacerItem5 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) spacerItem4 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_7.addItem(spacerItem5, 1, 0, 1, 1) self.gridLayout_7.addItem(spacerItem4, 1, 0, 1, 1)
self.label_13 = QtGui.QLabel(self.tab_2) self.label_13 = QtGui.QLabel(self.tab_2)
self.label_13.setLayoutDirection(QtCore.Qt.LeftToRight) self.label_13.setLayoutDirection(QtCore.Qt.LeftToRight)
self.label_13.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.label_13.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
@ -224,8 +250,8 @@ class Ui_settingsDialog(object):
self.lineEditMaxAcceptableTotalDifficulty.setMaximumSize(QtCore.QSize(70, 16777215)) self.lineEditMaxAcceptableTotalDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
self.lineEditMaxAcceptableTotalDifficulty.setObjectName(_fromUtf8("lineEditMaxAcceptableTotalDifficulty")) self.lineEditMaxAcceptableTotalDifficulty.setObjectName(_fromUtf8("lineEditMaxAcceptableTotalDifficulty"))
self.gridLayout_7.addWidget(self.lineEditMaxAcceptableTotalDifficulty, 1, 2, 1, 1) self.gridLayout_7.addWidget(self.lineEditMaxAcceptableTotalDifficulty, 1, 2, 1, 1)
spacerItem6 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) spacerItem5 = QtGui.QSpacerItem(102, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_7.addItem(spacerItem6, 2, 0, 1, 1) self.gridLayout_7.addItem(spacerItem5, 2, 0, 1, 1)
self.label_14 = QtGui.QLabel(self.tab_2) self.label_14 = QtGui.QLabel(self.tab_2)
self.label_14.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.label_14.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_14.setObjectName(_fromUtf8("label_14")) self.label_14.setObjectName(_fromUtf8("label_14"))
@ -239,15 +265,15 @@ class Ui_settingsDialog(object):
self.lineEditMaxAcceptableSmallMessageDifficulty.setMaximumSize(QtCore.QSize(70, 16777215)) self.lineEditMaxAcceptableSmallMessageDifficulty.setMaximumSize(QtCore.QSize(70, 16777215))
self.lineEditMaxAcceptableSmallMessageDifficulty.setObjectName(_fromUtf8("lineEditMaxAcceptableSmallMessageDifficulty")) self.lineEditMaxAcceptableSmallMessageDifficulty.setObjectName(_fromUtf8("lineEditMaxAcceptableSmallMessageDifficulty"))
self.gridLayout_7.addWidget(self.lineEditMaxAcceptableSmallMessageDifficulty, 2, 2, 1, 1) self.gridLayout_7.addWidget(self.lineEditMaxAcceptableSmallMessageDifficulty, 2, 2, 1, 1)
spacerItem7 = QtGui.QSpacerItem(20, 147, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) spacerItem6 = QtGui.QSpacerItem(20, 147, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_7.addItem(spacerItem7, 3, 1, 1, 1) self.gridLayout_7.addItem(spacerItem6, 3, 1, 1, 1)
self.tabWidgetSettings.addTab(self.tab_2, _fromUtf8("")) self.tabWidgetSettings.addTab(self.tab_2, _fromUtf8(""))
self.tabNamecoin = QtGui.QWidget() self.tabNamecoin = QtGui.QWidget()
self.tabNamecoin.setObjectName(_fromUtf8("tabNamecoin")) self.tabNamecoin.setObjectName(_fromUtf8("tabNamecoin"))
self.gridLayout_8 = QtGui.QGridLayout(self.tabNamecoin) self.gridLayout_8 = QtGui.QGridLayout(self.tabNamecoin)
self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8")) self.gridLayout_8.setObjectName(_fromUtf8("gridLayout_8"))
spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) spacerItem7 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem8, 2, 0, 1, 1) self.gridLayout_8.addItem(spacerItem7, 2, 0, 1, 1)
self.label_16 = QtGui.QLabel(self.tabNamecoin) self.label_16 = QtGui.QLabel(self.tabNamecoin)
self.label_16.setWordWrap(True) self.label_16.setWordWrap(True)
self.label_16.setObjectName(_fromUtf8("label_16")) self.label_16.setObjectName(_fromUtf8("label_16"))
@ -259,10 +285,10 @@ class Ui_settingsDialog(object):
self.lineEditNamecoinHost = QtGui.QLineEdit(self.tabNamecoin) self.lineEditNamecoinHost = QtGui.QLineEdit(self.tabNamecoin)
self.lineEditNamecoinHost.setObjectName(_fromUtf8("lineEditNamecoinHost")) self.lineEditNamecoinHost.setObjectName(_fromUtf8("lineEditNamecoinHost"))
self.gridLayout_8.addWidget(self.lineEditNamecoinHost, 2, 2, 1, 1) self.gridLayout_8.addWidget(self.lineEditNamecoinHost, 2, 2, 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) spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem9, 3, 0, 1, 1) self.gridLayout_8.addItem(spacerItem9, 4, 0, 1, 1)
spacerItem10 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem10, 4, 0, 1, 1)
self.label_18 = QtGui.QLabel(self.tabNamecoin) self.label_18 = QtGui.QLabel(self.tabNamecoin)
self.label_18.setEnabled(True) self.label_18.setEnabled(True)
self.label_18.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.label_18.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
@ -271,8 +297,8 @@ class Ui_settingsDialog(object):
self.lineEditNamecoinPort = QtGui.QLineEdit(self.tabNamecoin) self.lineEditNamecoinPort = QtGui.QLineEdit(self.tabNamecoin)
self.lineEditNamecoinPort.setObjectName(_fromUtf8("lineEditNamecoinPort")) self.lineEditNamecoinPort.setObjectName(_fromUtf8("lineEditNamecoinPort"))
self.gridLayout_8.addWidget(self.lineEditNamecoinPort, 3, 2, 1, 1) self.gridLayout_8.addWidget(self.lineEditNamecoinPort, 3, 2, 1, 1)
spacerItem11 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) spacerItem10 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_8.addItem(spacerItem11, 8, 1, 1, 1) self.gridLayout_8.addItem(spacerItem10, 8, 1, 1, 1)
self.labelNamecoinUser = QtGui.QLabel(self.tabNamecoin) self.labelNamecoinUser = QtGui.QLabel(self.tabNamecoin)
self.labelNamecoinUser.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.labelNamecoinUser.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.labelNamecoinUser.setObjectName(_fromUtf8("labelNamecoinUser")) self.labelNamecoinUser.setObjectName(_fromUtf8("labelNamecoinUser"))
@ -280,8 +306,8 @@ class Ui_settingsDialog(object):
self.lineEditNamecoinUser = QtGui.QLineEdit(self.tabNamecoin) self.lineEditNamecoinUser = QtGui.QLineEdit(self.tabNamecoin)
self.lineEditNamecoinUser.setObjectName(_fromUtf8("lineEditNamecoinUser")) self.lineEditNamecoinUser.setObjectName(_fromUtf8("lineEditNamecoinUser"))
self.gridLayout_8.addWidget(self.lineEditNamecoinUser, 4, 2, 1, 1) self.gridLayout_8.addWidget(self.lineEditNamecoinUser, 4, 2, 1, 1)
spacerItem12 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) spacerItem11 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.gridLayout_8.addItem(spacerItem12, 5, 0, 1, 1) self.gridLayout_8.addItem(spacerItem11, 5, 0, 1, 1)
self.labelNamecoinPassword = QtGui.QLabel(self.tabNamecoin) self.labelNamecoinPassword = QtGui.QLabel(self.tabNamecoin)
self.labelNamecoinPassword.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) self.labelNamecoinPassword.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.labelNamecoinPassword.setObjectName(_fromUtf8("labelNamecoinPassword")) self.labelNamecoinPassword.setObjectName(_fromUtf8("labelNamecoinPassword"))
@ -353,6 +379,14 @@ class Ui_settingsDialog(object):
self.languageComboBox.setItemText(6, _translate("settingsDialog", "Russian", "ru")) self.languageComboBox.setItemText(6, _translate("settingsDialog", "Russian", "ru"))
self.languageComboBox.setItemText(7, _translate("settingsDialog", "Pirate English", "en_pirate")) self.languageComboBox.setItemText(7, _translate("settingsDialog", "Pirate English", "en_pirate"))
self.languageComboBox.setItemText(8, _translate("settingsDialog", "Other (set in keys.dat)", "other")) self.languageComboBox.setItemText(8, _translate("settingsDialog", "Other (set in keys.dat)", "other"))
self.groupBox_3.setTitle(_translate("settingsDialog", "Identicons (with example image)", None))
self.comboBox.setItemText(0, _translate("settingsDialog", "no identicons", None))
self.comboBox.setItemText(1, _translate("settingsDialog", "qidenticon", None))
self.comboBox.setItemText(2, _translate("settingsDialog", "qidenticon_x", None))
self.comboBox.setItemText(3, _translate("settingsDialog", "qidenticon_two", None))
self.comboBox.setItemText(4, _translate("settingsDialog", "qidenticon_two_x", None))
self.checkBoxLoadAvatars.setText(_translate("settingsDialog", "Load avatar images", None))
self.lineEdit.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.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), _translate("settingsDialog", "User Interface", None))
self.groupBox1.setTitle(_translate("settingsDialog", "Listening port", None)) self.groupBox1.setTitle(_translate("settingsDialog", "Listening port", None))
self.label.setText(_translate("settingsDialog", "Listen for connections on port:", None)) self.label.setText(_translate("settingsDialog", "Listen for connections on port:", None))
@ -389,6 +423,7 @@ class Ui_settingsDialog(object):
self.radioButtonNamecoinNmcontrol.setText(_translate("settingsDialog", "NMControl", None)) self.radioButtonNamecoinNmcontrol.setText(_translate("settingsDialog", "NMControl", None))
self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNamecoin), _translate("settingsDialog", "Namecoin integration", None)) self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNamecoin), _translate("settingsDialog", "Namecoin integration", None))
import bitmessage_icons_rc
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys

View File

@ -47,19 +47,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="0">
<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>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QCheckBox" name="checkBoxStartOnLogon"> <widget class="QCheckBox" name="checkBoxStartOnLogon">
<property name="text"> <property name="text">
@ -105,7 +92,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="1"> <item row="7" column="1" rowspan="4">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Interface Language</string> <string>Interface Language</string>
@ -163,6 +150,100 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="7" column="0" rowspan="4">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Identicons (with example image)</string>
</property>
<widget class="QComboBox" name="comboBox">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>251</width>
<height>31</height>
</rect>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<item>
<property name="text">
<string>no identicons</string>
</property>
<property name="icon">
<iconset resource="bitmessage_icons.qrc">
<normaloff>:/newPrefix/images/no_identicons.png</normaloff>:/newPrefix/images/no_identicons.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>qidenticon</string>
</property>
<property name="icon">
<iconset resource="bitmessage_icons.qrc">
<normaloff>:/newPrefix/images/qidenticon.png</normaloff>:/newPrefix/images/qidenticon.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>qidenticon_x</string>
</property>
<property name="icon">
<iconset resource="bitmessage_icons.qrc">
<normaloff>:/newPrefix/images/qidenticon_x.png</normaloff>:/newPrefix/images/qidenticon_x.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>qidenticon_two</string>
</property>
<property name="icon">
<iconset resource="bitmessage_icons.qrc">
<normaloff>:/newPrefix/images/qidenticon_two.png</normaloff>:/newPrefix/images/qidenticon_two.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>qidenticon_two_x</string>
</property>
<property name="icon">
<iconset resource="bitmessage_icons.qrc">
<normaloff>:/newPrefix/images/qidenticon_two_x.png</normaloff>:/newPrefix/images/qidenticon_two_x.png</iconset>
</property>
</item>
</widget>
<widget class="QCheckBox" name="checkBoxLoadAvatars">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>121</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Load avatar images</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>140</x>
<y>50</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<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>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabNetworkSettings"> <widget class="QWidget" name="tabNetworkSettings">
@ -756,7 +837,9 @@
<tabstop>checkBoxSocksListen</tabstop> <tabstop>checkBoxSocksListen</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources/> <resources>
<include location="bitmessage_icons.qrc"/>
</resources>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>

View File

@ -67,12 +67,12 @@ class IdenticonRendererBase(object):
code = int(code) code = int(code)
self.code = code self.code = code
def render(self, size, twoColor, transparent, penwidth): def render(self, size, twoColor, opacity, penwidth):
""" """
render identicon to QPixmap render identicon to QPicture
@param size identicon patchsize. (image size is 3 * [size]) @param size identicon patchsize. (image size is 3 * [size])
@return QPixmap @return QPicture
""" """
# decode the code # decode the code
@ -82,7 +82,7 @@ class IdenticonRendererBase(object):
image = QPixmap(QSize(size * 3 +penwidth, size * 3 +penwidth)) image = QPixmap(QSize(size * 3 +penwidth, size * 3 +penwidth))
# fill background # fill background
backColor = QtGui.QColor(255,255,255,(not transparent) * 255) backColor = QtGui.QColor(255,255,255,opacity)
image.fill(backColor) image.fill(backColor)
kwds = { kwds = {
@ -133,7 +133,7 @@ class IdenticonRendererBase(object):
nopen = QtGui.QPen(foreColor, Qt.NoPen) nopen = QtGui.QPen(foreColor, Qt.NoPen)
foreBrush = QtGui.QBrush(foreColor, Qt.SolidPattern) foreBrush = QtGui.QBrush(foreColor, Qt.SolidPattern)
if penwidth > 0: if penwidth > 0:
pen_color = QtGui.QColor(223, 223, 223) pen_color = QtGui.QColor(255, 255, 255)
pen = QtGui.QPen(pen_color, Qt.SolidPattern) pen = QtGui.QPen(pen_color, Qt.SolidPattern)
pen.setWidth(penwidth) pen.setWidth(penwidth)
@ -147,8 +147,8 @@ class IdenticonRendererBase(object):
if invert: if invert:
# subtract the actual polygon from a rectangle to invert it # subtract the actual polygon from a rectangle to invert it
rect_polygon = QPolygonF(rect) poly_rect = QPolygonF(rect)
polygon = rect_polygon.subtracted(polygon) polygon = poly_rect.subtracted(polygon)
painter.setBrush(foreBrush) painter.setBrush(foreBrush)
if penwidth > 0: if penwidth > 0:
# draw the borders # draw the borders
@ -157,7 +157,7 @@ class IdenticonRendererBase(object):
# draw the fill # draw the fill
painter.setPen(nopen) painter.setPen(nopen)
painter.drawPolygon(polygon, Qt.WindingFill) painter.drawPolygon(polygon, Qt.WindingFill)
painter.end() painter.end()
return image return image
@ -173,22 +173,39 @@ class DonRenderer(IdenticonRendererBase):
""" """
PATH_SET = [ PATH_SET = [
[(0, 0), (4, 0), (4, 4), (0, 4)], # 0 #[0] full square:
[(0, 0), (4, 0), (4, 4), (0, 4)],
#[1] right-angled triangle pointing top-left:
[(0, 0), (4, 0), (0, 4)], [(0, 0), (4, 0), (0, 4)],
#[2] upwardy triangle:
[(2, 0), (4, 4), (0, 4)], [(2, 0), (4, 4), (0, 4)],
#[3] left half of square, standing rectangle:
[(0, 0), (2, 0), (2, 4), (0, 4)], [(0, 0), (2, 0), (2, 4), (0, 4)],
[(2, 0), (4, 2), (2, 4), (0, 2)], # 4 #[4] square standing on diagonale:
[(2, 0), (4, 2), (2, 4), (0, 2)],
#[5] kite pointing topleft:
[(0, 0), (4, 2), (4, 4), (2, 4)], [(0, 0), (4, 2), (4, 4), (2, 4)],
#[6] Sierpinski triangle, fractal triangles:
[(2, 0), (4, 4), (2, 4), (3, 2), (1, 2), (2, 4), (0, 4)], [(2, 0), (4, 4), (2, 4), (3, 2), (1, 2), (2, 4), (0, 4)],
#[7] sharp angled lefttop pointing triangle:
[(0, 0), (4, 2), (2, 4)], [(0, 0), (4, 2), (2, 4)],
[(1, 1), (3, 1), (3, 3), (1, 3)], # 8 #[8] small centered square:
[(1, 1), (3, 1), (3, 3), (1, 3)],
#[9] two small triangles:
[(2, 0), (4, 0), (0, 4), (0, 2), (2, 2)], [(2, 0), (4, 0), (0, 4), (0, 2), (2, 2)],
#[10] small topleft square:
[(0, 0), (2, 0), (2, 2), (0, 2)], [(0, 0), (2, 0), (2, 2), (0, 2)],
#[11] downpointing right-angled triangle on bottom:
[(0, 2), (4, 2), (2, 4)], [(0, 2), (4, 2), (2, 4)],
#[12] uppointing right-angled triangle on bottom:
[(2, 2), (4, 4), (0, 4)], [(2, 2), (4, 4), (0, 4)],
#[13] small rightbottom pointing right-angled triangle on topleft:
[(2, 0), (2, 2), (0, 2)], [(2, 0), (2, 2), (0, 2)],
#[14] small lefttop pointing right-angled triangle on topleft:
[(0, 0), (2, 0), (0, 2)], [(0, 0), (2, 0), (0, 2)],
[]] # 15 #[15] empty:
[]]
# get the [0] full square, [4] square standing on diagonale, [8] small centered square, or [15] empty tile:
MIDDLE_PATCH_SET = [0, 4, 8, 15] MIDDLE_PATCH_SET = [0, 4, 8, 15]
# modify path set # modify path set
@ -232,7 +249,7 @@ class DonRenderer(IdenticonRendererBase):
foreColor, secondColor, swap_cross foreColor, secondColor, swap_cross
def render_identicon(code, size, twoColor=False, transparent=False, penwidth=0, renderer=None): def render_identicon(code, size, twoColor=False, opacity=255, penwidth=0, renderer=None):
if not renderer: if not renderer:
renderer = DonRenderer renderer = DonRenderer
return renderer(code).render(size, twoColor, transparent, penwidth) return renderer(code).render(size, twoColor, opacity, penwidth)