ui-file based Settings dialog
parent
a961a4a2fb
commit
8a3074f3ff
@ -1,630 +1,544 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# pylint: disable=too-many-instance-attributes,too-many-locals,too-many-statements,attribute-defined-outside-init
|
||||
"""
|
||||
src/bitmessageqt/settings.py
|
||||
============================
|
||||
|
||||
Form implementation generated from reading ui file 'settings.ui'
|
||||
|
||||
Created: Thu Dec 25 23:21:20 2014
|
||||
by: PyQt4 UI code generator 4.10.3
|
||||
|
||||
WARNING! All changes made in this file will be lost!
|
||||
"""
|
||||
|
||||
from sys import platform
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from . import bitmessage_icons_rc # pylint: disable=unused-import
|
||||
from .languagebox import LanguageBox
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
def _fromUtf8(s):
|
||||
return s
|
||||
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
except AttributeError:
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig)
|
||||
|
||||
|
||||
class Ui_settingsDialog(object):
|
||||
"""Encapsulate a UI settings dialog object"""
|
||||
|
||||
def setupUi(self, settingsDialog):
|
||||
"""Set up the UI"""
|
||||
|
||||
settingsDialog.setObjectName(_fromUtf8("settingsDialog"))
|
||||
settingsDialog.resize(521, 413)
|
||||
self.gridLayout = QtGui.QGridLayout(settingsDialog)
|
||||
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
|
||||
self.buttonBox = QtGui.QDialogButtonBox(settingsDialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok)
|
||||
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
|
||||
self.gridLayout.addWidget(self.buttonBox, 1, 0, 1, 1)
|
||||
self.tabWidgetSettings = QtGui.QTabWidget(settingsDialog)
|
||||
self.tabWidgetSettings.setObjectName(_fromUtf8("tabWidgetSettings"))
|
||||
self.tabUserInterface = QtGui.QWidget()
|
||||
self.tabUserInterface.setEnabled(True)
|
||||
self.tabUserInterface.setObjectName(_fromUtf8("tabUserInterface"))
|
||||
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.groupBoxTray = QtGui.QGroupBox(self.tabUserInterface)
|
||||
self.groupBoxTray.setObjectName(_fromUtf8("groupBoxTray"))
|
||||
self.formLayoutTray = QtGui.QFormLayout(self.groupBoxTray)
|
||||
self.formLayoutTray.setObjectName(_fromUtf8("formLayoutTray"))
|
||||
self.checkBoxStartInTray = QtGui.QCheckBox(self.groupBoxTray)
|
||||
self.checkBoxStartInTray.setObjectName(_fromUtf8("checkBoxStartInTray"))
|
||||
self.formLayoutTray.setWidget(0, QtGui.QFormLayout.SpanningRole, self.checkBoxStartInTray)
|
||||
self.checkBoxMinimizeToTray = QtGui.QCheckBox(self.groupBoxTray)
|
||||
self.checkBoxMinimizeToTray.setChecked(True)
|
||||
self.checkBoxMinimizeToTray.setObjectName(_fromUtf8("checkBoxMinimizeToTray"))
|
||||
self.formLayoutTray.setWidget(1, QtGui.QFormLayout.LabelRole, self.checkBoxMinimizeToTray)
|
||||
self.checkBoxTrayOnClose = QtGui.QCheckBox(self.groupBoxTray)
|
||||
self.checkBoxTrayOnClose.setChecked(True)
|
||||
self.checkBoxTrayOnClose.setObjectName(_fromUtf8("checkBoxTrayOnClose"))
|
||||
self.formLayoutTray.setWidget(2, QtGui.QFormLayout.LabelRole, self.checkBoxTrayOnClose)
|
||||
self.formLayout.setWidget(1, QtGui.QFormLayout.SpanningRole, self.groupBoxTray)
|
||||
self.checkBoxHideTrayConnectionNotifications = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxHideTrayConnectionNotifications.setChecked(False)
|
||||
self.checkBoxHideTrayConnectionNotifications.setObjectName(
|
||||
_fromUtf8("checkBoxHideTrayConnectionNotifications"))
|
||||
self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.checkBoxHideTrayConnectionNotifications)
|
||||
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.checkBoxReplyBelow = QtGui.QCheckBox(self.tabUserInterface)
|
||||
self.checkBoxReplyBelow.setObjectName(_fromUtf8("checkBoxReplyBelow"))
|
||||
self.formLayout.setWidget(8, QtGui.QFormLayout.LabelRole, self.checkBoxReplyBelow)
|
||||
self.groupBox = QtGui.QGroupBox(self.tabUserInterface)
|
||||
self.groupBox.setObjectName(_fromUtf8("groupBox"))
|
||||
self.formLayout_2 = QtGui.QFormLayout(self.groupBox)
|
||||
self.formLayout_2.setObjectName(_fromUtf8("formLayout_2"))
|
||||
self.languageComboBox = LanguageBox(self.groupBox)
|
||||
self.languageComboBox.setMinimumSize(QtCore.QSize(100, 0))
|
||||
self.languageComboBox.setObjectName(_fromUtf8("languageComboBox")) # pylint: disable=not-callable
|
||||
self.formLayout_2.setWidget(0, QtGui.QFormLayout.LabelRole, self.languageComboBox)
|
||||
self.formLayout.setWidget(9, QtGui.QFormLayout.FieldRole, self.groupBox)
|
||||
self.tabWidgetSettings.addTab(self.tabUserInterface, _fromUtf8(""))
|
||||
self.tabNetworkSettings = QtGui.QWidget()
|
||||
self.tabNetworkSettings.setObjectName(_fromUtf8("tabNetworkSettings"))
|
||||
self.gridLayout_4 = QtGui.QGridLayout(self.tabNetworkSettings)
|
||||
self.gridLayout_4.setObjectName(_fromUtf8("gridLayout_4"))
|
||||
self.groupBox1 = QtGui.QGroupBox(self.tabNetworkSettings)
|
||||
self.groupBox1.setObjectName(_fromUtf8("groupBox1"))
|
||||
self.gridLayout_3 = QtGui.QGridLayout(self.groupBox1)
|
||||
self.gridLayout_3.setObjectName(_fromUtf8("gridLayout_3"))
|
||||
self.label = QtGui.QLabel(self.groupBox1)
|
||||
self.label.setObjectName(_fromUtf8("label"))
|
||||
self.gridLayout_3.addWidget(self.label, 0, 0, 1, 1, QtCore.Qt.AlignRight)
|
||||
self.lineEditTCPPort = QtGui.QLineEdit(self.groupBox1)
|
||||
self.lineEditTCPPort.setMaximumSize(QtCore.QSize(70, 16777215))
|
||||
self.lineEditTCPPort.setObjectName(_fromUtf8("lineEditTCPPort"))
|
||||
self.gridLayout_3.addWidget(self.lineEditTCPPort, 0, 1, 1, 1, QtCore.Qt.AlignLeft)
|
||||
self.labelUPnP = QtGui.QLabel(self.groupBox1)
|
||||
self.labelUPnP.setObjectName(_fromUtf8("labelUPnP"))
|
||||
self.gridLayout_3.addWidget(self.labelUPnP, 0, 2, 1, 1, QtCore.Qt.AlignRight)
|
||||
self.checkBoxUPnP = QtGui.QCheckBox(self.groupBox1)
|
||||
self.checkBoxUPnP.setObjectName(_fromUtf8("checkBoxUPnP"))
|
||||
self.gridLayout_3.addWidget(self.checkBoxUPnP, 0, 3, 1, 1, QtCore.Qt.AlignLeft)
|
||||
self.gridLayout_4.addWidget(self.groupBox1, 0, 0, 1, 1)
|
||||
self.groupBox_3 = QtGui.QGroupBox(self.tabNetworkSettings)
|
||||
self.groupBox_3.setObjectName(_fromUtf8("groupBox_3"))
|
||||
self.gridLayout_9 = QtGui.QGridLayout(self.groupBox_3)
|
||||
self.gridLayout_9.setObjectName(_fromUtf8("gridLayout_9"))
|
||||
spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.gridLayout_9.addItem(spacerItem1, 0, 0, 2, 1)
|
||||
self.label_24 = QtGui.QLabel(self.groupBox_3)
|
||||
self.label_24.setObjectName(_fromUtf8("label_24"))
|
||||
self.gridLayout_9.addWidget(self.label_24, 0, 1, 1, 1)
|
||||
self.lineEditMaxDownloadRate = QtGui.QLineEdit(self.groupBox_3)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditMaxDownloadRate.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditMaxDownloadRate.setSizePolicy(sizePolicy)
|
||||
self.lineEditMaxDownloadRate.setMaximumSize(QtCore.QSize(60, 16777215))
|
||||
self.lineEditMaxDownloadRate.setObjectName(_fromUtf8("lineEditMaxDownloadRate"))
|
||||
self.gridLayout_9.addWidget(self.lineEditMaxDownloadRate, 0, 2, 1, 1)
|
||||
self.label_25 = QtGui.QLabel(self.groupBox_3)
|
||||
self.label_25.setObjectName(_fromUtf8("label_25"))
|
||||
self.gridLayout_9.addWidget(self.label_25, 1, 1, 1, 1)
|
||||
self.lineEditMaxUploadRate = QtGui.QLineEdit(self.groupBox_3)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditMaxUploadRate.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditMaxUploadRate.setSizePolicy(sizePolicy)
|
||||
self.lineEditMaxUploadRate.setMaximumSize(QtCore.QSize(60, 16777215))
|
||||
self.lineEditMaxUploadRate.setObjectName(_fromUtf8("lineEditMaxUploadRate"))
|
||||
self.gridLayout_9.addWidget(self.lineEditMaxUploadRate, 1, 2, 1, 1)
|
||||
self.label_26 = QtGui.QLabel(self.groupBox_3)
|
||||
self.label_26.setObjectName(_fromUtf8("label_26"))
|
||||
self.gridLayout_9.addWidget(self.label_26, 2, 1, 1, 1)
|
||||
self.lineEditMaxOutboundConnections = QtGui.QLineEdit(self.groupBox_3)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.lineEditMaxOutboundConnections.sizePolicy().hasHeightForWidth())
|
||||
self.lineEditMaxOutboundConnections.setSizePolicy(sizePolicy)
|
||||
self.lineEditMaxOutboundConnections.setMaximumSize(QtCore.QSize(60, 16777215))
|
||||
self.lineEditMaxOutboundConnections.setObjectName(_fromUtf8("lineEditMaxOutboundConnections"))
|
||||
import os
|
||||
import sys
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
import debug
|
||||
import defaults
|
||||
import knownnodes
|
||||
import namecoin
|
||||
import openclpow
|
||||
import paths
|
||||
import queues
|
||||
import shared
|
||||
import state
|
||||
import tempfile
|
||||
import widgets
|
||||
from bmconfigparser import BMConfigParser
|
||||
from helper_sql import sqlExecute, sqlStoredProcedure
|
||||
from network.asyncore_pollchoose import set_rates
|
||||
from tr import _translate
|
||||
|
||||
|
||||
class SettingsDialog(QtGui.QDialog):
|
||||
"""The "Settings" dialog"""
|
||||
def __init__(self, parent=None, firstrun=False):
|
||||
super(SettingsDialog, self).__init__(parent)
|
||||
widgets.load('settings.ui', self)
|
||||
|
||||
self.parent = parent
|
||||
self.firstrun = firstrun
|
||||
self.config = BMConfigParser()
|
||||
|
||||
self.lineEditMaxOutboundConnections.setValidator(
|
||||
QtGui.QIntValidator(0, 8, self.lineEditMaxOutboundConnections))
|
||||
self.gridLayout_9.addWidget(self.lineEditMaxOutboundConnections, 2, 2, 1, 1)
|
||||
self.gridLayout_4.addWidget(self.groupBox_3, 2, 0, 1, 1)
|
||||
self.groupBox_2 = QtGui.QGroupBox(self.tabNetworkSettings)
|
||||
self.groupBox_2.setObjectName(_fromUtf8("groupBox_2"))
|
||||
self.gridLayout_2 = QtGui.QGridLayout(self.groupBox_2)
|
||||
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
|
||||
self.label_2 = QtGui.QLabel(self.groupBox_2)
|
||||
self.label_2.setObjectName(_fromUtf8("label_2"))
|
||||
self.gridLayout_2.addWidget(self.label_2, 0, 0, 1, 1)
|
||||
self.label_3 = QtGui.QLabel(self.groupBox_2)
|
||||
self.label_3.setObjectName(_fromUtf8("label_3"))
|
||||
self.gridLayout_2.addWidget(self.label_3, 1, 1, 1, 1)
|
||||
self.lineEditSocksHostname = QtGui.QLineEdit(self.groupBox_2)
|
||||
self.lineEditSocksHostname.setObjectName(_fromUtf8("lineEditSocksHostname"))
|
||||
self.lineEditSocksHostname.setPlaceholderText(_fromUtf8("127.0.0.1"))
|
||||
self.gridLayout_2.addWidget(self.lineEditSocksHostname, 1, 2, 1, 2)
|
||||
self.label_4 = QtGui.QLabel(self.groupBox_2)
|
||||
self.label_4.setObjectName(_fromUtf8("label_4"))
|
||||
self.gridLayout_2.addWidget(self.label_4, 1, 4, 1, 1)
|
||||
self.lineEditSocksPort = QtGui.QLineEdit(self.groupBox_2)
|
||||
self.lineEditSocksPort.setObjectName(_fromUtf8("lineEditSocksPort"))
|
||||
if platform in ['darwin', 'win32', 'win64']:
|
||||
self.lineEditSocksPort.setPlaceholderText(_fromUtf8("9150"))
|
||||
|
||||
self.adjust_from_config(self.config)
|
||||
if firstrun:
|
||||
# switch to "Network Settings" tab if user selected
|
||||
# "Let me configure special network settings first" on first run
|
||||
self.tabWidgetSettings.setCurrentIndex(
|
||||
self.tabWidgetSettings.indexOf(self.tabNetworkSettings)
|
||||
)
|
||||
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))
|
||||
|
||||
def adjust_from_config(self, config):
|
||||
"""Adjust all widgets state according to config settings"""
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
self.checkBoxStartOnLogon.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'startonlogon'))
|
||||
self.checkBoxMinimizeToTray.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'minimizetotray'))
|
||||
self.checkBoxTrayOnClose.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'trayonclose'))
|
||||
self.checkBoxHideTrayConnectionNotifications.setChecked(
|
||||
config.getboolean("bitmessagesettings", "hidetrayconnectionnotifications"))
|
||||
self.checkBoxShowTrayNotifications.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'showtraynotifications'))
|
||||
self.checkBoxStartInTray.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'startintray'))
|
||||
self.checkBoxWillinglySendToMobile.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'willinglysendtomobile'))
|
||||
self.checkBoxUseIdenticons.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'useidenticons'))
|
||||
self.checkBoxReplyBelow.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'replybelow'))
|
||||
|
||||
if state.appdata == paths.lookupExeFolder():
|
||||
self.checkBoxPortableMode.setChecked(True)
|
||||
else:
|
||||
try:
|
||||
tempfile.NamedTemporaryFile(
|
||||
dir=paths.lookupExeFolder(), delete=True
|
||||
).close() # should autodelete
|
||||
except:
|
||||
self.checkBoxPortableMode.setDisabled(True)
|
||||
|
||||
if 'darwin' in sys.platform:
|
||||
self.checkBoxStartOnLogon.setDisabled(True)
|
||||
self.checkBoxStartOnLogon.setText(_translate(
|
||||
"MainWindow", "Start-on-login not yet supported on your OS."))
|
||||
self.checkBoxMinimizeToTray.setDisabled(True)
|
||||
self.checkBoxMinimizeToTray.setText(_translate(
|
||||
"MainWindow", "Minimize-to-tray not yet supported on your OS."))
|
||||
self.checkBoxShowTrayNotifications.setDisabled(True)
|
||||
self.checkBoxShowTrayNotifications.setText(_translate(
|
||||
"MainWindow", "Tray notifications not yet supported on your OS."))
|
||||
elif 'linux' in sys.platform:
|
||||
self.checkBoxStartOnLogon.setDisabled(True)
|
||||
self.checkBoxStartOnLogon.setText(_translate(
|
||||
"MainWindow", "Start-on-login not yet supported on your OS."))
|
||||
# On the Network settings tab:
|
||||
self.lineEditTCPPort.setText(str(
|
||||
config.get('bitmessagesettings', 'port')))
|
||||
self.checkBoxUPnP.setChecked(
|
||||
config.safeGetBoolean('bitmessagesettings', 'upnp'))
|
||||
self.checkBoxAuthentication.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'socksauthentication'))
|
||||
self.checkBoxSocksListen.setChecked(
|
||||
config.getboolean('bitmessagesettings', 'sockslisten'))
|
||||
|
||||
proxy_type = config.get('bitmessagesettings', 'socksproxytype')
|
||||
if proxy_type == 'none':
|
||||
self.comboBoxProxyType.setCurrentIndex(0)
|
||||
self.lineEditSocksHostname.setEnabled(False)
|
||||
self.lineEditSocksPort.setEnabled(False)
|
||||
self.lineEditSocksUsername.setEnabled(False)
|
||||
self.lineEditSocksPassword.setEnabled(False)
|
||||
self.checkBoxAuthentication.setEnabled(False)
|
||||
self.checkBoxSocksListen.setEnabled(False)
|
||||
elif proxy_type == 'SOCKS4a':
|
||||
self.comboBoxProxyType.setCurrentIndex(1)
|
||||
elif proxy_type == 'SOCKS5':
|
||||
self.comboBoxProxyType.setCurrentIndex(2)
|
||||
|
||||
self.lineEditSocksHostname.setText(
|
||||
config.get('bitmessagesettings', 'sockshostname'))
|
||||
self.lineEditSocksPort.setText(str(
|
||||
config.get('bitmessagesettings', 'socksport')))
|
||||
self.lineEditSocksUsername.setText(
|
||||
config.get('bitmessagesettings', 'socksusername'))
|
||||
self.lineEditSocksPassword.setText(
|
||||
config.get('bitmessagesettings', 'sockspassword'))
|
||||
|
||||
self.lineEditMaxDownloadRate.setText(str(
|
||||
config.get('bitmessagesettings', 'maxdownloadrate')))
|
||||
self.lineEditMaxUploadRate.setText(str(
|
||||
config.get('bitmessagesettings', 'maxuploadrate')))
|
||||
self.lineEditMaxOutboundConnections.setText(str(
|
||||
config.get('bitmessagesettings', 'maxoutboundconnections')))
|
||||
|
||||
# Demanded difficulty tab
|
||||
self.lineEditTotalDifficulty.setText(str((float(
|
||||
config.getint(
|
||||
'bitmessagesettings', 'defaultnoncetrialsperbyte')
|
||||
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
self.lineEditSmallMessageDifficulty.setText(str((float(
|
||||
config.getint(
|
||||
'bitmessagesettings', 'defaultpayloadlengthextrabytes')
|
||||
) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||
|
||||
# Max acceptable difficulty tab
|
||||
self.lineEditMaxAcceptableTotalDifficulty.setText(str((float(
|
||||
config.getint(
|
||||
'bitmessagesettings', 'maxacceptablenoncetrialsperbyte')
|
||||
) / defaults.networkDefaultProofOfWorkNonceTrialsPerByte)))
|
||||
self.lineEditMaxAcceptableSmallMessageDifficulty.setText(str((float(
|
||||
config.getint(
|
||||
'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes')
|
||||
) / defaults.networkDefaultPayloadLengthExtraBytes)))
|
||||
|
||||
# OpenCL
|
||||
self.comboBoxOpenCL.setEnabled(openclpow.openclAvailable())
|
||||
self.comboBoxOpenCL.clear()
|
||||
self.comboBoxOpenCL.addItem("None")
|
||||
self.comboBoxOpenCL.addItems(openclpow.vendors)
|
||||
self.comboBoxOpenCL.setCurrentIndex(0)
|
||||
for i in range(self.comboBoxOpenCL.count()):
|
||||
if self.comboBoxOpenCL.itemText(i) == config.safeGet(
|
||||
'bitmessagesettings', 'opencl'):
|
||||
self.comboBoxOpenCL.setCurrentIndex(i)
|
||||
break
|
||||
|
||||
# Namecoin integration tab
|
||||
nmctype = config.get('bitmessagesettings', 'namecoinrpctype')
|
||||
self.lineEditNamecoinHost.setText(
|
||||
config.get('bitmessagesettings', 'namecoinrpchost'))
|
||||
self.lineEditNamecoinPort.setText(str(
|
||||
config.get('bitmessagesettings', 'namecoinrpcport')))
|
||||
self.lineEditNamecoinUser.setText(
|
||||
config.get('bitmessagesettings', 'namecoinrpcuser'))
|
||||
self.lineEditNamecoinPassword.setText(
|
||||
config.get('bitmessagesettings', 'namecoinrpcpassword'))
|
||||
|
||||
if nmctype == "namecoind":
|
||||
self.radioButtonNamecoinNamecoind.setChecked(True)
|
||||
elif nmctype == "nmcontrol":
|
||||
self.radioButtonNamecoinNmcontrol.setChecked(True)
|
||||
self.lineEditNamecoinUser.setEnabled(False)
|
||||
self.labelNamecoinUser.setEnabled(False)
|
||||
self.lineEditNamecoinPassword.setEnabled(False)
|
||||
self.labelNamecoinPassword.setEnabled(False)
|
||||
else:
|
||||
assert False
|
||||
|
||||
# Message Resend tab
|
||||
self.lineEditDays.setText(str(
|
||||
config.get('bitmessagesettings', 'stopresendingafterxdays')))
|
||||
self.lineEditMonths.setText(str(
|
||||
config.get('bitmessagesettings', 'stopresendingafterxmonths')))
|
||||
|
||||
def comboBoxProxyTypeChanged(self, comboBoxIndex):
|
||||
"""A callback for currentIndexChanged event of comboBoxProxyType"""
|
||||
if comboBoxIndex == 0:
|
||||
self.lineEditSocksHostname.setEnabled(False)
|
||||
self.lineEditSocksPort.setEnabled(False)
|
||||
self.lineEditSocksUsername.setEnabled(False)
|
||||
self.lineEditSocksPassword.setEnabled(False)
|
||||
self.checkBoxAuthentication.setEnabled(False)
|
||||
self.checkBoxSocksListen.setEnabled(False)
|
||||
elif comboBoxIndex in (1, 2):
|
||||
self.lineEditSocksHostname.setEnabled(True)
|
||||
self.lineEditSocksPort.setEnabled(True)
|
||||
self.checkBoxAuthentication.setEnabled(True)
|
||||
self.checkBoxSocksListen.setEnabled(True)
|
||||
if self.checkBoxAuthentication.isChecked():
|
||||
self.lineEditSocksUsername.setEnabled(True)
|
||||
self.lineEditSocksPassword.setEnabled(True)
|
||||
|
||||
def getNamecoinType(self):
|
||||
"""
|
||||
Check status of namecoin integration radio buttons
|
||||
and translate it to a string as in the options.
|
||||
"""
|
||||
if self.radioButtonNamecoinNamecoind.isChecked():
|
||||
return "namecoind"
|
||||
if self.radioButtonNamecoinNmcontrol.isChecked():
|
||||
return "nmcontrol"
|
||||
assert False
|
||||
|
||||
# Namecoin connection type was changed.
|
||||
def namecoinTypeChanged(self, checked): # pylint: disable=unused-argument
|
||||
"""A callback for toggled event of radioButtonNamecoinNamecoind"""
|
||||
nmctype = self.getNamecoinType()
|
||||
assert nmctype == "namecoind" or nmctype == "nmcontrol"
|
||||
|
||||
isNamecoind = (nmctype == "namecoind")
|
||||
self.lineEditNamecoinUser.setEnabled(isNamecoind)
|
||||
self.labelNamecoinUser.setEnabled(isNamecoind)
|
||||
self.lineEditNamecoinPassword.setEnabled(isNamecoind)
|
||||
self.labelNamecoinPassword.setEnabled(isNamecoind)
|
||||
|
||||
if isNamecoind:
|
||||
self.lineEditNamecoinPort.setText(defaults.namecoinDefaultRpcPort)
|
||||
else:
|
||||
self.lineEditNamecoinPort.setText("9000")
|
||||
|
||||
def click_pushButtonNamecoinTest(self):
|
||||
"""Test the namecoin settings specified in the settings dialog."""
|
||||
self.labelNamecoinTestResult.setText(
|
||||
_translate("MainWindow", "Testing..."))
|
||||
nc = namecoin.namecoinConnection({
|
||||
'type': self.getNamecoinType(),
|
||||
'host': str(self.lineEditNamecoinHost.text().toUtf8()),
|
||||
'port': str(self.lineEditNamecoinPort.text().toUtf8()),
|
||||
'user': str(self.lineEditNamecoinUser.text().toUtf8()),
|
||||
'password': str(self.lineEditNamecoinPassword.text().toUtf8())
|
||||
})
|
||||
status, text = nc.test()
|
||||
self.labelNamecoinTestResult.setText(text)
|
||||
if status == 'success':
|
||||
self.parent.namecoin = nc
|
||||
|
||||
def accept(self):
|
||||
"""A callback for accepted event of buttonBox (OK button pressed)"""
|
||||
# pylint: disable=too-many-branches,too-many-statements
|
||||
super(SettingsDialog, self).accept()
|
||||
if self.firstrun:
|
||||
self.config.remove_option('bitmessagesettings', 'dontconnect')
|
||||
self.config.set('bitmessagesettings', 'startonlogon', str(
|
||||
self.checkBoxStartOnLogon.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'minimizetotray', str(
|
||||
self.checkBoxMinimizeToTray.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'trayonclose', str(
|
||||
self.checkBoxTrayOnClose.isChecked()))
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'hidetrayconnectionnotifications',
|
||||
str(self.checkBoxHideTrayConnectionNotifications.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'showtraynotifications', str(
|
||||
self.checkBoxShowTrayNotifications.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'startintray', str(
|
||||
self.checkBoxStartInTray.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'willinglysendtomobile', str(
|
||||
self.checkBoxWillinglySendToMobile.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'useidenticons', str(
|
||||
self.checkBoxUseIdenticons.isChecked()))
|
||||
self.config.set('bitmessagesettings', 'replybelow', str(
|
||||
self.checkBoxReplyBelow.isChecked()))
|
||||
|
||||
lang = str(self.languageComboBox.itemData(
|
||||
self.languageComboBox.currentIndex()).toString())
|
||||
self.config.set('bitmessagesettings', 'userlocale', lang)
|
||||
self.parent.change_translation()
|
||||
|
||||
if int(self.config.get('bitmessagesettings', 'port')) != int(
|
||||
self.lineEditTCPPort.text()):
|
||||
if not self.config.safeGetBoolean('bitmessagesettings', 'dontconnect'):
|
||||
QtGui.QMessageBox.about(
|
||||
self, _translate("MainWindow", "Restart"),
|
||||
_translate(
|
||||
"MainWindow",
|
||||
"You must restart Bitmessage for the port number"
|
||||
" change to take effect.")
|
||||
)
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'port', str(self.lineEditTCPPort.text()))
|
||||
if self.checkBoxUPnP.isChecked() != self.config.safeGetBoolean(
|
||||
'bitmessagesettings', 'upnp'):
|
||||
self.config.set(
|
||||
'bitmessagesettings', 'upnp',
|
||||
str(self.checkBoxUPnP.isChecked()))
|
||||
if self.checkBoxUPnP.isChecked():
|
||||
import upnp
|
||||
upnpThread = upnp.uPnPThread()
|
||||
upnpThread.start()
|
||||
|
||||
if (
|
||||
self.config.get('bitmessagesettings', 'socksproxytype') ==
|
||||
'none' and
|
||||
self.comboBoxProxyType.currentText()[0:5] == 'SOCKS'
|
||||
):
|
||||
if shared.statusIconColor != 'red':
|
||||
QtGui.QMessageBox.about(
|
||||
self, _translate("MainWindow", "Restart"),
|
||||
_translate(
|
||||
"MainWindow",
|
||||
"Bitmessage will use your proxy from now on but"
|
||||
" you may want to manually restart Bitmessage now"
|
||||
" to close existing connections (if any).")
|
||||
)
|
||||
if (
|
||||
self.config.get('bitmessagesettings', 'socksproxytype')[0:5] ==
|
||||