From 0d5f2680d404125204156d8a2a2bf81faa94d62f Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Tue, 27 Aug 2013 22:29:39 -0400 Subject: [PATCH] various modifications to previous commit regarding ability to select language --- src/bitmessageqt/__init__.py | 13 +++++++++---- src/bitmessageqt/settings.py | 21 ++++++--------------- src/bitmessageqt/settings.ui | 14 ++++++++++---- src/class_outgoingSynSender.py | 2 +- src/class_sqlThread.py | 8 ++++++++ src/helper_startup.py | 7 +++++++ 6 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index eab7f0e2..8b6b1ce7 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -2049,14 +2049,19 @@ class MyForm(QtGui.QMainWindow): "MainWindow", "You must restart Bitmessage for the port number change to take effect.")) shared.config.set('bitmessagesettings', 'port', str( self.settingsDialogInstance.ui.lineEditTCPPort.text())) - if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5] == 'SOCKS': + #print 'self.settingsDialogInstance.ui.comboBoxProxyType.currentText()', self.settingsDialogInstance.ui.comboBoxProxyType.currentText() + #print 'self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5]', self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] + if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none' and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS': if shared.statusIconColor != 'red': 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 shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText()) == 'none': + if shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS': self.statusBar().showMessage('') - shared.config.set('bitmessagesettings', 'socksproxytype', str( - self.settingsDialogInstance.ui.comboBoxProxyType.currentText())) + if self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS': + shared.config.set('bitmessagesettings', 'socksproxytype', str( + self.settingsDialogInstance.ui.comboBoxProxyType.currentText())) + else: + shared.config.set('bitmessagesettings', 'socksproxytype', 'none') shared.config.set('bitmessagesettings', 'socksauthentication', str( self.settingsDialogInstance.ui.checkBoxAuthentication.isChecked())) shared.config.set('bitmessagesettings', 'sockshostname', str( diff --git a/src/bitmessageqt/settings.py b/src/bitmessageqt/settings.py index ad597773..0d8f9e72 100644 --- a/src/bitmessageqt/settings.py +++ b/src/bitmessageqt/settings.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'settings.ui' # -# Created: Sat Aug 24 09:19:58 2013 +# Created: Tue Aug 27 22:23:38 2013 # by: PyQt4 UI code generator 4.10.2 # # WARNING! All changes made in this file will be lost! @@ -71,6 +71,7 @@ class Ui_settingsDialog(object): self.horizontalLayout_2 = QtGui.QHBoxLayout(self.groupBox) self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.languageComboBox = QtGui.QComboBox(self.groupBox) + self.languageComboBox.setMinimumSize(QtCore.QSize(100, 0)) self.languageComboBox.setObjectName(_fromUtf8("languageComboBox")) self.languageComboBox.addItem(_fromUtf8("")) self.languageComboBox.addItem(_fromUtf8("")) @@ -347,10 +348,10 @@ class Ui_settingsDialog(object): self.languageComboBox.setItemText(0, _translate("settingsDialog", "System Settings", "system")) self.languageComboBox.setItemText(1, _translate("settingsDialog", "English", "en")) self.languageComboBox.setItemText(2, _translate("settingsDialog", "Esperanto", "eo")) - self.languageComboBox.setItemText(3, _translate("settingsDialog", "French", "fr")) - self.languageComboBox.setItemText(4, _translate("settingsDialog", "German", "de")) - self.languageComboBox.setItemText(5, _translate("settingsDialog", "Spanish", "es")) - self.languageComboBox.setItemText(6, _translate("settingsDialog", "Russian", "ru")) + self.languageComboBox.setItemText(3, _translate("settingsDialog", "Français", "fr")) + self.languageComboBox.setItemText(4, _translate("settingsDialog", "Deutsch", "de")) + self.languageComboBox.setItemText(5, _translate("settingsDialog", "Español", "es")) + 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.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabUserInterface), _translate("settingsDialog", "User Interface", None)) @@ -389,13 +390,3 @@ class Ui_settingsDialog(object): self.radioButtonNamecoinNmcontrol.setText(_translate("settingsDialog", "NMControl", None)) self.tabWidgetSettings.setTabText(self.tabWidgetSettings.indexOf(self.tabNamecoin), _translate("settingsDialog", "Namecoin integration", None)) - -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_()) - diff --git a/src/bitmessageqt/settings.ui b/src/bitmessageqt/settings.ui index eec38d8d..02117149 100644 --- a/src/bitmessageqt/settings.ui +++ b/src/bitmessageqt/settings.ui @@ -113,6 +113,12 @@ + + + 100 + 0 + + System Settings @@ -130,22 +136,22 @@ - French + Français - German + Deutsch - Spanish + Español - Russian + Русский diff --git a/src/class_outgoingSynSender.py b/src/class_outgoingSynSender.py index 8a929c7d..c526c9b4 100644 --- a/src/class_outgoingSynSender.py +++ b/src/class_outgoingSynSender.py @@ -25,7 +25,7 @@ class outgoingSynSender(threading.Thread): def run(self): while shared.safeConfigGetBoolean('bitmessagesettings', 'dontconnect'): time.sleep(2) - while True: + while shared.safeConfigGetBoolean('bitmessagesettings', 'sendoutgoingconnections'): while len(self.selfInitiatedConnections[self.streamNumber]) >= 8: # maximum number of outgoing connections = 8 time.sleep(10) if shared.shutdown: diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index 5a911246..47e41b42 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -204,6 +204,14 @@ class sqlThread(threading.Thread): item = '''update settings set value=? WHERE key='version';''' parameters = (2,) self.cur.execute(item, parameters) + + if not shared.config.has_option('bitmessagesettings', 'userlocale'): + shared.config.set('bitmessagesettings', 'userlocale', 'system') + if not shared.config.has_option('bitmessagesettings', 'sendoutgoingconnections'): + shared.config.set('bitmessagesettings', 'sendoutgoingconnections', 'True') + + # Are you hoping to add a new option to the keys.dat file of existing + # Bitmessage users? Add it right above this line! try: testpayload = '\x00\x00' diff --git a/src/helper_startup.py b/src/helper_startup.py index 12ea1b84..05afcb9c 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -84,6 +84,13 @@ def loadConfig(): 'bitmessagesettings', 'maxacceptablepayloadlengthextrabytes', '0') shared.config.set('bitmessagesettings', 'dontconnect', 'true') shared.config.set('bitmessagesettings', 'userlocale', 'system') + + # 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 + # the first time. But you must also add it to the keys.dat file of + # existing users. To do that, search the class_sqlThread.py file for the + # text: "right above this line!" + ensureNamecoinOptions() if storeConfigFilesInSameDirectoryAsProgramByDefault: