function _translate - lighter code

replace QtGui.QApplication.translate with _translate
This commit is contained in:
Gatien Bovyn 2013-06-13 09:59:40 +02:00
parent 11334a0cdf
commit c7358bdb84
1 changed files with 116 additions and 107 deletions

View File

@ -4,6 +4,7 @@ except:
pass pass
try: try:
from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import * from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
except Exception as err: except Exception as err:
@ -11,6 +12,14 @@ except Exception as err:
print 'Error message:', err print 'Error message:', err
sys.exit() sys.exit()
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text):
return QtGui.QApplication.translate(context, text)
except AttributeError:
print 'Error message:', err
withMessagingMenu = False withMessagingMenu = False
try: try:
from gi.repository import MessagingMenu from gi.repository import MessagingMenu
@ -57,7 +66,7 @@ class MyForm(QtGui.QMainWindow):
status, addressVersionNumber, streamNumber, hash = decodeAddress( status, addressVersionNumber, streamNumber, hash = decodeAddress(
addressInKeysFile) addressInKeysFile)
if addressVersionNumber == 1: if addressVersionNumber == 1:
displayMsg = QtGui.QApplication.translate( displayMsg = _translate(
"MainWindow", "One of your addresses, %1, is an old version 1 address. Version 1 addresses are no longer supported. " "MainWindow", "One of your addresses, %1, is an old version 1 address. Version 1 addresses are no longer supported. "
+ "May we delete it now?").arg(addressInKeysFile) + "May we delete it now?").arg(addressInKeysFile)
reply = QtGui.QMessageBox.question( reply = QtGui.QMessageBox.question(
@ -125,13 +134,13 @@ class MyForm(QtGui.QMainWindow):
# Popup menu for the Inbox tab # Popup menu for the Inbox tab
self.ui.inboxContextMenuToolbar = QtGui.QToolBar() self.ui.inboxContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionReply = self.ui.inboxContextMenuToolbar.addAction( self.actionReply = self.ui.inboxContextMenuToolbar.addAction(_translate(
"Reply", self.on_action_InboxReply) "MainWindow", "Reply"), self.on_action_InboxReply)
self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction(_translate(
"MainWindow", "Add sender to your Address Book"), self.on_action_InboxAddSenderToAddressBook) "MainWindow", "Add sender to your Address Book"), self.on_action_InboxAddSenderToAddressBook)
self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction( self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction(
QtGui.QApplication.translate("MainWindow", "Move to Trash"), self.on_action_InboxTrash) _translate("MainWindow", "Move to Trash"), self.on_action_InboxTrash)
self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction(_translate(
"MainWindow", "View HTML code as formatted text"), self.on_action_InboxMessageForceHtml) "MainWindow", "View HTML code as formatted text"), self.on_action_InboxMessageForceHtml)
self.ui.tableWidgetInbox.setContextMenuPolicy( self.ui.tableWidgetInbox.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
@ -148,15 +157,15 @@ class MyForm(QtGui.QMainWindow):
# Popup menu for the Your Identities tab # Popup menu for the Your Identities tab
self.ui.addressContextMenuToolbar = QtGui.QToolBar() self.ui.addressContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionNew = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionNew = self.ui.addressContextMenuToolbar.addAction(_translate(
"MainWindow", "New"), self.on_action_YourIdentitiesNew) "MainWindow", "New"), self.on_action_YourIdentitiesNew)
self.actionEnable = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionEnable = self.ui.addressContextMenuToolbar.addAction(_translate(
"MainWindow", "Enable"), self.on_action_YourIdentitiesEnable) "MainWindow", "Enable"), self.on_action_YourIdentitiesEnable)
self.actionDisable = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionDisable = self.ui.addressContextMenuToolbar.addAction(_translate(
"MainWindow", "Disable"), self.on_action_YourIdentitiesDisable) "MainWindow", "Disable"), self.on_action_YourIdentitiesDisable)
self.actionClipboard = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionClipboard = self.ui.addressContextMenuToolbar.addAction(_translate(
"MainWindow", "Copy address to clipboard"), self.on_action_YourIdentitiesClipboard) "MainWindow", "Copy address to clipboard"), self.on_action_YourIdentitiesClipboard)
self.actionSpecialAddressBehavior = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionSpecialAddressBehavior = self.ui.addressContextMenuToolbar.addAction(_translate(
"MainWindow", "Special address behavior..."), self.on_action_SpecialAddressBehaviorDialog) "MainWindow", "Special address behavior..."), self.on_action_SpecialAddressBehaviorDialog)
self.ui.tableWidgetYourIdentities.setContextMenuPolicy( self.ui.tableWidgetYourIdentities.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
@ -174,13 +183,13 @@ class MyForm(QtGui.QMainWindow):
# Popup menu for the Address Book page # Popup menu for the Address Book page
self.ui.addressBookContextMenuToolbar = QtGui.QToolBar() self.ui.addressBookContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction(_translate(
"MainWindow", "Send message to this address"), self.on_action_AddressBookSend) "MainWindow", "Send message to this address"), self.on_action_AddressBookSend)
self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction(_translate(
"MainWindow", "Copy address to clipboard"), self.on_action_AddressBookClipboard) "MainWindow", "Copy address to clipboard"), self.on_action_AddressBookClipboard)
self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction(_translate(
"MainWindow", "Add New Address"), self.on_action_AddressBookNew) "MainWindow", "Add New Address"), self.on_action_AddressBookNew)
self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction(_translate(
"MainWindow", "Delete"), self.on_action_AddressBookDelete) "MainWindow", "Delete"), self.on_action_AddressBookDelete)
self.ui.tableWidgetAddressBook.setContextMenuPolicy( self.ui.tableWidgetAddressBook.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
@ -197,15 +206,15 @@ class MyForm(QtGui.QMainWindow):
self.ui.subscriptionsContextMenuToolbar = QtGui.QToolBar() self.ui.subscriptionsContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionsubscriptionsNew = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsNew = self.ui.subscriptionsContextMenuToolbar.addAction(
QtGui.QApplication.translate("MainWindow", "New"), self.on_action_SubscriptionsNew) _translate("MainWindow", "New"), self.on_action_SubscriptionsNew)
self.actionsubscriptionsDelete = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsDelete = self.ui.subscriptionsContextMenuToolbar.addAction(
QtGui.QApplication.translate("MainWindow", "Delete"), self.on_action_SubscriptionsDelete) _translate("MainWindow", "Delete"), self.on_action_SubscriptionsDelete)
self.actionsubscriptionsClipboard = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsClipboard = self.ui.subscriptionsContextMenuToolbar.addAction(
QtGui.QApplication.translate("MainWindow", "Copy address to clipboard"), self.on_action_SubscriptionsClipboard) _translate("MainWindow", "Copy address to clipboard"), self.on_action_SubscriptionsClipboard)
self.actionsubscriptionsEnable = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsEnable = self.ui.subscriptionsContextMenuToolbar.addAction(
QtGui.QApplication.translate("MainWindow", "Enable"), self.on_action_SubscriptionsEnable) _translate("MainWindow", "Enable"), self.on_action_SubscriptionsEnable)
self.actionsubscriptionsDisable = self.ui.subscriptionsContextMenuToolbar.addAction( self.actionsubscriptionsDisable = self.ui.subscriptionsContextMenuToolbar.addAction(
QtGui.QApplication.translate("MainWindow", "Disable"), self.on_action_SubscriptionsDisable) _translate("MainWindow", "Disable"), self.on_action_SubscriptionsDisable)
self.ui.tableWidgetSubscriptions.setContextMenuPolicy( self.ui.tableWidgetSubscriptions.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
self.connect(self.ui.tableWidgetSubscriptions, QtCore.SIGNAL( self.connect(self.ui.tableWidgetSubscriptions, QtCore.SIGNAL(
@ -222,11 +231,11 @@ class MyForm(QtGui.QMainWindow):
# Popup menu for the Sent page # Popup menu for the Sent page
self.ui.sentContextMenuToolbar = QtGui.QToolBar() self.ui.sentContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction(_translate(
"MainWindow", "Move to Trash"), self.on_action_SentTrash) "MainWindow", "Move to Trash"), self.on_action_SentTrash)
self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction(_translate(
"MainWindow", "Copy destination address to clipboard"), self.on_action_SentClipboard) "MainWindow", "Copy destination address to clipboard"), self.on_action_SentClipboard)
self.actionForceSend = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionForceSend = self.ui.sentContextMenuToolbar.addAction(_translate(
"MainWindow", "Force send"), self.on_action_ForceSend) "MainWindow", "Force send"), self.on_action_ForceSend)
self.ui.tableWidgetSent.setContextMenuPolicy( self.ui.tableWidgetSent.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
@ -239,15 +248,15 @@ class MyForm(QtGui.QMainWindow):
# Popup menu for the Blacklist page # Popup menu for the Blacklist page
self.ui.blacklistContextMenuToolbar = QtGui.QToolBar() self.ui.blacklistContextMenuToolbar = QtGui.QToolBar()
# Actions # Actions
self.actionBlacklistNew = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionBlacklistNew = self.ui.blacklistContextMenuToolbar.addAction(_translate(
"MainWindow", "Add new entry"), self.on_action_BlacklistNew) "MainWindow", "Add new entry"), self.on_action_BlacklistNew)
self.actionBlacklistDelete = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionBlacklistDelete = self.ui.blacklistContextMenuToolbar.addAction(_translate(
"MainWindow", "Delete"), self.on_action_BlacklistDelete) "MainWindow", "Delete"), self.on_action_BlacklistDelete)
self.actionBlacklistClipboard = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionBlacklistClipboard = self.ui.blacklistContextMenuToolbar.addAction(_translate(
"MainWindow", "Copy address to clipboard"), self.on_action_BlacklistClipboard) "MainWindow", "Copy address to clipboard"), self.on_action_BlacklistClipboard)
self.actionBlacklistEnable = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionBlacklistEnable = self.ui.blacklistContextMenuToolbar.addAction(_translate(
"MainWindow", "Enable"), self.on_action_BlacklistEnable) "MainWindow", "Enable"), self.on_action_BlacklistEnable)
self.actionBlacklistDisable = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( self.actionBlacklistDisable = self.ui.blacklistContextMenuToolbar.addAction(_translate(
"MainWindow", "Disable"), self.on_action_BlacklistDisable) "MainWindow", "Disable"), self.on_action_BlacklistDisable)
self.ui.tableWidgetBlacklist.setContextMenuPolicy( self.ui.tableWidgetBlacklist.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu) QtCore.Qt.CustomContextMenu)
@ -449,37 +458,37 @@ class MyForm(QtGui.QMainWindow):
QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
self.ui.tableWidgetSent.setItem(0, 2, newItem) self.ui.tableWidgetSent.setItem(0, 2, newItem)
if status == 'awaitingpubkey': if status == 'awaitingpubkey':
statusText = QtGui.QApplication.translate( statusText = _translate(
"MainWindow", "Waiting on their encryption key. Will request it again soon.") "MainWindow", "Waiting on their encryption key. Will request it again soon.")
elif status == 'doingpowforpubkey': elif status == 'doingpowforpubkey':
statusText = QtGui.QApplication.translate( statusText = _translate(
"MainWindow", "Encryption key request queued.") "MainWindow", "Encryption key request queued.")
elif status == 'msgqueued': elif status == 'msgqueued':
statusText = QtGui.QApplication.translate( statusText = _translate(
"MainWindow", "Queued.") "MainWindow", "Queued.")
elif status == 'msgsent': elif status == 'msgsent':
statusText = QtGui.QApplication.translate("MainWindow", "Message sent. Waiting on acknowledgement. Sent at %1").arg( statusText = _translate("MainWindow", "Message sent. Waiting on acknowledgement. Sent at %1").arg(
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(lastactiontime)))) unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(lastactiontime))))
elif status == 'doingmsgpow': elif status == 'doingmsgpow':
statusText = QtGui.QApplication.translate( statusText = _translate(
"MainWindow", "Need to do work to send message. Work is queued.") "MainWindow", "Need to do work to send message. Work is queued.")
elif status == 'ackreceived': elif status == 'ackreceived':
statusText = QtGui.QApplication.translate("MainWindow", "Acknowledgement of the message received %1").arg( statusText = _translate("MainWindow", "Acknowledgement of the message received %1").arg(
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime))))) unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
elif status == 'broadcastqueued': elif status == 'broadcastqueued':
statusText = QtGui.QApplication.translate( statusText = _translate(
"MainWindow", "Broadcast queued.") "MainWindow", "Broadcast queued.")
elif status == 'broadcastsent': elif status == 'broadcastsent':
statusText = QtGui.QApplication.translate("MainWindow", "Broadcast on %1").arg(unicode(strftime( statusText = _translate("MainWindow", "Broadcast on %1").arg(unicode(strftime(
shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime))))) shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
elif status == 'toodifficult': elif status == 'toodifficult':
statusText = QtGui.QApplication.translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg( statusText = _translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime))))) unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
elif status == 'forcepow': elif status == 'forcepow':
statusText = QtGui.QApplication.translate( statusText = _translate(
"MainWindow", "Forced difficulty override. Send should start soon.") "MainWindow", "Forced difficulty override. Send should start soon.")
else: else:
statusText = QtGui.QApplication.translate("MainWindow", "Unknown status: %1 %2").arg(status).arg(unicode( statusText = _translate("MainWindow", "Unknown status: %1 %2").arg(status).arg(unicode(
strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime))))) strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime)))))
newItem = myTableWidgetItem(statusText) newItem = myTableWidgetItem(statusText)
newItem.setToolTip(statusText) newItem.setToolTip(statusText)
@ -533,7 +542,7 @@ class MyForm(QtGui.QMainWindow):
# self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png")) # self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
self.statusbar = self.statusBar() self.statusbar = self.statusBar()
self.statusbar.insertPermanentWidget(0, self.ui.pushButtonStatusIcon) self.statusbar.insertPermanentWidget(0, self.ui.pushButtonStatusIcon)
self.ui.labelStartupTime.setText(QtGui.QApplication.translate("MainWindow", "Since startup on %1").arg( self.ui.labelStartupTime.setText(_translate("MainWindow", "Since startup on %1").arg(
unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time())))))) unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time()))))))
self.numberOfMessagesProcessed = 0 self.numberOfMessagesProcessed = 0
self.numberOfBroadcastsProcessed = 0 self.numberOfBroadcastsProcessed = 0
@ -680,7 +689,7 @@ class MyForm(QtGui.QMainWindow):
m = QMenu() m = QMenu()
self.actionStatus = QtGui.QAction(QtGui.QApplication.translate( self.actionStatus = QtGui.QAction(_translate(
"MainWindow", "Not Connected"), m, checkable=False) "MainWindow", "Not Connected"), m, checkable=False)
m.addAction(self.actionStatus) m.addAction(self.actionStatus)
@ -690,7 +699,7 @@ class MyForm(QtGui.QMainWindow):
m.addAction(actionSeparator) m.addAction(actionSeparator)
# show bitmessage # show bitmessage
self.actionShow = QtGui.QAction(QtGui.QApplication.translate( self.actionShow = QtGui.QAction(_translate(
"MainWindow", "Show Bitmessage"), m, checkable=True) "MainWindow", "Show Bitmessage"), m, checkable=True)
self.actionShow.setChecked(not shared.config.getboolean( self.actionShow.setChecked(not shared.config.getboolean(
'bitmessagesettings', 'startintray')) 'bitmessagesettings', 'startintray'))
@ -699,19 +708,19 @@ class MyForm(QtGui.QMainWindow):
m.addAction(self.actionShow) m.addAction(self.actionShow)
# Send # Send
actionSend = QtGui.QAction(QtGui.QApplication.translate( actionSend = QtGui.QAction(_translate(
"MainWindow", "Send"), m, checkable=False) "MainWindow", "Send"), m, checkable=False)
actionSend.triggered.connect(self.appIndicatorSend) actionSend.triggered.connect(self.appIndicatorSend)
m.addAction(actionSend) m.addAction(actionSend)
# Subscribe # Subscribe
actionSubscribe = QtGui.QAction(QtGui.QApplication.translate( actionSubscribe = QtGui.QAction(_translate(
"MainWindow", "Subscribe"), m, checkable=False) "MainWindow", "Subscribe"), m, checkable=False)
actionSubscribe.triggered.connect(self.appIndicatorSubscribe) actionSubscribe.triggered.connect(self.appIndicatorSubscribe)
m.addAction(actionSubscribe) m.addAction(actionSubscribe)
# Address book # Address book
actionAddressBook = QtGui.QAction(QtGui.QApplication.translate( actionAddressBook = QtGui.QAction(_translate(
"MainWindow", "Address Book"), m, checkable=False) "MainWindow", "Address Book"), m, checkable=False)
actionAddressBook.triggered.connect(self.appIndicatorAddressBook) actionAddressBook.triggered.connect(self.appIndicatorAddressBook)
m.addAction(actionAddressBook) m.addAction(actionAddressBook)
@ -722,7 +731,7 @@ class MyForm(QtGui.QMainWindow):
m.addAction(actionSeparator) m.addAction(actionSeparator)
# Quit # Quit
m.addAction(QtGui.QApplication.translate( m.addAction(_translate(
"MainWindow", "Quit"), self.quit) "MainWindow", "Quit"), self.quit)
self.tray.setContextMenu(m) self.tray.setContextMenu(m)
@ -911,24 +920,24 @@ class MyForm(QtGui.QMainWindow):
# may manage your keys by editing the keys.dat file stored in # may manage your keys by editing the keys.dat file stored in
# the same directory as this program. It is important that you # the same directory as this program. It is important that you
# back up this file.', QMessageBox.Ok) # back up this file.', QMessageBox.Ok)
reply = QtGui.QMessageBox.information(self, 'keys.dat?', QtGui.QApplication.translate( reply = QtGui.QMessageBox.information(self, 'keys.dat?', _translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file."), QMessageBox.Ok) "MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file."), QMessageBox.Ok)
else: else:
QtGui.QMessageBox.information(self, 'keys.dat?', QtGui.QApplication.translate( QtGui.QMessageBox.information(self, 'keys.dat?', _translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file.").arg(shared.appdata), QMessageBox.Ok) "MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file.").arg(shared.appdata), QMessageBox.Ok)
elif sys.platform == 'win32' or sys.platform == 'win64': elif sys.platform == 'win32' or sys.platform == 'win64':
if shared.appdata == '': if shared.appdata == '':
reply = QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Open keys.dat?"), QtGui.QApplication.translate( reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) "MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
else: else:
reply = QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Open keys.dat?"), QtGui.QApplication.translate( reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate(
"MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(shared.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) "MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(shared.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:
self.openKeysFile() self.openKeysFile()
def click_actionDeleteAllTrashedMessages(self): def click_actionDeleteAllTrashedMessages(self):
if QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Delete trash?"), QtGui.QApplication.translate("MainWindow", "Are you sure you want to delete all trashed messages?"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: if QtGui.QMessageBox.question(self, _translate("MainWindow", "Delete trash?"), _translate("MainWindow", "Are you sure you want to delete all trashed messages?"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
return return
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('deleteandvacuume') shared.sqlSubmitQueue.put('deleteandvacuume')
@ -939,7 +948,7 @@ class MyForm(QtGui.QMainWindow):
self) self)
if self.regenerateAddressesDialogInstance.exec_(): if self.regenerateAddressesDialogInstance.exec_():
if self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text() == "": if self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text() == "":
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "bad passphrase"), QtGui.QApplication.translate( QMessageBox.about(self, _translate("MainWindow", "bad passphrase"), _translate(
"MainWindow", "You must type your passphrase. If you don\'t have one then this is not the form for you.")) "MainWindow", "You must type your passphrase. If you don\'t have one then this is not the form for you."))
else: else:
streamNumberForAddress = int( streamNumberForAddress = int(
@ -984,17 +993,17 @@ class MyForm(QtGui.QMainWindow):
def incrementNumberOfMessagesProcessed(self): def incrementNumberOfMessagesProcessed(self):
self.numberOfMessagesProcessed += 1 self.numberOfMessagesProcessed += 1
self.ui.labelMessageCount.setText(QtGui.QApplication.translate( self.ui.labelMessageCount.setText(_translate(
"MainWindow", "Processed %1 person-to-person messages.").arg(str(self.numberOfMessagesProcessed))) "MainWindow", "Processed %1 person-to-person messages.").arg(str(self.numberOfMessagesProcessed)))
def incrementNumberOfBroadcastsProcessed(self): def incrementNumberOfBroadcastsProcessed(self):
self.numberOfBroadcastsProcessed += 1 self.numberOfBroadcastsProcessed += 1
self.ui.labelBroadcastCount.setText(QtGui.QApplication.translate( self.ui.labelBroadcastCount.setText(_translate(
"MainWindow", "Processed %1 broadcast messages.").arg(str(self.numberOfBroadcastsProcessed))) "MainWindow", "Processed %1 broadcast messages.").arg(str(self.numberOfBroadcastsProcessed)))
def incrementNumberOfPubkeysProcessed(self): def incrementNumberOfPubkeysProcessed(self):
self.numberOfPubkeysProcessed += 1 self.numberOfPubkeysProcessed += 1
self.ui.labelPubkeyCount.setText(QtGui.QApplication.translate( self.ui.labelPubkeyCount.setText(_translate(
"MainWindow", "Processed %1 public keys.").arg(str(self.numberOfPubkeysProcessed))) "MainWindow", "Processed %1 public keys.").arg(str(self.numberOfPubkeysProcessed)))
def updateNetworkStatusTab(self): def updateNetworkStatusTab(self):
@ -1038,7 +1047,7 @@ class MyForm(QtGui.QMainWindow):
newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled )
self.ui.tableWidgetConnectionCount.setItem(0,1,newItem) self.ui.tableWidgetConnectionCount.setItem(0,1,newItem)
totalNumberOfConnectionsFromAllStreams += connectionCount""" totalNumberOfConnectionsFromAllStreams += connectionCount"""
self.ui.labelTotalConnections.setText(QtGui.QApplication.translate( self.ui.labelTotalConnections.setText(_translate(
"MainWindow", "Total Connections: %1").arg(str(len(shared.connectedHostsList)))) "MainWindow", "Total Connections: %1").arg(str(len(shared.connectedHostsList))))
if len(shared.connectedHostsList) > 0 and shared.statusIconColor == 'red': # FYI: The 'singlelistener' thread sets the icon color to green when it receives an incoming connection, meaning that the user's firewall is configured correctly. if len(shared.connectedHostsList) > 0 and shared.statusIconColor == 'red': # FYI: The 'singlelistener' thread sets the icon color to green when it receives an incoming connection, meaning that the user's firewall is configured correctly.
self.setStatusIcon('yellow') self.setStatusIcon('yellow')
@ -1057,12 +1066,12 @@ class MyForm(QtGui.QMainWindow):
shared.statusIconColor = 'red' shared.statusIconColor = 'red'
# if the connection is lost then show a notification # if the connection is lost then show a notification
if self.connected: if self.connected:
self.notifierShow('Bitmessage', QtGui.QApplication.translate( self.notifierShow('Bitmessage', _translate(
"MainWindow", "Connection lost")) "MainWindow", "Connection lost"))
self.connected = False self.connected = False
if self.actionStatus is not None: if self.actionStatus is not None:
self.actionStatus.setText(QtGui.QApplication.translate( self.actionStatus.setText(_translate(
"MainWindow", "Not Connected")) "MainWindow", "Not Connected"))
self.tray.setIcon(QtGui.QIcon( self.tray.setIcon(QtGui.QIcon(
":/newPrefix/images/can-icon-24px-red.png")) ":/newPrefix/images/can-icon-24px-red.png"))
@ -1074,12 +1083,12 @@ class MyForm(QtGui.QMainWindow):
shared.statusIconColor = 'yellow' shared.statusIconColor = 'yellow'
# if a new connection has been established then show a notification # if a new connection has been established then show a notification
if not self.connected: if not self.connected:
self.notifierShow('Bitmessage', QtGui.QApplication.translate( self.notifierShow('Bitmessage', _translate(
"MainWindow", "Connected")) "MainWindow", "Connected"))
self.connected = True self.connected = True
if self.actionStatus is not None: if self.actionStatus is not None:
self.actionStatus.setText(QtGui.QApplication.translate( self.actionStatus.setText(_translate(
"MainWindow", "Connected")) "MainWindow", "Connected"))
self.tray.setIcon(QtGui.QIcon( self.tray.setIcon(QtGui.QIcon(
":/newPrefix/images/can-icon-24px-yellow.png")) ":/newPrefix/images/can-icon-24px-yellow.png"))
@ -1090,12 +1099,12 @@ class MyForm(QtGui.QMainWindow):
QIcon(":/newPrefix/images/greenicon.png")) QIcon(":/newPrefix/images/greenicon.png"))
shared.statusIconColor = 'green' shared.statusIconColor = 'green'
if not self.connected: if not self.connected:
self.notifierShow('Bitmessage', QtGui.QApplication.translate( self.notifierShow('Bitmessage', _translate(
"MainWindow", "Connected")) "MainWindow", "Connected"))
self.connected = True self.connected = True
if self.actionStatus is not None: if self.actionStatus is not None:
self.actionStatus.setText(QtGui.QApplication.translate( self.actionStatus.setText(_translate(
"MainWindow", "Connected")) "MainWindow", "Connected"))
self.tray.setIcon(QtGui.QIcon( self.tray.setIcon(QtGui.QIcon(
":/newPrefix/images/can-icon-24px-green.png")) ":/newPrefix/images/can-icon-24px-green.png"))
@ -1135,7 +1144,7 @@ class MyForm(QtGui.QMainWindow):
def removeInboxRowByMsgid(self, msgid): # msgid and inventoryHash are the same thing def removeInboxRowByMsgid(self, msgid): # msgid and inventoryHash are the same thing
for i in range(self.ui.tableWidgetInbox.rowCount()): for i in range(self.ui.tableWidgetInbox.rowCount()):
if msgid == str(self.ui.tableWidgetInbox.item(i, 3).data(Qt.UserRole).toPyObject()): if msgid == str(self.ui.tableWidgetInbox.item(i, 3).data(Qt.UserRole).toPyObject()):
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Message trashed")) "MainWindow", "Message trashed"))
self.ui.tableWidgetInbox.removeRow(i) self.ui.tableWidgetInbox.removeRow(i)
break break
@ -1269,28 +1278,28 @@ class MyForm(QtGui.QMainWindow):
print 'Error: Could not decode', toAddress, ':', status print 'Error: Could not decode', toAddress, ':', status
shared.printLock.release() shared.printLock.release()
if status == 'missingbm': if status == 'missingbm':
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: Bitmessage addresses start with BM- Please check %1").arg(toAddress)) "MainWindow", "Error: Bitmessage addresses start with BM- Please check %1").arg(toAddress))
elif status == 'checksumfailed': elif status == 'checksumfailed':
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: The address %1 is not typed or copied correctly. Please check it.").arg(toAddress)) "MainWindow", "Error: The address %1 is not typed or copied correctly. Please check it.").arg(toAddress))
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: The address %1 contains invalid characters. Please check it.").arg(toAddress)) "MainWindow", "Error: The address %1 contains invalid characters. Please check it.").arg(toAddress))
elif status == 'versiontoohigh': elif status == 'versiontoohigh':
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: The address version in %1 is too high. Either you need to upgrade your Bitmessage software or your acquaintance is being clever.").arg(toAddress)) "MainWindow", "Error: The address version in %1 is too high. Either you need to upgrade your Bitmessage software or your acquaintance is being clever.").arg(toAddress))
elif status == 'ripetooshort': elif status == 'ripetooshort':
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: Some data encoded in the address %1 is too short. There might be something wrong with the software of your acquaintance.").arg(toAddress)) "MainWindow", "Error: Some data encoded in the address %1 is too short. There might be something wrong with the software of your acquaintance.").arg(toAddress))
elif status == 'ripetoolong': elif status == 'ripetoolong':
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: Some data encoded in the address %1 is too long. There might be something wrong with the software of your acquaintance.").arg(toAddress)) "MainWindow", "Error: Some data encoded in the address %1 is too long. There might be something wrong with the software of your acquaintance.").arg(toAddress))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: Something is wrong with the address %1.").arg(toAddress)) "MainWindow", "Error: Something is wrong with the address %1.").arg(toAddress))
elif fromAddress == '': elif fromAddress == '':
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.")) "MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab."))
else: else:
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
@ -1299,22 +1308,22 @@ class MyForm(QtGui.QMainWindow):
# The toAddress is one owned by me. We cannot send # The toAddress is one owned by me. We cannot send
# messages to ourselves without significant changes # messages to ourselves without significant changes
# to the codebase. # to the codebase.
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Sending to your address"), QtGui.QApplication.translate( QMessageBox.about(self, _translate("MainWindow", "Sending to your address"), _translate(
"MainWindow", "Error: One of the addresses to which you are sending a message, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM.").arg(toAddress)) "MainWindow", "Error: One of the addresses to which you are sending a message, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM.").arg(toAddress))
continue continue
except: except:
pass pass
if addressVersionNumber > 3 or addressVersionNumber <= 1: if addressVersionNumber > 3 or addressVersionNumber <= 1:
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Address version number"), QtGui.QApplication.translate( QMessageBox.about(self, _translate("MainWindow", "Address version number"), _translate(
"MainWindow", "Concerning the address %1, Bitmessage cannot understand address version numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(addressVersionNumber))) "MainWindow", "Concerning the address %1, Bitmessage cannot understand address version numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(addressVersionNumber)))
continue continue
if streamNumber > 1 or streamNumber == 0: if streamNumber > 1 or streamNumber == 0:
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Stream number"), QtGui.QApplication.translate( QMessageBox.about(self, _translate("MainWindow", "Stream number"), _translate(
"MainWindow", "Concerning the address %1, Bitmessage cannot handle stream numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(streamNumber))) "MainWindow", "Concerning the address %1, Bitmessage cannot handle stream numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(streamNumber)))
continue continue
self.statusBar().showMessage('') self.statusBar().showMessage('')
if shared.statusIconColor == 'red': if shared.statusIconColor == 'red':
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.")) "MainWindow", "Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect."))
ackdata = OpenSSL.rand(32) ackdata = OpenSSL.rand(32)
shared.sqlLock.acquire() shared.sqlLock.acquire()
@ -1351,11 +1360,11 @@ class MyForm(QtGui.QMainWindow):
self.ui.tabWidget.setCurrentIndex(2) self.ui.tabWidget.setCurrentIndex(2)
self.ui.tableWidgetSent.setCurrentCell(0, 0) self.ui.tableWidgetSent.setCurrentCell(0, 0)
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Your \'To\' field is empty.")) "MainWindow", "Your \'To\' field is empty."))
else: # User selected 'Broadcast' else: # User selected 'Broadcast'
if fromAddress == '': if fromAddress == '':
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.")) "MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab."))
else: else:
self.statusBar().showMessage('') self.statusBar().showMessage('')
@ -1428,7 +1437,7 @@ class MyForm(QtGui.QMainWindow):
time.sleep(0.1) time.sleep(0.1)
self.statusBar().showMessage('') self.statusBar().showMessage('')
time.sleep(0.1) time.sleep(0.1)
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Right click one or more entries in your address book and select \'Send message to this address\'.")) "MainWindow", "Right click one or more entries in your address book and select \'Send message to this address\'."))
def redrawLabelFrom(self, index): def redrawLabelFrom(self, index):
@ -1621,10 +1630,10 @@ class MyForm(QtGui.QMainWindow):
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
self.rerenderSentToLabels() self.rerenderSentToLabels()
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.")) "MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want."))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "The address you entered was invalid. Ignoring it.")) "MainWindow", "The address you entered was invalid. Ignoring it."))
def click_pushButtonAddSubscription(self): def click_pushButtonAddSubscription(self):
@ -1667,10 +1676,10 @@ class MyForm(QtGui.QMainWindow):
self.rerenderInboxFromLabels() self.rerenderInboxFromLabels()
shared.reloadBroadcastSendersForWhichImWatching() shared.reloadBroadcastSendersForWhichImWatching()
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: You cannot add the same address to your subsciptions twice. Perhaps rename the existing one if you want.")) "MainWindow", "Error: You cannot add the same address to your subsciptions twice. Perhaps rename the existing one if you want."))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "The address you entered was invalid. Ignoring it.")) "MainWindow", "The address you entered was invalid. Ignoring it."))
def loadBlackWhiteList(self): def loadBlackWhiteList(self):
@ -1726,13 +1735,13 @@ class MyForm(QtGui.QMainWindow):
shared.config.set('bitmessagesettings', 'startintray', str( shared.config.set('bitmessagesettings', 'startintray', str(
self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked())) self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked()))
if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()): if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()):
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Restart"), QtGui.QApplication.translate( QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate(
"MainWindow", "You must restart Bitmessage for the port number change to take effect.")) "MainWindow", "You must restart Bitmessage for the port number change to take effect."))
shared.config.set('bitmessagesettings', 'port', str( shared.config.set('bitmessagesettings', 'port', str(
self.settingsDialogInstance.ui.lineEditTCPPort.text())) self.settingsDialogInstance.ui.lineEditTCPPort.text()))
if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5] == 'SOCKS': if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5] == 'SOCKS':
if shared.statusIconColor != 'red': if shared.statusIconColor != 'red':
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Restart"), QtGui.QApplication.translate( 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.")) "MainWindow", "Bitmessage will use your proxy from now on but you may want to manually restart Bitmessage now to close existing connections."))
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 str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText()) == 'none':
self.statusBar().showMessage('') self.statusBar().showMessage('')
@ -1886,10 +1895,10 @@ class MyForm(QtGui.QMainWindow):
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
shared.sqlLock.release() shared.sqlLock.release()
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: You cannot add the same address to your list twice. Perhaps rename the existing one if you want.")) "MainWindow", "Error: You cannot add the same address to your list twice. Perhaps rename the existing one if you want."))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "The address you entered was invalid. Ignoring it.")) "MainWindow", "The address you entered was invalid. Ignoring it."))
def on_action_SpecialAddressBehaviorDialog(self): def on_action_SpecialAddressBehaviorDialog(self):
@ -1942,11 +1951,11 @@ class MyForm(QtGui.QMainWindow):
self.dialog.ui.newaddresslabel.text().toUtf8()), 1, "", self.dialog.ui.checkBoxEighteenByteRipe.isChecked())) self.dialog.ui.newaddresslabel.text().toUtf8()), 1, "", self.dialog.ui.checkBoxEighteenByteRipe.isChecked()))
else: else:
if self.dialog.ui.lineEditPassphrase.text() != self.dialog.ui.lineEditPassphraseAgain.text(): if self.dialog.ui.lineEditPassphrase.text() != self.dialog.ui.lineEditPassphraseAgain.text():
QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Passphrase mismatch"), QtGui.QApplication.translate( QMessageBox.about(self, _translate("MainWindow", "Passphrase mismatch"), _translate(
"MainWindow", "The passphrase you entered twice doesn\'t match. Try again.")) "MainWindow", "The passphrase you entered twice doesn\'t match. Try again."))
elif self.dialog.ui.lineEditPassphrase.text() == "": elif self.dialog.ui.lineEditPassphrase.text() == "":
QMessageBox.about(self, QtGui.QApplication.translate( QMessageBox.about(self, _translate(
"MainWindow", "Choose a passphrase"), QtGui.QApplication.translate("MainWindow", "You really do need a passphrase.")) "MainWindow", "Choose a passphrase"), _translate("MainWindow", "You really do need a passphrase."))
else: else:
streamNumberForAddress = 1 # this will eventually have to be replaced by logic to determine the most available stream number. streamNumberForAddress = 1 # this will eventually have to be replaced by logic to determine the most available stream number.
# self.addressGenerator = addressGenerator() # self.addressGenerator = addressGenerator()
@ -1973,7 +1982,7 @@ class MyForm(QtGui.QMainWindow):
# unregister the messaging system # unregister the messaging system
if self.mmapp is not None: if self.mmapp is not None:
self.mmapp.unregister() self.mmapp.unregister()
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "All done. Closing user interface...")) "MainWindow", "All done. Closing user interface..."))
os._exit(0) os._exit(0)
@ -2021,11 +2030,11 @@ class MyForm(QtGui.QMainWindow):
if toAddressAtCurrentInboxRow == self.str_broadcast_subscribers: if toAddressAtCurrentInboxRow == self.str_broadcast_subscribers:
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
elif not shared.config.has_section(toAddressAtCurrentInboxRow): elif not shared.config.has_section(toAddressAtCurrentInboxRow):
QtGui.QMessageBox.information(self, QtGui.QApplication.translate("MainWindow", "Address is gone"), QtGui.QApplication.translate( QtGui.QMessageBox.information(self, _translate("MainWindow", "Address is gone"), _translate(
"MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(toAddressAtCurrentInboxRow), QMessageBox.Ok) "MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(toAddressAtCurrentInboxRow), QMessageBox.Ok)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
elif not shared.config.getboolean(toAddressAtCurrentInboxRow, 'enabled'): elif not shared.config.getboolean(toAddressAtCurrentInboxRow, 'enabled'):
QtGui.QMessageBox.information(self, QtGui.QApplication.translate("MainWindow", "Address disabled"), QtGui.QApplication.translate( QtGui.QMessageBox.information(self, _translate("MainWindow", "Address disabled"), _translate(
"MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok) "MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok)
self.ui.labelFrom.setText('') self.ui.labelFrom.setText('')
else: else:
@ -2077,10 +2086,10 @@ class MyForm(QtGui.QMainWindow):
shared.sqlLock.release() shared.sqlLock.release()
self.ui.tabWidget.setCurrentIndex(5) self.ui.tabWidget.setCurrentIndex(5)
self.ui.tableWidgetAddressBook.setCurrentCell(0, 0) self.ui.tableWidgetAddressBook.setCurrentCell(0, 0)
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Entry added to the Address Book. Edit the label to your liking.")) "MainWindow", "Entry added to the Address Book. Edit the label to your liking."))
else: else:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.")) "MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want."))
# Send item on the Inbox tab to trash # Send item on the Inbox tab to trash
@ -2098,7 +2107,7 @@ class MyForm(QtGui.QMainWindow):
shared.sqlLock.release() shared.sqlLock.release()
self.ui.textEditInboxMessage.setText("") self.ui.textEditInboxMessage.setText("")
self.ui.tableWidgetInbox.removeRow(currentRow) self.ui.tableWidgetInbox.removeRow(currentRow)
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.")) "MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back."))
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -2123,7 +2132,7 @@ class MyForm(QtGui.QMainWindow):
shared.sqlLock.release() shared.sqlLock.release()
self.ui.textEditSentMessage.setPlainText("") self.ui.textEditSentMessage.setPlainText("")
self.ui.tableWidgetSent.removeRow(currentRow) self.ui.tableWidgetSent.removeRow(currentRow)
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.")) "MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back."))
shared.sqlLock.acquire() shared.sqlLock.acquire()
shared.sqlSubmitQueue.put('commit') shared.sqlSubmitQueue.put('commit')
@ -2217,7 +2226,7 @@ class MyForm(QtGui.QMainWindow):
self.ui.lineEditTo.setText(str( self.ui.lineEditTo.setText(str(
self.ui.lineEditTo.text()) + '; ' + str(addressAtCurrentRow)) self.ui.lineEditTo.text()) + '; ' + str(addressAtCurrentRow))
if listOfSelectedRows == {}: if listOfSelectedRows == {}:
self.statusBar().showMessage(QtGui.QApplication.translate( self.statusBar().showMessage(_translate(
"MainWindow", "No addresses selected.")) "MainWindow", "No addresses selected."))
else: else:
self.statusBar().showMessage('') self.statusBar().showMessage('')
@ -2630,12 +2639,12 @@ class settingsDialog(QtGui.QDialog):
self.ui.checkBoxStartOnLogon.setDisabled(True) self.ui.checkBoxStartOnLogon.setDisabled(True)
self.ui.checkBoxMinimizeToTray.setDisabled(True) self.ui.checkBoxMinimizeToTray.setDisabled(True)
self.ui.checkBoxShowTrayNotifications.setDisabled(True) self.ui.checkBoxShowTrayNotifications.setDisabled(True)
self.ui.labelSettingsNote.setText(QtGui.QApplication.translate( self.ui.labelSettingsNote.setText(_translate(
"MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system.")) "MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system."))
elif 'linux' in sys.platform: elif 'linux' in sys.platform:
self.ui.checkBoxStartOnLogon.setDisabled(True) self.ui.checkBoxStartOnLogon.setDisabled(True)
self.ui.checkBoxMinimizeToTray.setDisabled(True) self.ui.checkBoxMinimizeToTray.setDisabled(True)
self.ui.labelSettingsNote.setText(QtGui.QApplication.translate( self.ui.labelSettingsNote.setText(_translate(
"MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system.")) "MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system."))
# On the Network settings tab: # On the Network settings tab:
self.ui.lineEditTCPPort.setText(str( self.ui.lineEditTCPPort.setText(str(
@ -2753,26 +2762,26 @@ class NewSubscriptionDialog(QtGui.QDialog):
def subscriptionAddressChanged(self, QString): def subscriptionAddressChanged(self, QString):
status, a, b, c = decodeAddress(str(QString)) status, a, b, c = decodeAddress(str(QString))
if status == 'missingbm': if status == 'missingbm':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( self.ui.labelSubscriptionAddressCheck.setText(_translate(
"MainWindow", "The address should start with ''BM-''")) "MainWindow", "The address should start with ''BM-''"))
elif status == 'checksumfailed': elif status == 'checksumfailed':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( self.ui.labelSubscriptionAddressCheck.setText(_translate(
"MainWindow", "The address is not typed or copied correctly (the checksum failed).")) "MainWindow", "The address is not typed or copied correctly (the checksum failed)."))
elif status == 'versiontoohigh': elif status == 'versiontoohigh':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( self.ui.labelSubscriptionAddressCheck.setText(_translate(
"MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage.")) "MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage."))
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( self.ui.labelSubscriptionAddressCheck.setText(_translate(
"MainWindow", "The address contains invalid characters.")) "MainWindow", "The address contains invalid characters."))
elif status == 'ripetooshort': elif status == 'ripetooshort':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( self.ui.labelSubscriptionAddressCheck.setText(_translate(
"MainWindow", "Some data encoded in the address is too short.")) "MainWindow", "Some data encoded in the address is too short."))
elif status == 'ripetoolong': elif status == 'ripetoolong':
self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( self.ui.labelSubscriptionAddressCheck.setText(_translate(
"MainWindow", "Some data encoded in the address is too long.")) "MainWindow", "Some data encoded in the address is too long."))
elif status == 'success': elif status == 'success':
self.ui.labelSubscriptionAddressCheck.setText( self.ui.labelSubscriptionAddressCheck.setText(
QtGui.QApplication.translate("MainWindow", "Address is valid.")) _translate("MainWindow", "Address is valid."))
class NewAddressDialog(QtGui.QDialog): class NewAddressDialog(QtGui.QDialog):
@ -2803,7 +2812,7 @@ class iconGlossaryDialog(QtGui.QDialog):
self.ui = Ui_iconGlossaryDialog() self.ui = Ui_iconGlossaryDialog()
self.ui.setupUi(self) self.ui.setupUi(self)
self.parent = parent self.parent = parent
self.ui.labelPortNumber.setText(QtGui.QApplication.translate( self.ui.labelPortNumber.setText(_translate(
"MainWindow", "You are using TCP port %1. (This can be changed in the settings).").arg(str(shared.config.getint('bitmessagesettings', 'port')))) "MainWindow", "You are using TCP port %1. (This can be changed in the settings).").arg(str(shared.config.getint('bitmessagesettings', 'port'))))
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self)) QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))