diff --git a/src/bitmessageqt/settings.py b/src/bitmessageqt/settings.py index caaff929..ca55dbed 100644 --- a/src/bitmessageqt/settings.py +++ b/src/bitmessageqt/settings.py @@ -1,7 +1,7 @@ import os import sys -from PyQt4 import QtGui +from PyQt4 import QtCore, QtGui import debug import defaults @@ -29,6 +29,8 @@ class SettingsDialog(QtGui.QDialog): self.parent = parent self.firstrun = firstrun self.config = BMConfigParser() + self.net_restart_needed = False + self.timer = QtCore.QTimer() self.lineEditMaxOutboundConnections.setValidator( QtGui.QIntValidator(0, 8, self.lineEditMaxOutboundConnections)) @@ -284,16 +286,11 @@ class SettingsDialog(QtGui.QDialog): 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 not self.config.safeGetBoolean('bitmessagesettings', 'dontconnect'): + self.net_restart_needed = True + if self.checkBoxUPnP.isChecked() != self.config.safeGetBoolean( 'bitmessagesettings', 'upnp'): self.config.set( @@ -307,17 +304,10 @@ class SettingsDialog(QtGui.QDialog): if ( self.config.get('bitmessagesettings', 'socksproxytype') == 'none' and - self.comboBoxProxyType.currentText()[0:5] == 'SOCKS' + self.comboBoxProxyType.currentText()[0:5] == 'SOCKS' and + shared.statusIconColor != 'red' ): - 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).") - ) + self.net_restart_needed = True if ( self.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and self.comboBoxProxyType.currentText()[0:5] != 'SOCKS' @@ -364,6 +354,15 @@ class SettingsDialog(QtGui.QDialog): self.config.set('bitmessagesettings', 'maxoutboundconnections', str( int(float(self.lineEditMaxOutboundConnections.text())))) + if self.net_restart_needed: + self.net_restart_needed = False + self.config.set('bitmessagesettings', 'dontconnect', 'true') + self.timer.singleShot( + 5000, lambda: + self.config.remove_option( + 'bitmessagesettings', 'dontconnect') + ) + self.config.set( 'bitmessagesettings', 'namecoinrpctype', self.getNamecoinType()) self.config.set('bitmessagesettings', 'namecoinrpchost', str(