Simplified showing statusbar messages:

- Use MyForm.statusbar set in __init__ instead of MyForm.statusBar()
 - MyForm.updateStatusBar() to show the message in MyForm methods
 - queues.UISignalQueue.put(('updateStatusBar', msg)) in dialogs
This commit is contained in:
Dmitri Bogomolov 2018-01-23 18:15:11 +02:00
parent ece5ad9113
commit 41155406d6
Signed by untrusted user: g1itch
GPG Key ID: 720A756F18DEED13
2 changed files with 237 additions and 134 deletions

View File

@ -1522,7 +1522,6 @@ class MyForm(settingsmixin.SMainWindow):
pass pass
# QtGui.QWidget.changeEvent(self, event) # QtGui.QWidget.changeEvent(self, event)
def __icon_activated(self, reason): def __icon_activated(self, reason):
if reason == QtGui.QSystemTrayIcon.Trigger: if reason == QtGui.QSystemTrayIcon.Trigger:
self.actionShow.setChecked(not self.actionShow.isChecked()) self.actionShow.setChecked(not self.actionShow.isChecked())
@ -1547,8 +1546,12 @@ class MyForm(settingsmixin.SMainWindow):
sound.SOUND_DISCONNECTED) sound.SOUND_DISCONNECTED)
if not BMConfigParser().safeGetBoolean('bitmessagesettings', 'upnp') and \ if not BMConfigParser().safeGetBoolean('bitmessagesettings', 'upnp') and \
BMConfigParser().get('bitmessagesettings', 'socksproxytype') == "none": BMConfigParser().get('bitmessagesettings', 'socksproxytype') == "none":
self.statusBar().showMessage(_translate( self.updateStatusBar(
"MainWindow", "Problems connecting? Try enabling UPnP in the Network Settings"), 10000) _translate(
"MainWindow",
"Problems connecting? Try enabling UPnP in the Network"
" Settings"
))
self.connected = False self.connected = False
if self.actionStatus is not None: if self.actionStatus is not None:
@ -1556,8 +1559,8 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "Not Connected")) "MainWindow", "Not Connected"))
self.setTrayIconFile("can-icon-24px-red.png") self.setTrayIconFile("can-icon-24px-red.png")
if color == 'yellow': if color == 'yellow':
if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.': if self.statusbar.currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
self.statusBar().clearMessage() self.statusbar.clearMessage()
self.pushButtonStatusIcon.setIcon( self.pushButtonStatusIcon.setIcon(
QtGui.QIcon(":/newPrefix/images/yellowicon.png")) QtGui.QIcon(":/newPrefix/images/yellowicon.png"))
shared.statusIconColor = 'yellow' shared.statusIconColor = 'yellow'
@ -1574,8 +1577,8 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "Connected")) "MainWindow", "Connected"))
self.setTrayIconFile("can-icon-24px-yellow.png") self.setTrayIconFile("can-icon-24px-yellow.png")
if color == 'green': if color == 'green':
if self.statusBar().currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.': if self.statusbar.currentMessage() == 'Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.':
self.statusBar().clearMessage() self.statusbar.clearMessage()
self.pushButtonStatusIcon.setIcon( self.pushButtonStatusIcon.setIcon(
QtGui.QIcon(":/newPrefix/images/greenicon.png")) QtGui.QIcon(":/newPrefix/images/greenicon.png"))
shared.statusIconColor = 'green' shared.statusIconColor = 'green'
@ -1705,8 +1708,8 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.tableWidgetInboxChans]): self.ui.tableWidgetInboxChans]):
for i in range(inbox.rowCount()): for i in range(inbox.rowCount()):
if msgid == str(inbox.item(i, 3).data(QtCore.Qt.UserRole).toPyObject()): if msgid == str(inbox.item(i, 3).data(QtCore.Qt.UserRole).toPyObject()):
self.statusBar().showMessage(_translate( self.updateStatusBar(
"MainWindow", "Message trashed"), 10000) _translate("MainWindow", "Message trashed"))
treeWidget = self.widgetConvert(inbox) treeWidget = self.widgetConvert(inbox)
self.propagateUnreadCount(inbox.item(i, 1 if inbox.item(i, 1).type == AccountMixin.SUBSCRIPTION else 0).data(QtCore.Qt.UserRole), self.getCurrentFolder(treeWidget), treeWidget, 0) self.propagateUnreadCount(inbox.item(i, 1 if inbox.item(i, 1).type == AccountMixin.SUBSCRIPTION else 0).data(QtCore.Qt.UserRole), self.getCurrentFolder(treeWidget), treeWidget, 0)
inbox.removeRow(i) inbox.removeRow(i)
@ -1714,10 +1717,15 @@ class MyForm(settingsmixin.SMainWindow):
def newVersionAvailable(self, version): def newVersionAvailable(self, version):
self.notifiedNewVersion = ".".join(str(n) for n in version) self.notifiedNewVersion = ".".join(str(n) for n in version)
self.statusBar().showMessage(_translate("MainWindow", "New version of PyBitmessage is available: %1. Download it from https://github.com/Bitmessage/PyBitmessage/releases/latest").arg(self.notifiedNewVersion), 10000) self.updateStatusBar(_translate(
"MainWindow",
"New version of PyBitmessage is available: %1. Download it"
" from https://github.com/Bitmessage/PyBitmessage/releases/latest"
).arg(self.notifiedNewVersion)
)
def displayAlert(self, title, text, exitAfterUserClicksOk): def displayAlert(self, title, text, exitAfterUserClicksOk):
self.statusBar().showMessage(text) self.updateStatusBar(text)
QtGui.QMessageBox.critical(self, title, text, QtGui.QMessageBox.Ok) QtGui.QMessageBox.critical(self, title, text, QtGui.QMessageBox.Ok)
if exitAfterUserClicksOk: if exitAfterUserClicksOk:
os._exit(0) os._exit(0)
@ -1799,7 +1807,7 @@ class MyForm(settingsmixin.SMainWindow):
def click_pushButtonSend(self): def click_pushButtonSend(self):
encoding = 3 if QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier else 2 encoding = 3 if QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier else 2
self.statusBar().clearMessage() self.statusbar.clearMessage()
if self.ui.tabWidgetSend.currentIndex() == \ if self.ui.tabWidgetSend.currentIndex() == \
self.ui.tabWidgetSend.indexOf(self.ui.sendDirect): self.ui.tabWidgetSend.indexOf(self.ui.sendDirect):
@ -1871,8 +1879,14 @@ class MyForm(settingsmixin.SMainWindow):
BMConfigParser().set(fromAddress, 'label', email) BMConfigParser().set(fromAddress, 'label', email)
BMConfigParser().set(fromAddress, 'gateway', 'mailchuck') BMConfigParser().set(fromAddress, 'gateway', 'mailchuck')
BMConfigParser().save() BMConfigParser().save()
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: Your account wasn't registered at an email gateway. Sending registration now as %1, please wait for the registration to be processed before retrying sending.").arg(email), 10000) "MainWindow",
"Error: Your account wasn't registered at"
" an email gateway. Sending registration"
" now as %1, please wait for the registration"
" to be processed before retrying sending."
).arg(email)
)
return return
status, addressVersionNumber, streamNumber, ripe = decodeAddress( status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress) toAddress)
@ -1884,32 +1898,68 @@ class MyForm(settingsmixin.SMainWindow):
logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status) logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status)
if status == 'missingbm': if status == 'missingbm':
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: Bitmessage addresses start with BM- Please check the recipient address %1").arg(toAddress), 10000) "MainWindow",
"Error: Bitmessage addresses start with"
" BM- Please check the recipient address %1"
).arg(toAddress))
elif status == 'checksumfailed': elif status == 'checksumfailed':
self.statusBar().showMessage(_translate( self.statusbar_message(_translate(
"MainWindow", "Error: The recipient address %1 is not typed or copied correctly. Please check it.").arg(toAddress), 10000) "MainWindow",
"Error: The recipient address %1 is not"
" typed or copied correctly. Please check it."
).arg(toAddress))
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: The recipient address %1 contains invalid characters. Please check it.").arg(toAddress), 10000) "MainWindow",
"Error: The recipient address %1 contains"
" invalid characters. Please check it."
).arg(toAddress))
elif status == 'versiontoohigh': elif status == 'versiontoohigh':
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: The version of the recipient address %1 is too high. Either you need to upgrade your Bitmessage software or your acquaintance is being clever.").arg(toAddress), 10000) "MainWindow",
"Error: The version of the recipient address"
" %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(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: Some data encoded in the recipient address %1 is too short. There might be something wrong with the software of your acquaintance.").arg(toAddress), 10000) "MainWindow",
"Error: Some data encoded in the recipient"
" 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(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: Some data encoded in the recipient address %1 is too long. There might be something wrong with the software of your acquaintance.").arg(toAddress), 10000) "MainWindow",
"Error: Some data encoded in the recipient"
" address %1 is too long. There might be"
" something wrong with the software of"
" your acquaintance."
).arg(toAddress))
elif status == 'varintmalformed': elif status == 'varintmalformed':
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: Some data encoded in the recipient address %1 is malformed. There might be something wrong with the software of your acquaintance.").arg(toAddress), 10000) "MainWindow",
"Error: Some data encoded in the recipient"
" address %1 is malformed. There might be"
" something wrong with the software of"
" your acquaintance."
).arg(toAddress))
else: else:
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: Something is wrong with the recipient address %1.").arg(toAddress), 10000) "MainWindow",
"Error: Something is wrong with the"
" recipient address %1."
).arg(toAddress))
elif fromAddress == '': elif fromAddress == '':
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab."), 10000) "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)
@ -1921,11 +1971,17 @@ class MyForm(settingsmixin.SMainWindow):
QtGui.QMessageBox.about(self, _translate("MainWindow", "Stream number"), _translate( QtGui.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().clearMessage() self.statusbar.clearMessage()
if shared.statusIconColor == 'red': if shared.statusIconColor == 'red':
self.statusBar().showMessage(_translate( self.updateStatusBar(_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",
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel') "Warning: You are currently not connected."
" Bitmessage will do the work necessary to"
" send the message but it won\'t send until"
" you connect.")
)
stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel')
ackdata = genAckPayload(streamNumber, stealthLevel) ackdata = genAckPayload(streamNumber, stealthLevel)
t = () t = ()
sqlExecute( sqlExecute(
@ -1965,18 +2021,21 @@ class MyForm(settingsmixin.SMainWindow):
if self.replyFromTab is not None: if self.replyFromTab is not None:
self.ui.tabWidget.setCurrentIndex(self.replyFromTab) self.ui.tabWidget.setCurrentIndex(self.replyFromTab)
self.replyFromTab = None self.replyFromTab = None
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Message queued."), 10000) "MainWindow", "Message queued."))
#self.ui.tableWidgetInbox.setCurrentCell(0, 0) # self.ui.tableWidgetInbox.setCurrentCell(0, 0)
else: else:
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Your \'To\' field is empty."), 10000) "MainWindow", "Your \'To\' field is empty."))
else: # User selected 'Broadcast' else: # User selected 'Broadcast'
if fromAddress == '': if fromAddress == '':
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab."), 10000) "MainWindow",
"Error: You must specify a From address. If you don\'t"
" have one, go to the \'Your Identities\' tab."
))
else: else:
self.statusBar().clearMessage() self.statusbar.clearMessage()
# We don't actually need the ackdata for acknowledgement since # We don't actually need the ackdata for acknowledgement since
# this is a broadcast message, but we can use it to update the # this is a broadcast message, but we can use it to update the
# user interface when the POW is done generating. # user interface when the POW is done generating.
@ -2016,30 +2075,32 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.tabWidget.indexOf(self.ui.send) self.ui.tabWidget.indexOf(self.ui.send)
) )
self.ui.tableWidgetInboxSubscriptions.setCurrentCell(0, 0) self.ui.tableWidgetInboxSubscriptions.setCurrentCell(0, 0)
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Broadcast queued."), 10000) "MainWindow", "Broadcast queued."))
def click_pushButtonLoadFromAddressBook(self): def click_pushButtonLoadFromAddressBook(self):
self.ui.tabWidget.setCurrentIndex(5) self.ui.tabWidget.setCurrentIndex(5)
for i in range(4): for i in range(4):
time.sleep(0.1) time.sleep(0.1)
self.statusBar().clearMessage() self.statusbar.clearMessage()
time.sleep(0.1) time.sleep(0.1)
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Right click one or more entries in your address book and select \'Send message to this address\'."), 10000) "MainWindow",
"Right click one or more entries in your address book and"
" select \'Send message to this address\'."
))
def click_pushButtonFetchNamecoinID(self): def click_pushButtonFetchNamecoinID(self):
nc = namecoinConnection() nc = namecoinConnection()
identities = str(self.ui.lineEditTo.text().toUtf8()).split(";") identities = str(self.ui.lineEditTo.text().toUtf8()).split(";")
err, addr = nc.query(identities[-1].strip()) err, addr = nc.query(identities[-1].strip())
if err is not None: if err is not None:
self.statusBar().showMessage(_translate( self.statusbar_message("Error: %1", args=[err])
"MainWindow", "Error: %1").arg(err), 10000)
else: else:
identities[-1] = addr identities[-1] = addr
self.ui.lineEditTo.setText("; ".join(identities)) self.ui.lineEditTo.setText("; ".join(identities))
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Fetched address from namecoin identity."), 10000) "MainWindow", "Fetched address from namecoin identity."))
def setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(self, address): def setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(self, address):
# If this is a chan then don't let people broadcast because no one # If this is a chan then don't let people broadcast because no one
@ -2183,23 +2244,22 @@ class MyForm(settingsmixin.SMainWindow):
dialog = dialogs.AddAddressDialog(self) dialog = dialogs.AddAddressDialog(self)
if dialog.exec_(): if dialog.exec_():
if not dialog.valid: if not dialog.valid:
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"The address you entered was invalid. Ignoring it." "The address you entered was invalid. Ignoring it."
), 10000) ))
return return
address = addBMIfNotPresent(str(dialog.lineEditAddress.text())) address = addBMIfNotPresent(str(dialog.lineEditAddress.text()))
# First we must check to see if the address is already in the # First we must check to see if the address is already in the
# address book. The user cannot add it again or else it will # address book. The user cannot add it again or else it will
# cause problems when updating and deleting the entry. # cause problems when updating and deleting the entry.
if shared.isAddressInMyAddressBook(address): if shared.isAddressInMyAddressBook(address):
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: You cannot add the same address to your" "Error: You cannot add the same address to your"
" address book twice. Try renaming the existing one" " address book twice. Try renaming the existing one"
" if you want." " if you want."
), 10000) ))
return return
label = str(dialog.lineEditLabel.text().toUtf8()) label = str(dialog.lineEditLabel.text().toUtf8())
self.addEntryToAddressBook(address, label) self.addEntryToAddressBook(address, label)
@ -2231,23 +2291,22 @@ class MyForm(settingsmixin.SMainWindow):
dialog = dialogs.NewSubscriptionDialog(self) dialog = dialogs.NewSubscriptionDialog(self)
if dialog.exec_(): if dialog.exec_():
if not dialog.valid: if not dialog.valid:
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"The address you entered was invalid. Ignoring it." "The address you entered was invalid. Ignoring it."
), 10000) ))
return return
address = addBMIfNotPresent(str(dialog.lineEditAddress.text())) address = addBMIfNotPresent(str(dialog.lineEditAddress.text()))
# We must check to see if the address is already in the # We must check to see if the address is already in the
# subscriptions list. The user cannot add it again or else it # subscriptions list. The user cannot add it again or else it
# will cause problems when updating and deleting the entry. # will cause problems when updating and deleting the entry.
if shared.isAddressInMySubscriptionsList(address): if shared.isAddressInMySubscriptionsList(address):
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: You cannot add the same address to your" "Error: You cannot add the same address to your"
" subscriptions twice. Perhaps rename the existing one" " subscriptions twice. Perhaps rename the existing one"
" if you want." " if you want."
), 10000) ))
return return
label = str(dialog.lineEditLabel.text().toUtf8()) label = str(dialog.lineEditLabel.text().toUtf8())
self.addSubscription(address, label) self.addSubscription(address, label)
@ -2322,7 +2381,7 @@ class MyForm(settingsmixin.SMainWindow):
QtGui.QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate( 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).")) "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 BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS': if BMConfigParser().get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] != 'SOCKS':
self.statusBar().clearMessage() self.statusbar.clearMessage()
state.resetNetworkProtocolAvailability() # just in case we changed something in the network connectivity state.resetNetworkProtocolAvailability() # just in case we changed something in the network connectivity
if self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS': if self.settingsDialogInstance.ui.comboBoxProxyType.currentText()[0:5] == 'SOCKS':
BMConfigParser().set('bitmessagesettings', 'socksproxytype', str( BMConfigParser().set('bitmessagesettings', 'socksproxytype', str(
@ -2674,23 +2733,27 @@ class MyForm(settingsmixin.SMainWindow):
self.quitAccepted = True self.quitAccepted = True
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Shutting down PyBitmessage... %1%").arg(str(0))) "MainWindow", "Shutting down PyBitmessage... %1%").arg(0))
if waitForConnection: if waitForConnection:
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Waiting for network connection...")) "MainWindow", "Waiting for network connection..."))
while shared.statusIconColor == 'red': while shared.statusIconColor == 'red':
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
)
# this probably will not work correctly, because there is a delay between the status icon turning red and inventory exchange, but it's better than nothing. # this probably will not work correctly, because there is a delay between the status icon turning red and inventory exchange, but it's better than nothing.
if waitForSync: if waitForSync:
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Waiting for finishing synchronisation...")) "MainWindow", "Waiting for finishing synchronisation..."))
while PendingDownloadQueue.totalSize() > 0: while PendingDownloadQueue.totalSize() > 0:
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
)
if waitForPow: if waitForPow:
# check if PoW queue empty # check if PoW queue empty
@ -2702,51 +2765,83 @@ class MyForm(settingsmixin.SMainWindow):
if curWorkerQueue > maxWorkerQueue: if curWorkerQueue > maxWorkerQueue:
maxWorkerQueue = curWorkerQueue maxWorkerQueue = curWorkerQueue
if curWorkerQueue > 0: if curWorkerQueue > 0:
self.statusBar().showMessage(_translate("MainWindow", "Waiting for PoW to finish... %1%").arg(str(50 * (maxWorkerQueue - curWorkerQueue) / maxWorkerQueue))) self.updateStatusBar(_translate(
"MainWindow", "Waiting for PoW to finish... %1%"
).arg(50 * (maxWorkerQueue - curWorkerQueue)
/ maxWorkerQueue)
)
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
)
self.statusBar().showMessage(_translate("MainWindow", "Shutting down Pybitmessage... %1%").arg(str(50))) self.updateStatusBar(_translate(
"MainWindow", "Shutting down Pybitmessage... %1%").arg(50))
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
)
if maxWorkerQueue > 0: if maxWorkerQueue > 0:
time.sleep(0.5) # a bit of time so that the hashHolder is populated # a bit of time so that the hashHolder is populated
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) time.sleep(0.5)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
)
# check if upload (of objects created locally) pending # check if upload (of objects created locally) pending
self.statusBar().showMessage(_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(str(50))) self.updateStatusBar(_translate(
"MainWindow", "Waiting for objects to be sent... %1%").arg(50))
try: try:
while PendingUpload().progress() < 1: while PendingUpload().progress() < 1:
self.statusBar().showMessage(_translate("MainWindow", "Waiting for objects to be sent... %1%").arg(str(int(50 + 20 * PendingUpload().progress())))) self.updateStatusBar(_translate(
"MainWindow",
"Waiting for objects to be sent... %1%"
).arg(int(50 + 20 * PendingUpload().progress()))
)
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
)
except PendingUploadDeadlineException: except PendingUploadDeadlineException:
pass pass
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) QtCore.QCoreApplication.processEvents(
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) QtCore.QEventLoop.AllEvents, 1000
)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
)
# save state and geometry self and all widgets # save state and geometry self and all widgets
self.statusBar().showMessage(_translate("MainWindow", "Saving settings... %1%").arg(str(70))) self.updateStatusBar(_translate(
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) "MainWindow", "Saving settings... %1%").arg(70))
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
)
self.saveSettings() self.saveSettings()
for attr, obj in self.ui.__dict__.iteritems(): for attr, obj in self.ui.__dict__.iteritems():
if hasattr(obj, "__class__") and isinstance(obj, settingsmixin.SettingsMixin): if hasattr(obj, "__class__") \
and isinstance(obj, settingsmixin.SettingsMixin):
saveMethod = getattr(obj, "saveSettings", None) saveMethod = getattr(obj, "saveSettings", None)
if callable (saveMethod): if callable(saveMethod):
obj.saveSettings() obj.saveSettings()
self.statusBar().showMessage(_translate("MainWindow", "Shutting down core... %1%").arg(str(80))) self.updateStatusBar(_translate(
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 1000) "MainWindow", "Shutting down core... %1%").arg(80))
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
)
shutdown.doCleanShutdown() shutdown.doCleanShutdown()
self.statusBar().showMessage(_translate("MainWindow", "Stopping notifications... %1%").arg(str(90))) self.updateStatusBar(_translate(
"MainWindow", "Stopping notifications... %1%").arg(90))
self.tray.hide() self.tray.hide()
self.statusBar().showMessage(_translate("MainWindow", "Shutdown imminent... %1%").arg(str(100))) self.updateStatusBar(_translate(
"MainWindow", "Shutdown imminent... %1%").arg(100))
shared.thisapp.cleanup() shared.thisapp.cleanup()
logger.info("Shutdown complete") logger.info("Shutdown complete")
super(MyForm, myapp).close() super(MyForm, myapp).close()
#return # return
os._exit(0) os._exit(0)
# window close event # window close event
@ -2991,11 +3086,15 @@ class MyForm(settingsmixin.SMainWindow):
label, label,
addressAtCurrentInboxRow, True) addressAtCurrentInboxRow, True)
self.ui.blackwhitelist.rerenderBlackWhiteList() self.ui.blackwhitelist.rerenderBlackWhiteList()
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Entry added to the blacklist. Edit the label to your liking."), 10000) "MainWindow",
"Entry added to the blacklist. Edit the label to your liking.")
)
else: else:
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Error: You cannot add the same address to your blacklist twice. Try renaming the existing one if you want."), 10000) "MainWindow",
"Error: You cannot add the same address to your blacklist"
" twice. Try renaming the existing one if you want."))
def deleteRowFromMessagelist(self, row = None, inventoryHash = None, ackData = None, messageLists = None): def deleteRowFromMessagelist(self, row = None, inventoryHash = None, ackData = None, messageLists = None):
if messageLists is None: if messageLists is None:
@ -3047,8 +3146,8 @@ class MyForm(settingsmixin.SMainWindow):
tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1) tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1)
tableWidget.setUpdatesEnabled(True) tableWidget.setUpdatesEnabled(True)
self.propagateUnreadCount(self.getCurrentAccount, folder) self.propagateUnreadCount(self.getCurrentAccount, folder)
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Moved items to trash."), 10000) "MainWindow", "Moved items to trash."))
def on_action_TrashUndelete(self): def on_action_TrashUndelete(self):
tableWidget = self.getCurrentMessagelist() tableWidget = self.getCurrentMessagelist()
@ -3078,8 +3177,7 @@ class MyForm(settingsmixin.SMainWindow):
tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1) tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1)
tableWidget.setUpdatesEnabled(True) tableWidget.setUpdatesEnabled(True)
self.propagateUnreadCount(self.getCurrentAccount) self.propagateUnreadCount(self.getCurrentAccount)
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate("MainWindow", "Undeleted item."))
"MainWindow", "Undeleted items."), 10000)
def on_action_InboxSaveMessageAs(self): def on_action_InboxSaveMessageAs(self):
tableWidget = self.getCurrentMessagelist() tableWidget = self.getCurrentMessagelist()
@ -3109,9 +3207,9 @@ class MyForm(settingsmixin.SMainWindow):
f = open(filename, 'w') f = open(filename, 'w')
f.write(message) f.write(message)
f.close() f.close()
except Exception, e: except Exception:
logger.exception('Message not saved', exc_info=True) logger.exception('Message not saved', exc_info=True)
self.statusBar().showMessage(_translate("MainWindow", "Write error."), 10000) self.updateStatusBar(_translate("MainWindow", "Write error."))
# Send item on the Sent tab to trash # Send item on the Sent tab to trash
def on_action_SentTrash(self): def on_action_SentTrash(self):
@ -3134,12 +3232,11 @@ class MyForm(settingsmixin.SMainWindow):
self.propagateUnreadCount(tableWidget.item(currentRow, 1 if tableWidget.item(currentRow, 1).type == AccountMixin.SUBSCRIPTION else 0).data(QtCore.Qt.UserRole), folder, self.getCurrentTreeWidget(), -1) self.propagateUnreadCount(tableWidget.item(currentRow, 1 if tableWidget.item(currentRow, 1).type == AccountMixin.SUBSCRIPTION else 0).data(QtCore.Qt.UserRole), folder, self.getCurrentTreeWidget(), -1)
self.getCurrentMessageTextedit().setPlainText("") self.getCurrentMessageTextedit().setPlainText("")
tableWidget.removeRow(currentRow) tableWidget.removeRow(currentRow)
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "Moved items to trash."), 10000) "MainWindow", "Moved items to trash."))
if currentRow == 0:
self.ui.tableWidgetInbox.selectRow(currentRow) self.ui.tableWidgetInbox.selectRow(
else: currentRow if currentRow == 0 else currentRow - 1)
self.ui.tableWidgetInbox.selectRow(currentRow - 1)
def on_action_ForceSend(self): def on_action_ForceSend(self):
currentRow = self.ui.tableWidgetInbox.currentRow() currentRow = self.ui.tableWidgetInbox.currentRow()
@ -3214,10 +3311,10 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.lineEditTo.setText(unicode( self.ui.lineEditTo.setText(unicode(
self.ui.lineEditTo.text().toUtf8(), encoding="UTF-8") + '; ' + stringToAdd) self.ui.lineEditTo.text().toUtf8(), encoding="UTF-8") + '; ' + stringToAdd)
if listOfSelectedRows == {}: if listOfSelectedRows == {}:
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "No addresses selected."), 10000) "MainWindow", "No addresses selected."))
else: else:
self.statusBar().clearMessage() self.statusbar.clearMessage()
self.ui.tabWidget.setCurrentIndex( self.ui.tabWidget.setCurrentIndex(
self.ui.tabWidget.indexOf(self.ui.send) self.ui.tabWidget.indexOf(self.ui.send)
) )
@ -3230,11 +3327,11 @@ class MyForm(settingsmixin.SMainWindow):
addressAtCurrentRow = str(self.ui.tableWidgetAddressBook.item(currentRow,1).text()) addressAtCurrentRow = str(self.ui.tableWidgetAddressBook.item(currentRow,1).text())
# Then subscribe to it... provided it's not already in the address book # Then subscribe to it... provided it's not already in the address book
if shared.isAddressInMySubscriptionsList(addressAtCurrentRow): if shared.isAddressInMySubscriptionsList(addressAtCurrentRow):
self.statusBar().showMessage(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: You cannot add the same address to your" "Error: You cannot add the same address to your"
" subscriptions twice. Perhaps rename the existing" " subscriptions twice. Perhaps rename the existing"
" one if you want."), 10000) " one if you want."))
continue continue
labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8() labelAtCurrentRow = self.ui.tableWidgetAddressBook.item(currentRow,0).text().toUtf8()
self.addSubscription(addressAtCurrentRow, labelAtCurrentRow) self.addSubscription(addressAtCurrentRow, labelAtCurrentRow)
@ -3991,9 +4088,9 @@ class MyForm(settingsmixin.SMainWindow):
logger.info('Status bar: ' + message) logger.info('Status bar: ' + message)
if option == 1: if option == 1:
self.statusBar().addImportant(message) self.statusbar.addImportant(message)
else: else:
self.statusBar().showMessage(message, 10000) self.statusbar.showMessage(message, 10000)
def initSettings(self): def initSettings(self):
QtCore.QCoreApplication.setOrganizationName("PyBitmessage") QtCore.QCoreApplication.setOrganizationName("PyBitmessage")
@ -4001,9 +4098,10 @@ class MyForm(settingsmixin.SMainWindow):
QtCore.QCoreApplication.setApplicationName("pybitmessageqt") QtCore.QCoreApplication.setApplicationName("pybitmessageqt")
self.loadSettings() self.loadSettings()
for attr, obj in self.ui.__dict__.iteritems(): for attr, obj in self.ui.__dict__.iteritems():
if hasattr(obj, "__class__") and isinstance(obj, settingsmixin.SettingsMixin): if hasattr(obj, "__class__") and \
isinstance(obj, settingsmixin.SettingsMixin):
loadMethod = getattr(obj, "loadSettings", None) loadMethod = getattr(obj, "loadSettings", None)
if callable (loadMethod): if callable(loadMethod):
obj.loadSettings() obj.loadSettings()

View File

@ -8,6 +8,7 @@ from tr import _translate
from retranslateui import RetranslateMixin from retranslateui import RetranslateMixin
import widgets import widgets
import queues
import hashlib import hashlib
from inventory import Inventory from inventory import Inventory
@ -32,7 +33,9 @@ class AddressCheckMixin(object):
self._onSuccess(addressVersion, streamNumber, ripe) self._onSuccess(addressVersion, streamNumber, ripe)
elif status == 'missingbm': elif status == 'missingbm':
self.labelAddressCheck.setText(_translate( self.labelAddressCheck.setText(_translate(
"MainWindow", "The address should start with ''BM-''")) "MainWindow", # dialog name should be here
"The address should start with ''BM-''"
))
elif status == 'checksumfailed': elif status == 'checksumfailed':
self.labelAddressCheck.setText(_translate( self.labelAddressCheck.setText(_translate(
"MainWindow", "MainWindow",
@ -47,7 +50,9 @@ class AddressCheckMixin(object):
)) ))
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
self.labelAddressCheck.setText(_translate( self.labelAddressCheck.setText(_translate(
"MainWindow", "The address contains invalid characters.")) "MainWindow",
"The address contains invalid characters."
))
elif status == 'ripetooshort': elif status == 'ripetooshort':
self.labelAddressCheck.setText(_translate( self.labelAddressCheck.setText(_translate(
"MainWindow", "MainWindow",
@ -55,7 +60,9 @@ class AddressCheckMixin(object):
)) ))
elif status == 'ripetoolong': elif status == 'ripetoolong':
self.labelAddressCheck.setText(_translate( self.labelAddressCheck.setText(_translate(
"MainWindow", "Some data encoded in the address is too long.")) "MainWindow",
"Some data encoded in the address is too long."
))
elif status == 'varintmalformed': elif status == 'varintmalformed':
self.labelAddressCheck.setText(_translate( self.labelAddressCheck.setText(_translate(
"MainWindow", "MainWindow",
@ -152,7 +159,7 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog, RetranslateMixin):
if self.address_is_chan: # address is a chan address if self.address_is_chan: # address is a chan address
self.radioButtonBehaviorMailingList.setDisabled(True) self.radioButtonBehaviorMailingList.setDisabled(True)
self.lineEditMailingListName.setText(_translate( self.lineEditMailingListName.setText(_translate(
"MainWindow", "SpecialAddressBehaviorDialog",
"This is a chan address. You cannot use it as a" "This is a chan address. You cannot use it as a"
" pseudo-mailing list." " pseudo-mailing list."
)) ))
@ -240,10 +247,8 @@ class EmailGatewayDialog(QtGui.QDialog, RetranslateMixin):
self.config.set(acct.fromAddress, 'label', email) self.config.set(acct.fromAddress, 'label', email)
self.config.set(acct.fromAddress, 'gateway', 'mailchuck') self.config.set(acct.fromAddress, 'gateway', 'mailchuck')
self.config.save() self.config.save()
self.parent.statusBar().showMessage(_translate( self.parent.statusbar_message(
"MainWindow", "Sending email gateway registration request")
"Sending email gateway registration request"
), 10000)
def accept(self): def accept(self):
self.hide() self.hide()
@ -260,15 +265,15 @@ class EmailGatewayDialog(QtGui.QDialog, RetranslateMixin):
self.acct.unregister() self.acct.unregister()
self.config.remove_option(self.acct.fromAddress, 'gateway') self.config.remove_option(self.acct.fromAddress, 'gateway')
self.config.save() self.config.save()
self.parent.statusBar().showMessage(_translate( queues.UISignalQueue.put(('updateStatusBar', _translate(
"MainWindow", "EmailGatewayDialog",
"Sending email gateway unregistration request" "Sending email gateway unregistration request"
), 10000) )))
elif self.radioButtonStatus.isChecked(): elif self.radioButtonStatus.isChecked():
self.acct.status() self.acct.status()
self.parent.statusBar().showMessage(_translate( queues.UISignalQueue.put(('updateStatusBar', _translate(
"MainWindow", "EmailGatewayDialog",
"Sending email gateway status request" "Sending email gateway status request"
), 10000) )))
elif self.radioButtonSettings.isChecked(): elif self.radioButtonSettings.isChecked():
return self.acct return self.acct