try to migrate to Python3 + PyQt6; part 2

TLS is disabled
This commit is contained in:
Kashiko Koibumi 2024-05-13 12:47:42 +09:00
parent 6dfecbe361
commit 057e856925
No known key found for this signature in database
GPG Key ID: 8F06E069E37C40C4
32 changed files with 391 additions and 326 deletions

View File

@ -609,12 +609,12 @@ class MyForm(settingsmixin.SMainWindow):
if addressVersionNumber == 1: if addressVersionNumber == 1:
displayMsg = _translate( displayMsg = _translate(
"MainWindow", "MainWindow",
"One of your addresses, %1, is an old version 1 address. " "One of your addresses, {0}, is an old version 1 address. "
"Version 1 addresses are no longer supported. " "Version 1 addresses are no longer supported. "
"May we delete it now?").arg(addressInKeysFile) "May we delete it now?").format(addressInKeysFile)
reply = QtGui.QMessageBox.question( reply = QtGui.QMessageBox.question(
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) self, 'Message', displayMsg, QtGui.QMessageBox.StandardButton.Yes, QtGui.QMessageBox.StandardButton.No)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.StandardButton.Yes:
config.remove_section(addressInKeysFile) config.remove_section(addressInKeysFile)
config.save() config.save()
@ -1062,20 +1062,20 @@ class MyForm(settingsmixin.SMainWindow):
elif status == 'msgsent': elif status == 'msgsent':
statusText = _translate( statusText = _translate(
"MainWindow", "MainWindow",
"Message sent. Waiting for acknowledgement. Sent at %1" "Message sent. Waiting for acknowledgement. Sent at {0}"
).arg(l10n.formatTimestamp(lastactiontime)) ).format(l10n.formatTimestamp(lastactiontime))
elif status == 'msgsentnoackexpected': elif status == 'msgsentnoackexpected':
statusText = _translate( statusText = _translate(
"MainWindow", "Message sent. Sent at %1" "MainWindow", "Message sent. Sent at {0}"
).arg(l10n.formatTimestamp(lastactiontime)) ).format(l10n.formatTimestamp(lastactiontime))
elif status == 'doingmsgpow': elif status == 'doingmsgpow':
statusText = _translate( statusText = _translate(
"MainWindow", "Doing work necessary to send message.") "MainWindow", "Doing work necessary to send message.")
elif status == 'ackreceived': elif status == 'ackreceived':
statusText = _translate( statusText = _translate(
"MainWindow", "MainWindow",
"Acknowledgement of the message received %1" "Acknowledgement of the message received {0}"
).arg(l10n.formatTimestamp(lastactiontime)) ).format(l10n.formatTimestamp(lastactiontime))
elif status == 'broadcastqueued': elif status == 'broadcastqueued':
statusText = _translate( statusText = _translate(
"MainWindow", "Broadcast queued.") "MainWindow", "Broadcast queued.")
@ -1083,27 +1083,27 @@ class MyForm(settingsmixin.SMainWindow):
statusText = _translate( statusText = _translate(
"MainWindow", "Doing work necessary to send broadcast.") "MainWindow", "Doing work necessary to send broadcast.")
elif status == 'broadcastsent': elif status == 'broadcastsent':
statusText = _translate("MainWindow", "Broadcast on %1").arg( statusText = _translate("MainWindow", "Broadcast on {0}").format(
l10n.formatTimestamp(lastactiontime)) l10n.formatTimestamp(lastactiontime))
elif status == 'toodifficult': elif status == 'toodifficult':
statusText = _translate( statusText = _translate(
"MainWindow", "MainWindow",
"Problem: The work demanded by the recipient is more" "Problem: The work demanded by the recipient is more"
" difficult than you are willing to do. %1" " difficult than you are willing to do. {0}"
).arg(l10n.formatTimestamp(lastactiontime)) ).format(l10n.formatTimestamp(lastactiontime))
elif status == 'badkey': elif status == 'badkey':
statusText = _translate( statusText = _translate(
"MainWindow", "MainWindow",
"Problem: The recipient\'s encryption key is no good." "Problem: The recipient\'s encryption key is no good."
" Could not encrypt message. %1" " Could not encrypt message. {0}"
).arg(l10n.formatTimestamp(lastactiontime)) ).format(l10n.formatTimestamp(lastactiontime))
elif status == 'forcepow': elif status == 'forcepow':
statusText = _translate( statusText = _translate(
"MainWindow", "MainWindow",
"Forced difficulty override. Send should start soon.") "Forced difficulty override. Send should start soon.")
else: else:
statusText = _translate( statusText = _translate(
"MainWindow", "Unknown status: %1 %2").arg(status).arg( "MainWindow", "Unknown status: {0} {1}").format(status,
l10n.formatTimestamp(lastactiontime)) l10n.formatTimestamp(lastactiontime))
items = [ items = [
@ -1387,7 +1387,7 @@ class MyForm(settingsmixin.SMainWindow):
def notifierInit(self): def notifierInit(self):
def _simple_notify( def _simple_notify(
title, subtitle, category, label=None, icon=None): title, subtitle, category, label=None, icon=None):
self.tray.showMessage(title, subtitle, 1, 2000) self.tray.showMessage(title, subtitle, icon, 2000)
self._notifier = _simple_notify self._notifier = _simple_notify
# does nothing if isAvailable returns false # does nothing if isAvailable returns false
@ -1504,7 +1504,7 @@ class MyForm(settingsmixin.SMainWindow):
# reply = QtGui.QMessageBox.information(self, 'keys.dat?','You # reply = QtGui.QMessageBox.information(self, 'keys.dat?','You
# 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.StandardButton.Ok)
reply = QtGui.QMessageBox.information( reply = QtGui.QMessageBox.information(
self, self,
'keys.dat?', 'keys.dat?',
@ -1513,7 +1513,7 @@ class MyForm(settingsmixin.SMainWindow):
"You may manage your keys by editing the keys.dat file stored in the same directory" "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." "as this program. It is important that you back up this file."
), ),
QtGui.QMessageBox.Ok) QtGui.QMessageBox.StandardButton.Ok)
else: else:
QtGui.QMessageBox.information( QtGui.QMessageBox.information(
@ -1522,10 +1522,10 @@ class MyForm(settingsmixin.SMainWindow):
_translate( _translate(
"MainWindow", "MainWindow",
"You may manage your keys by editing the keys.dat file stored in" "You may manage your keys by editing the keys.dat file stored in"
"\n %1 \n" "\n {0} \n"
"It is important that you back up this file." "It is important that you back up this file."
).arg(state.appdata), ).format(state.appdata),
QtGui.QMessageBox.Ok) QtGui.QMessageBox.StandardButton.Ok)
elif sys.platform == 'win32' or sys.platform == 'win64': elif sys.platform == 'win32' or sys.platform == 'win64':
if state.appdata == '': if state.appdata == '':
reply = QtGui.QMessageBox.question( reply = QtGui.QMessageBox.question(
@ -1537,19 +1537,19 @@ class MyForm(settingsmixin.SMainWindow):
"this program. It is important that you back up this file. " "this program. It is important that you back up this file. "
"Would you like to open the file now? " "Would you like to open the file now? "
"(Be sure to close Bitmessage before making any changes.)"), "(Be sure to close Bitmessage before making any changes.)"),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.StandardButton.Yes,
QtGui.QMessageBox.No) QtGui.QMessageBox.StandardButton.No)
else: else:
reply = QtGui.QMessageBox.question( reply = QtGui.QMessageBox.question(
self, self,
_translate("MainWindow", "Open keys.dat?"), _translate("MainWindow", "Open keys.dat?"),
_translate( _translate(
"MainWindow", "MainWindow",
"You may manage your keys by editing the keys.dat file stored in\n %1 \n" "You may manage your keys by editing the keys.dat file stored in\n {0} \n"
"It is important that you back up this file. Would you like to open the file now?" "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.)").arg(state.appdata), "(Be sure to close Bitmessage before making any changes.)").format(state.appdata),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) QtGui.QMessageBox.StandardButton.Yes, QtGui.QMessageBox.StandardButton.No)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.StandardButton.Yes:
openKeysFile() openKeysFile()
# menu button 'delete all treshed messages' # menu button 'delete all treshed messages'
@ -1558,8 +1558,8 @@ class MyForm(settingsmixin.SMainWindow):
self, self,
_translate("MainWindow", "Delete trash?"), _translate("MainWindow", "Delete trash?"),
_translate("MainWindow", "Are you sure you want to delete all trashed messages?"), _translate("MainWindow", "Are you sure you want to delete all trashed messages?"),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.StandardButton.Yes,
QtGui.QMessageBox.No) == QtGui.QMessageBox.No: QtGui.QMessageBox.StandardButton.No) == QtGui.QMessageBox.StandardButton.No:
return return
sqlStoredProcedure('deleteandvacuume') sqlStoredProcedure('deleteandvacuume')
self.rerenderTabTreeMessages() self.rerenderTabTreeMessages()
@ -1654,7 +1654,7 @@ class MyForm(settingsmixin.SMainWindow):
pass pass
def changeEvent(self, event): def changeEvent(self, event):
if event.type() == QtCore.QEvent.LanguageChange: if event.type() == QtCore.QEvent.Type.LanguageChange:
self.ui.retranslateUi(self) self.ui.retranslateUi(self)
self.init_inbox_popup_menu(False) self.init_inbox_popup_menu(False)
self.init_identities_popup_menu(False) self.init_identities_popup_menu(False)
@ -1663,7 +1663,7 @@ class MyForm(settingsmixin.SMainWindow):
self.init_subscriptions_popup_menu(False) self.init_subscriptions_popup_menu(False)
self.init_sent_popup_menu(False) self.init_sent_popup_menu(False)
self.ui.blackwhitelist.init_blacklist_popup_menu(False) self.ui.blackwhitelist.init_blacklist_popup_menu(False)
if event.type() == QtCore.QEvent.WindowStateChange: if event.type() == QtCore.QEvent.Type.WindowStateChange:
if self.windowState() & QtCore.Qt.WindowMinimized: if self.windowState() & QtCore.Qt.WindowMinimized:
if config.getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform: if config.getboolean('bitmessagesettings', 'minimizetotray') and not 'darwin' in sys.platform:
QtCore.QTimer.singleShot(0, self.appIndicatorHide) QtCore.QTimer.singleShot(0, self.appIndicatorHide)
@ -1890,14 +1890,14 @@ class MyForm(settingsmixin.SMainWindow):
self.notifiedNewVersion = ".".join(str(n) for n in version) self.notifiedNewVersion = ".".join(str(n) for n in version)
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"New version of PyBitmessage is available: %1. Download it" "New version of PyBitmessage is available: {0}. Download it"
" from https://github.com/Bitmessage/PyBitmessage/releases/latest" " from https://github.com/Bitmessage/PyBitmessage/releases/latest"
).arg(self.notifiedNewVersion) ).format(self.notifiedNewVersion)
) )
def displayAlert(self, title, text, exitAfterUserClicksOk): def displayAlert(self, title, text, exitAfterUserClicksOk):
self.updateStatusBar(text) self.updateStatusBar(text)
QtGui.QMessageBox.critical(self, title, text, QtGui.QMessageBox.Ok) QtGui.QMessageBox.critical(self, title, text, QtGui.QMessageBox.StandardButton.Ok)
if exitAfterUserClicksOk: if exitAfterUserClicksOk:
os._exit(0) os._exit(0)
@ -1982,7 +1982,7 @@ class MyForm(settingsmixin.SMainWindow):
,it will resend the message automatically. The longer the Time-To-Live, the ,it will resend the message automatically. The longer the Time-To-Live, the
more work your computer must do to send the message. more work your computer must do to send the message.
A Time-To-Live of four or five days is often appropriate."""), A Time-To-Live of four or five days is often appropriate."""),
QtGui.QMessageBox.Ok) QtGui.QMessageBox.StandardButton.Ok)
def click_pushButtonClear(self): def click_pushButtonClear(self):
self.ui.lineEditSubject.setText("") self.ui.lineEditSubject.setText("")
@ -2028,9 +2028,9 @@ class MyForm(settingsmixin.SMainWindow):
_translate( _translate(
"MainWindow", "MainWindow",
"The message that you are trying to send is too long" "The message that you are trying to send is too long"
" by %1 bytes. (The maximum is 261644 bytes). Please" " by {0} bytes. (The maximum is 261644 bytes). Please"
" cut it down before sending." " cut it down before sending."
).arg(len(message) - (2 ** 18 - 500))) ).format(len(message) - (2 ** 18 - 500)))
return return
acct = accountClass(fromAddress) acct = accountClass(fromAddress)
@ -2062,7 +2062,7 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "MainWindow",
"You are trying to send an email instead of a bitmessage. " "You are trying to send an email instead of a bitmessage. "
"This requires registering with a gateway. Attempt to register?"), "This requires registering with a gateway. Attempt to register?"),
QtGui.QMessageBox.Yes|QtGui.QMessageBox.No) != QtGui.QMessageBox.Yes: QtGui.QMessageBox.StandardButton.Yes|QtGui.QMessageBox.StandardButton.No) != QtGui.QMessageBox.StandardButton.Yes:
continue continue
email = acct.getLabel() email = acct.getLabel()
if email[-14:] != "@mailchuck.com": # attempt register if email[-14:] != "@mailchuck.com": # attempt register
@ -2079,9 +2079,9 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "MainWindow",
"Error: Your account wasn't registered at" "Error: Your account wasn't registered at"
" an email gateway. Sending registration" " an email gateway. Sending registration"
" now as %1, please wait for the registration" " now as {0}, please wait for the registration"
" to be processed before retrying sending." " to be processed before retrying sending."
).arg(email) ).format(email)
) )
return return
status, addressVersionNumber, streamNumber = decodeAddress(toAddress)[:3] status, addressVersionNumber, streamNumber = decodeAddress(toAddress)[:3]
@ -2096,58 +2096,58 @@ class MyForm(settingsmixin.SMainWindow):
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Bitmessage addresses start with" "Error: Bitmessage addresses start with"
" BM- Please check the recipient address %1" " BM- Please check the recipient address {0}"
).arg(toAddress)) ).format(toAddress))
elif status == 'checksumfailed': elif status == 'checksumfailed':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: The recipient address %1 is not" "Error: The recipient address {0} is not"
" typed or copied correctly. Please check it." " typed or copied correctly. Please check it."
).arg(toAddress)) ).format(toAddress))
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: The recipient address %1 contains" "Error: The recipient address {0} contains"
" invalid characters. Please check it." " invalid characters. Please check it."
).arg(toAddress)) ).format(toAddress))
elif status == 'versiontoohigh': elif status == 'versiontoohigh':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: The version of the recipient address" "Error: The version of the recipient address"
" %1 is too high. Either you need to upgrade" " {0} is too high. Either you need to upgrade"
" your Bitmessage software or your" " your Bitmessage software or your"
" acquaintance is being clever." " acquaintance is being clever."
).arg(toAddress)) ).format(toAddress))
elif status == 'ripetooshort': elif status == 'ripetooshort':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Some data encoded in the recipient" "Error: Some data encoded in the recipient"
" address %1 is too short. There might be" " address {0} is too short. There might be"
" something wrong with the software of" " something wrong with the software of"
" your acquaintance." " your acquaintance."
).arg(toAddress)) ).format(toAddress))
elif status == 'ripetoolong': elif status == 'ripetoolong':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Some data encoded in the recipient" "Error: Some data encoded in the recipient"
" address %1 is too long. There might be" " address {0} is too long. There might be"
" something wrong with the software of" " something wrong with the software of"
" your acquaintance." " your acquaintance."
).arg(toAddress)) ).format(toAddress))
elif status == 'varintmalformed': elif status == 'varintmalformed':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Some data encoded in the recipient" "Error: Some data encoded in the recipient"
" address %1 is malformed. There might be" " address {0} is malformed. There might be"
" something wrong with the software of" " something wrong with the software of"
" your acquaintance." " your acquaintance."
).arg(toAddress)) ).format(toAddress))
else: else:
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Something is wrong with the" "Error: Something is wrong with the"
" recipient address %1." " recipient address {0}."
).arg(toAddress)) ).format(toAddress))
elif fromAddress == '': elif fromAddress == '':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
@ -2164,9 +2164,9 @@ class MyForm(settingsmixin.SMainWindow):
_translate("MainWindow", "Address version number"), _translate("MainWindow", "Address version number"),
_translate( _translate(
"MainWindow", "MainWindow",
"Concerning the address %1, Bitmessage cannot understand address version numbers" "Concerning the address {0}, Bitmessage cannot understand address version numbers"
" of %2. Perhaps upgrade Bitmessage to the latest version." " of {1}. Perhaps upgrade Bitmessage to the latest version."
).arg(toAddress).arg(str(addressVersionNumber))) ).format(toAddress, str(addressVersionNumber)))
continue continue
if streamNumber > 1 or streamNumber == 0: if streamNumber > 1 or streamNumber == 0:
QtGui.QMessageBox.about( QtGui.QMessageBox.about(
@ -2174,9 +2174,9 @@ class MyForm(settingsmixin.SMainWindow):
_translate("MainWindow", "Stream number"), _translate("MainWindow", "Stream number"),
_translate( _translate(
"MainWindow", "MainWindow",
"Concerning the address %1, Bitmessage cannot handle stream numbers of %2." "Concerning the address {0}, Bitmessage cannot handle stream numbers of {1}."
" Perhaps upgrade Bitmessage to the latest version." " Perhaps upgrade Bitmessage to the latest version."
).arg(toAddress).arg(str(streamNumber))) ).format(toAddress, str(streamNumber)))
continue continue
self.statusbar.clearMessage() self.statusbar.clearMessage()
if state.statusIconColor == 'red': if state.statusIconColor == 'red':
@ -2265,7 +2265,7 @@ class MyForm(settingsmixin.SMainWindow):
err, addr = self.namecoin.query(identities[-1].strip()) err, addr = self.namecoin.query(identities[-1].strip())
if err is not None: if err is not None:
self.updateStatusBar( self.updateStatusBar(
_translate("MainWindow", "Error: %1").arg(err)) _translate("MainWindow", "Error: {0}").format(err))
else: else:
identities[-1] = addr identities[-1] = addr
self.ui.lineEditTo.setText("; ".join(identities)) self.ui.lineEditTo.setText("; ".join(identities))
@ -2420,7 +2420,7 @@ class MyForm(settingsmixin.SMainWindow):
'bitmessagesettings', 'showtraynotifications'): 'bitmessagesettings', 'showtraynotifications'):
self.notifierShow( self.notifierShow(
_translate("MainWindow", "New Message"), _translate("MainWindow", "New Message"),
_translate("MainWindow", "From %1").arg( _translate("MainWindow", "From {0}").format(
str(acct.fromLabel, 'utf-8')), str(acct.fromLabel, 'utf-8')),
sound.SOUND_UNKNOWN sound.SOUND_UNKNOWN
) )
@ -2583,8 +2583,8 @@ class MyForm(settingsmixin.SMainWindow):
_translate( _translate(
"MainWindow", "MainWindow",
"Are you sure you would like to mark all messages read?" "Are you sure you would like to mark all messages read?"
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No ), QtGui.QMessageBox.StandardButton.Yes | QtGui.QMessageBox.StandardButton.No
) != QtGui.QMessageBox.Yes: ) != QtGui.QMessageBox.StandardButton.Yes:
return return
tableWidget = self.getCurrentMessagelist() tableWidget = self.getCurrentMessagelist()
@ -2612,7 +2612,7 @@ class MyForm(settingsmixin.SMainWindow):
def network_switch(self): def network_switch(self):
dontconnect_option = not config.safeGetBoolean( dontconnect_option = not config.safeGetBoolean(
'bitmessagesettings', 'dontconnect') 'bitmessagesettings', 'dontconnect')
reply = QtGui.QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Disconnecting") self, _translate("MainWindow", "Disconnecting")
if dontconnect_option else _translate("MainWindow", "Connecting"), if dontconnect_option else _translate("MainWindow", "Connecting"),
_translate( _translate(
@ -2621,9 +2621,9 @@ class MyForm(settingsmixin.SMainWindow):
) if dontconnect_option else _translate( ) if dontconnect_option else _translate(
"MainWindow", "MainWindow",
"Bitmessage will now start connecting to network. Are you sure?" "Bitmessage will now start connecting to network. Are you sure?"
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.Cancel, ), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.Cancel,
QtGui.QMessageBox.Cancel) QtWidgets.QMessageBox.StandardButton.Cancel)
if reply != QtGui.QMessageBox.Yes: if reply != QtWidgets.QMessageBox.StandardButton.Yes:
return return
config.set( config.set(
'bitmessagesettings', 'dontconnect', str(dontconnect_option)) 'bitmessagesettings', 'dontconnect', str(dontconnect_option))
@ -2650,7 +2650,7 @@ class MyForm(settingsmixin.SMainWindow):
# C PoW currently doesn't support interrupting and OpenCL is untested # C PoW currently doesn't support interrupting and OpenCL is untested
if getPowType() == "python" and (powQueueSize() > 0 or pendingUpload() > 0): if getPowType() == "python" and (powQueueSize() > 0 or pendingUpload() > 0):
reply = QtGui.QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Proof of work pending"), self, _translate("MainWindow", "Proof of work pending"),
_translate( _translate(
"MainWindow", "MainWindow",
@ -2664,15 +2664,15 @@ class MyForm(settingsmixin.SMainWindow):
) + "\n\n" + ) + "\n\n" +
_translate( _translate(
"MainWindow", "Wait until these tasks finish?"), "MainWindow", "Wait until these tasks finish?"),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) | QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel)
if reply == QtGui.QMessageBox.No: if reply == QtWidgets.QMessageBox.StandardButton.No:
waitForPow = False waitForPow = False
elif reply == QtGui.QMessageBox.Cancel: elif reply == QtWidgets.QMessageBox.StandardButton.Cancel:
return return
if pendingDownload() > 0: if pendingDownload() > 0:
reply = QtGui.QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Synchronisation pending"), self, _translate("MainWindow", "Synchronisation pending"),
_translate( _translate(
"MainWindow", "MainWindow",
@ -2682,16 +2682,16 @@ class MyForm(settingsmixin.SMainWindow):
" synchronisation finishes?", None, " synchronisation finishes?", None,
QtCore.QCoreApplication.CodecForTr, pendingDownload() QtCore.QCoreApplication.CodecForTr, pendingDownload()
), ),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) | QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel)
if reply == QtGui.QMessageBox.Yes: if reply == QtWidgets.QMessageBox.StandardButton.Yes:
self.wait = waitForSync = True self.wait = waitForSync = True
elif reply == QtGui.QMessageBox.Cancel: elif reply == QtWidgets.QMessageBox.StandardButton.Cancel:
return return
if state.statusIconColor == 'red' and not config.safeGetBoolean( if state.statusIconColor == 'red' and not config.safeGetBoolean(
'bitmessagesettings', 'dontconnect'): 'bitmessagesettings', 'dontconnect'):
reply = QtGui.QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Not connected"), self, _translate("MainWindow", "Not connected"),
_translate( _translate(
"MainWindow", "MainWindow",
@ -2699,18 +2699,18 @@ class MyForm(settingsmixin.SMainWindow):
" quit now, it may cause delivery delays. Wait until" " quit now, it may cause delivery delays. Wait until"
" connected and the synchronisation finishes?" " connected and the synchronisation finishes?"
), ),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) | QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel)
if reply == QtGui.QMessageBox.Yes: if reply == QtWidgets.QMessageBox.StandardButton.Yes:
waitForConnection = True waitForConnection = True
self.wait = waitForSync = True self.wait = waitForSync = True
elif reply == QtGui.QMessageBox.Cancel: elif reply == QtWidgets.QMessageBox.StandardButton.Cancel:
return return
self.quitAccepted = True self.quitAccepted = True
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Shutting down PyBitmessage... %1%").arg(0)) "MainWindow", "Shutting down PyBitmessage... {0}%").format(0))
if waitForConnection: if waitForConnection:
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
@ -2718,7 +2718,7 @@ class MyForm(settingsmixin.SMainWindow):
while state.statusIconColor == 'red': while state.statusIconColor == 'red':
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
# this probably will not work correctly, because there is a delay # this probably will not work correctly, because there is a delay
@ -2730,7 +2730,7 @@ class MyForm(settingsmixin.SMainWindow):
while pendingDownload() > 0: while pendingDownload() > 0:
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
if waitForPow: if waitForPow:
@ -2744,54 +2744,54 @@ class MyForm(settingsmixin.SMainWindow):
maxWorkerQueue = curWorkerQueue maxWorkerQueue = curWorkerQueue
if curWorkerQueue > 0: if curWorkerQueue > 0:
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Waiting for PoW to finish... %1%" "MainWindow", "Waiting for PoW to finish... {0}%"
).arg(50 * (maxWorkerQueue - curWorkerQueue) / ).format(50 * (maxWorkerQueue - curWorkerQueue) /
maxWorkerQueue)) maxWorkerQueue))
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Shutting down Pybitmessage... %1%").arg(50)) "MainWindow", "Shutting down Pybitmessage... {0}%").format(50))
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
if maxWorkerQueue > 0: if maxWorkerQueue > 0:
# a bit of time so that the hashHolder is populated # a bit of time so that the hashHolder is populated
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
# check if upload (of objects created locally) pending # check if upload (of objects created locally) pending
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Waiting for objects to be sent... %1%").arg(50)) "MainWindow", "Waiting for objects to be sent... {0}%").format(50))
maxPendingUpload = max(1, pendingUpload()) maxPendingUpload = max(1, pendingUpload())
while pendingUpload() > 1: while pendingUpload() > 1:
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Waiting for objects to be sent... %1%" "Waiting for objects to be sent... {0}%"
).arg(int(50 + 20 * (pendingUpload() / maxPendingUpload)))) ).format(int(50 + 20 * (pendingUpload() / maxPendingUpload))))
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
# save state and geometry self and all widgets # save state and geometry self and all widgets
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Saving settings... %1%").arg(70)) "MainWindow", "Saving settings... {0}%").format(70))
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
self.saveSettings() self.saveSettings()
for attr, obj in self.ui.__dict__.items(): for attr, obj in self.ui.__dict__.items():
@ -2802,18 +2802,18 @@ class MyForm(settingsmixin.SMainWindow):
obj.saveSettings() obj.saveSettings()
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Shutting down core... %1%").arg(80)) "MainWindow", "Shutting down core... {0}%").format(80))
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.ProcessEventsFlag.AllEvents, 1000
) )
shutdown.doCleanShutdown() shutdown.doCleanShutdown()
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Stopping notifications... %1%").arg(90)) "MainWindow", "Stopping notifications... {0}%").format(90))
self.tray.hide() self.tray.hide()
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Shutdown imminent... %1%").arg(100)) "MainWindow", "Shutdown imminent... {0}%").format(100))
logger.info("Shutdown complete") logger.info("Shutdown complete")
self.close() self.close()
@ -2982,23 +2982,23 @@ class MyForm(settingsmixin.SMainWindow):
) )
# toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow # toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
elif not config.has_section(toAddressAtCurrentInboxRow): elif not config.has_section(toAddressAtCurrentInboxRow):
QtGui.QMessageBox.information( QtWidgets.QMessageBox.information(
self, _translate("MainWindow", "Address is gone"), self, _translate("MainWindow", "Address is gone"),
_translate( _translate(
"MainWindow", "MainWindow",
"Bitmessage cannot find your address %1. Perhaps you" "Bitmessage cannot find your address {0}. Perhaps you"
" removed it?" " removed it?"
).arg(toAddressAtCurrentInboxRow), QtGui.QMessageBox.Ok) ).format(toAddressAtCurrentInboxRow), QtWidgets.QMessageBox.StandardButton.Ok)
elif not config.getboolean( elif not config.getboolean(
toAddressAtCurrentInboxRow, 'enabled'): toAddressAtCurrentInboxRow, 'enabled'):
QtGui.QMessageBox.information( QtWidgets.QMessageBox.information(
self, _translate("MainWindow", "Address disabled"), self, _translate("MainWindow", "Address disabled"),
_translate( _translate(
"MainWindow", "MainWindow",
"Error: The address from which you are trying to send" "Error: The address from which you are trying to send"
" is disabled. You\'ll have to enable it on the" " is disabled. You\'ll have to enable it on the"
" \'Your Identities\' tab before using it." " \'Your Identities\' tab before using it."
), QtGui.QMessageBox.Ok) ), QtWidgets.QMessageBox.StandardButton.Ok)
else: else:
self.setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(toAddressAtCurrentInboxRow) self.setBroadcastEnablementDependingOnWhetherThisIsAMailingListAddress(toAddressAtCurrentInboxRow)
broadcast_tab_index = self.ui.tabWidgetSend.indexOf( broadcast_tab_index = self.ui.tabWidgetSend.indexOf(
@ -3126,7 +3126,7 @@ class MyForm(settingsmixin.SMainWindow):
return return
currentRow = 0 currentRow = 0
folder = self.getCurrentFolder() folder = self.getCurrentFolder()
shifted = QtGui.QApplication.queryKeyboardModifiers() \ shifted = QtWidgets.QApplication.queryKeyboardModifiers() \
& QtCore.Qt.ShiftModifier & QtCore.Qt.ShiftModifier
tableWidget.setUpdatesEnabled(False) tableWidget.setUpdatesEnabled(False)
inventoryHashesToTrash = set() inventoryHashesToTrash = set()
@ -3199,7 +3199,7 @@ class MyForm(settingsmixin.SMainWindow):
message, = row message, = row
defaultFilename = "".join(x for x in subjectAtCurrentInboxRow if x.isalnum()) + '.txt' defaultFilename = "".join(x for x in subjectAtCurrentInboxRow if x.isalnum()) + '.txt'
filename = QtGui.QFileDialog.getSaveFileName( filename = QtWidgets.QFileDialog.getSaveFileName(
self, self,
_translate("MainWindow","Save As..."), _translate("MainWindow","Save As..."),
defaultFilename, defaultFilename,
@ -3220,7 +3220,7 @@ class MyForm(settingsmixin.SMainWindow):
if not tableWidget: if not tableWidget:
return return
folder = self.getCurrentFolder() folder = self.getCurrentFolder()
shifted = QtGui.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier shifted = QtWidgets.QApplication.queryKeyboardModifiers() & QtCore.Qt.ShiftModifier
while tableWidget.selectedIndexes() != []: while tableWidget.selectedIndexes() != []:
currentRow = tableWidget.selectedIndexes()[0].row() currentRow = tableWidget.selectedIndexes()[0].row()
ackdataToTrash = tableWidget.item(currentRow, 3).data() ackdataToTrash = tableWidget.item(currentRow, 3).data()
@ -3256,7 +3256,7 @@ class MyForm(settingsmixin.SMainWindow):
currentRow = self.ui.tableWidgetInbox.currentRow() currentRow = self.ui.tableWidgetInbox.currentRow()
addressAtCurrentRow = self.ui.tableWidgetInbox.item( addressAtCurrentRow = self.ui.tableWidgetInbox.item(
currentRow, 0).data(QtCore.Qt.UserRole) currentRow, 0).data(QtCore.Qt.UserRole)
clipboard = QtGui.QApplication.clipboard() clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(str(addressAtCurrentRow)) clipboard.setText(str(addressAtCurrentRow))
# Group of functions for the Address Book dialog box # Group of functions for the Address Book dialog box
@ -3281,7 +3281,7 @@ class MyForm(settingsmixin.SMainWindow):
addresses_string = item.address addresses_string = item.address
else: else:
addresses_string += ', ' + item.address addresses_string += ', ' + item.address
clipboard = QtGui.QApplication.clipboard() clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(addresses_string) clipboard.setText(addresses_string)
def on_action_AddressBookSend(self): def on_action_AddressBookSend(self):
@ -3323,7 +3323,7 @@ class MyForm(settingsmixin.SMainWindow):
) )
def on_context_menuAddressBook(self, point): def on_context_menuAddressBook(self, point):
self.popMenuAddressBook = QtGui.QMenu(self) self.popMenuAddressBook = QtWidgets.QMenu(self)
self.popMenuAddressBook.addAction(self.actionAddressBookSend) self.popMenuAddressBook.addAction(self.actionAddressBookSend)
self.popMenuAddressBook.addAction(self.actionAddressBookClipboard) self.popMenuAddressBook.addAction(self.actionAddressBookClipboard)
self.popMenuAddressBook.addAction(self.actionAddressBookSubscribe) self.popMenuAddressBook.addAction(self.actionAddressBookSubscribe)
@ -3353,7 +3353,7 @@ class MyForm(settingsmixin.SMainWindow):
self.click_pushButtonAddSubscription() self.click_pushButtonAddSubscription()
def on_action_SubscriptionsDelete(self): def on_action_SubscriptionsDelete(self):
if QtGui.QMessageBox.question( if QtWidgets.QMessageBox.question(
self, "Delete subscription?", self, "Delete subscription?",
_translate( _translate(
"MainWindow", "MainWindow",
@ -3364,8 +3364,8 @@ class MyForm(settingsmixin.SMainWindow):
" messages, but you can still view messages you" " messages, but you can still view messages you"
" already received.\n\nAre you sure you want to" " already received.\n\nAre you sure you want to"
" delete the subscription?" " delete the subscription?"
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No ), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
) != QtGui.QMessageBox.Yes: ) != QtWidgets.QMessageBox.StandardButton.Yes:
return return
address = self.getCurrentAccount() address = self.getCurrentAccount()
sqlExecute('''DELETE FROM subscriptions WHERE address=?''', sqlExecute('''DELETE FROM subscriptions WHERE address=?''',
@ -3377,7 +3377,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_action_SubscriptionsClipboard(self): def on_action_SubscriptionsClipboard(self):
address = self.getCurrentAccount() address = self.getCurrentAccount()
clipboard = QtGui.QApplication.clipboard() clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(str(address)) clipboard.setText(str(address))
def on_action_SubscriptionsEnable(self): def on_action_SubscriptionsEnable(self):
@ -3402,7 +3402,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_context_menuSubscriptions(self, point): def on_context_menuSubscriptions(self, point):
currentItem = self.getCurrentItem() currentItem = self.getCurrentItem()
self.popMenuSubscriptions = QtGui.QMenu(self) self.popMenuSubscriptions = QtWidgets.QMenu(self)
if isinstance(currentItem, Ui_AddressWidget): if isinstance(currentItem, Ui_AddressWidget):
self.popMenuSubscriptions.addAction(self.actionsubscriptionsNew) self.popMenuSubscriptions.addAction(self.actionsubscriptionsNew)
self.popMenuSubscriptions.addAction(self.actionsubscriptionsDelete) self.popMenuSubscriptions.addAction(self.actionsubscriptionsDelete)
@ -3588,7 +3588,7 @@ class MyForm(settingsmixin.SMainWindow):
if account.type == AccountMixin.NORMAL: if account.type == AccountMixin.NORMAL:
return # maybe in the future return # maybe in the future
elif account.type == AccountMixin.CHAN: elif account.type == AccountMixin.CHAN:
if QtGui.QMessageBox.question( if QtWidgets.QMessageBox.question(
self, "Delete channel?", self, "Delete channel?",
_translate( _translate(
"MainWindow", "MainWindow",
@ -3599,8 +3599,8 @@ class MyForm(settingsmixin.SMainWindow):
" messages, but you can still view messages you" " messages, but you can still view messages you"
" already received.\n\nAre you sure you want to" " already received.\n\nAre you sure you want to"
" delete the channel?" " delete the channel?"
), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No ), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
) == QtGui.QMessageBox.Yes: ) == QtWidgets.QMessageBox.StandardButton.Yes:
config.remove_section(str(account.address)) config.remove_section(str(account.address))
else: else:
return return
@ -3641,7 +3641,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_action_Clipboard(self): def on_action_Clipboard(self):
address = self.getCurrentAccount() address = self.getCurrentAccount()
clipboard = QtGui.QApplication.clipboard() clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(str(address)) clipboard.setText(str(address))
def on_action_ClipboardMessagelist(self): def on_action_ClipboardMessagelist(self):
@ -3666,7 +3666,7 @@ class MyForm(settingsmixin.SMainWindow):
else: else:
text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole) text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole)
clipboard = QtGui.QApplication.clipboard() clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(text) clipboard.setText(text)
# set avatar functions # set avatar functions
@ -3724,7 +3724,7 @@ class MyForm(settingsmixin.SMainWindow):
current_files += [upper] current_files += [upper]
filters[0:0] = ['Image files (' + ' '.join(all_images_filter) + ')'] filters[0:0] = ['Image files (' + ' '.join(all_images_filter) + ')']
filters[1:1] = ['All files (*.*)'] filters[1:1] = ['All files (*.*)']
sourcefile = QtGui.QFileDialog.getOpenFileName( sourcefile = QtWidgets.QFileDialog.getOpenFileName(
self, _translate("MainWindow", "Set avatar..."), self, _translate("MainWindow", "Set avatar..."),
filter=';;'.join(filters) filter=';;'.join(filters)
) )
@ -3736,11 +3736,11 @@ class MyForm(settingsmixin.SMainWindow):
if exists | (len(current_files) > 0): if exists | (len(current_files) > 0):
displayMsg = _translate( displayMsg = _translate(
"MainWindow", "Do you really want to remove this avatar?") "MainWindow", "Do you really want to remove this avatar?")
overwrite = QtGui.QMessageBox.question( overwrite = QtWidgets.QMessageBox.question(
self, 'Message', displayMsg, self, 'Message', displayMsg,
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No)
else: else:
overwrite = QtGui.QMessageBox.No overwrite = QtWidgets.QMessageBox.StandardButton.No
else: else:
# ask whether to overwrite old avatar # ask whether to overwrite old avatar
if exists | (len(current_files) > 0): if exists | (len(current_files) > 0):
@ -3748,15 +3748,15 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "MainWindow",
"You have already set an avatar for this address." "You have already set an avatar for this address."
" Do you really want to overwrite it?") " Do you really want to overwrite it?")
overwrite = QtGui.QMessageBox.question( overwrite = QtWidgets.QMessageBox.question(
self, 'Message', displayMsg, self, 'Message', displayMsg,
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No)
else: else:
overwrite = QtGui.QMessageBox.No overwrite = QtWidgets.QMessageBox.StandardButton.No
# copy the image file to the appdata folder # copy the image file to the appdata folder
if (not exists) | (overwrite == QtGui.QMessageBox.Yes): if (not exists) | (overwrite == QtWidgets.QMessageBox.StandardButton.Yes):
if overwrite == QtGui.QMessageBox.Yes: if overwrite == QtWidgets.QMessageBox.StandardButton.Yes:
for file in current_files: for file in current_files:
QtCore.QFile.remove(file) QtCore.QFile.remove(file)
QtCore.QFile.remove(destination) QtCore.QFile.remove(destination)
@ -3788,7 +3788,7 @@ class MyForm(settingsmixin.SMainWindow):
"MainWindow", "Sound files (%s)" % "MainWindow", "Sound files (%s)" %
' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions]) ' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions])
))] ))]
sourcefile = str(QtGui.QFileDialog.getOpenFileName( sourcefile = str(QtWidgets.QFileDialog.getOpenFileName(
self, _translate("MainWindow", "Set notification sound..."), self, _translate("MainWindow", "Set notification sound..."),
filter=';;'.join(filters) filter=';;'.join(filters)
)) ))
@ -3806,15 +3806,15 @@ class MyForm(settingsmixin.SMainWindow):
pattern = destfile.lower() pattern = destfile.lower()
for item in os.listdir(destdir): for item in os.listdir(destdir):
if item.lower() == pattern: if item.lower() == pattern:
overwrite = QtGui.QMessageBox.question( overwrite = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Message"), self, _translate("MainWindow", "Message"),
_translate( _translate(
"MainWindow", "MainWindow",
"You have already set a notification sound" "You have already set a notification sound"
" for this address book entry." " for this address book entry."
" Do you really want to overwrite it?"), " Do you really want to overwrite it?"),
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No
) == QtGui.QMessageBox.Yes ) == QtWidgets.QMessageBox.StandardButton.Yes
if overwrite: if overwrite:
QtCore.QFile.remove(os.path.join(destdir, item)) QtCore.QFile.remove(os.path.join(destdir, item))
break break
@ -3825,7 +3825,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_context_menuYourIdentities(self, point): def on_context_menuYourIdentities(self, point):
currentItem = self.getCurrentItem() currentItem = self.getCurrentItem()
self.popMenuYourIdentities = QtGui.QMenu(self) self.popMenuYourIdentities = QtWidgets.QMenu(self)
if isinstance(currentItem, Ui_AddressWidget): if isinstance(currentItem, Ui_AddressWidget):
self.popMenuYourIdentities.addAction(self.actionNewYourIdentities) self.popMenuYourIdentities.addAction(self.actionNewYourIdentities)
self.popMenuYourIdentities.addSeparator() self.popMenuYourIdentities.addSeparator()
@ -3855,7 +3855,7 @@ class MyForm(settingsmixin.SMainWindow):
# TODO make one popMenu # TODO make one popMenu
def on_context_menuChan(self, point): def on_context_menuChan(self, point):
currentItem = self.getCurrentItem() currentItem = self.getCurrentItem()
self.popMenu = QtGui.QMenu(self) self.popMenu = QtWidgets.QMenu(self)
if isinstance(currentItem, Ui_AddressWidget): if isinstance(currentItem, Ui_AddressWidget):
self.popMenu.addAction(self.actionNew) self.popMenu.addAction(self.actionNew)
self.popMenu.addAction(self.actionDelete) self.popMenu.addAction(self.actionDelete)
@ -3891,7 +3891,7 @@ class MyForm(settingsmixin.SMainWindow):
self.on_context_menuSent(point) self.on_context_menuSent(point)
return return
self.popMenuInbox = QtGui.QMenu(self) self.popMenuInbox = QtWidgets.QMenu(self)
self.popMenuInbox.addAction(self.actionForceHtml) self.popMenuInbox.addAction(self.actionForceHtml)
self.popMenuInbox.addAction(self.actionMarkUnread) self.popMenuInbox.addAction(self.actionMarkUnread)
self.popMenuInbox.addSeparator() self.popMenuInbox.addSeparator()
@ -3926,7 +3926,7 @@ class MyForm(settingsmixin.SMainWindow):
def on_context_menuSent(self, point): def on_context_menuSent(self, point):
currentRow = self.ui.tableWidgetInbox.currentRow() currentRow = self.ui.tableWidgetInbox.currentRow()
self.popMenuSent = QtGui.QMenu(self) self.popMenuSent = QtWidgets.QMenu(self)
self.popMenuSent.addAction(self.actionSentClipboard) self.popMenuSent.addAction(self.actionSentClipboard)
self._contact_selected = self.ui.tableWidgetInbox.item(currentRow, 0) self._contact_selected = self.ui.tableWidgetInbox.item(currentRow, 0)
# preloaded gui.menu plugins with prefix 'address' # preloaded gui.menu plugins with prefix 'address'

View File

@ -9,10 +9,13 @@
from PyQt6 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from bmconfigparser import config from bmconfigparser import config
from .foldertree import AddressBookCompleter from .foldertree import AddressBookCompleter
from .blacklist import Blacklist
from .networkstatus import NetworkStatus
class Ui_MainWindow(object): class Ui_MainWindow(object):
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow") MainWindow.setObjectName("MainWindow")
MainWindow.resize(885, 580)
self.MainDock = QtWidgets.QDockWidget(parent=MainWindow) self.MainDock = QtWidgets.QDockWidget(parent=MainWindow)
self.MainDock.setGeometry(QtCore.QRect(0, 0, 885, 580)) self.MainDock.setGeometry(QtCore.QRect(0, 0, 885, 580))
icon = QtGui.QIcon() icon = QtGui.QIcon()
@ -434,8 +437,14 @@ class Ui_MainWindow(object):
icon8 = QtGui.QIcon() icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-16px.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) icon8.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-16px.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.tabWidget.addTab(self.tab_3, icon8, "") self.tabWidget.addTab(self.tab_3, icon8, "")
self.blackwhitelist = QtWidgets.QWidget() self.blackwhitelist = Blacklist()
self.blackwhitelist.setObjectName("blackwhitelist") self.blackwhitelist.setObjectName("blackwhitelist")
self.tabWidget.addTab(self.blackwhitelist, QtGui.QIcon(":/newPrefix/images/blacklist.png"), "")
# Initialize the Blacklist or Whitelist
if config.get('bitmessagesettings', 'blackwhitelist') == 'white':
self.blackwhitelist.radioButtonWhitelist.click()
self.blackwhitelist.rerenderBlackWhiteList()
self.gridLayout_6 = QtWidgets.QGridLayout(self.blackwhitelist) self.gridLayout_6 = QtWidgets.QGridLayout(self.blackwhitelist)
self.gridLayout_6.setObjectName("gridLayout_6") self.gridLayout_6.setObjectName("gridLayout_6")
self.radioButtonBlacklist = QtWidgets.QRadioButton(parent=self.blackwhitelist) self.radioButtonBlacklist = QtWidgets.QRadioButton(parent=self.blackwhitelist)
@ -471,7 +480,8 @@ class Ui_MainWindow(object):
icon9 = QtGui.QIcon() icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap(":/newPrefix/images/blacklist.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) icon9.addPixmap(QtGui.QPixmap(":/newPrefix/images/blacklist.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.tabWidget.addTab(self.blackwhitelist, icon9, "") self.tabWidget.addTab(self.blackwhitelist, icon9, "")
self.networkstatus = QtWidgets.QWidget() self.networkstatus = NetworkStatus()
self.tabWidget.addTab(self.networkstatus, QtGui.QIcon(":/newPrefix/images/networkstatus.png"), "")
self.networkstatus.setObjectName("networkstatus") self.networkstatus.setObjectName("networkstatus")
self.pushButtonStatusIcon = QtWidgets.QPushButton(parent=self.networkstatus) self.pushButtonStatusIcon = QtWidgets.QPushButton(parent=self.networkstatus)
self.pushButtonStatusIcon.setGeometry(QtCore.QRect(680, 440, 21, 23)) self.pushButtonStatusIcon.setGeometry(QtCore.QRect(680, 440, 21, 23))
@ -539,8 +549,7 @@ class Ui_MainWindow(object):
self.tabWidget.addTab(self.networkstatus, icon11, "") self.tabWidget.addTab(self.networkstatus, icon11, "")
self.gridLayout_10.addWidget(self.tabWidget, 0, 0, 1, 1) self.gridLayout_10.addWidget(self.tabWidget, 0, 0, 1, 1)
self.MainDock.setWidget(self.centralwidget) self.MainDock.setWidget(self.centralwidget)
# XXX unresolved MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea.AllDockWidgetAreas, self.MainDock)
#MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(None), self.MainDock)
self.menubar = QtWidgets.QMenuBar(parent=MainWindow) self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 885, 27)) self.menubar.setGeometry(QtCore.QRect(0, 0, 885, 27))
self.menubar.setObjectName("menubar") self.menubar.setObjectName("menubar")
@ -637,6 +646,7 @@ class Ui_MainWindow(object):
self.subscriptionsContextMenuToolbar = QtWidgets.QToolBar() self.subscriptionsContextMenuToolbar = QtWidgets.QToolBar()
def updateNetworkSwitchMenuLabel(self, dontconnect=None): def updateNetworkSwitchMenuLabel(self, dontconnect=None):
_translate = QtCore.QCoreApplication.translate
if dontconnect is None: if dontconnect is None:
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
dontconnect = config.safeGetBoolean( dontconnect = config.safeGetBoolean(
@ -741,7 +751,10 @@ class Ui_MainWindow(object):
item.setText(_translate("MainWindow", "Name or Label")) item.setText(_translate("MainWindow", "Name or Label"))
item = self.tableWidgetBlacklist.horizontalHeaderItem(1) item = self.tableWidgetBlacklist.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Address")) item.setText(_translate("MainWindow", "Address"))
self.blackwhitelist.retranslateUi()
self.tabWidget.setTabText(self.tabWidget.indexOf(self.blackwhitelist), _translate("MainWindow", "Blacklist")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.blackwhitelist), _translate("MainWindow", "Blacklist"))
self.networkstatus.retranslateUi()
self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), _translate("MainWindow", "Network Status"))
item = self.tableWidgetConnectionCount.horizontalHeaderItem(0) item = self.tableWidgetConnectionCount.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Stream #")) item.setText(_translate("MainWindow", "Stream #"))
item = self.tableWidgetConnectionCount.horizontalHeaderItem(1) item = self.tableWidgetConnectionCount.horizontalHeaderItem(1)

View File

@ -1,16 +1,18 @@
--- bitmessageui.py.orig 2024-05-12 18:57:04.429581050 +0900 --- bitmessageui.py.orig 2024-05-13 08:32:22.376971328 +0900
+++ bitmessageui.py 2024-05-12 19:50:49.951776910 +0900 +++ bitmessageui.py 2024-05-13 09:48:39.354481762 +0900
@@ -7,7 +7,8 @@ @@ -7,7 +7,10 @@
from PyQt6 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
- -
+from bmconfigparser import config +from bmconfigparser import config
+from .foldertree import AddressBookCompleter +from .foldertree import AddressBookCompleter
+from .blacklist import Blacklist
+from .networkstatus import NetworkStatus
class Ui_MainWindow(object): class Ui_MainWindow(object):
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
@@ -137,6 +138,11 @@ @@ -140,6 +143,11 @@
self.tableWidgetAddressBook.horizontalHeader().setStretchLastSection(True) self.tableWidgetAddressBook.horizontalHeader().setStretchLastSection(True)
self.tableWidgetAddressBook.verticalHeader().setVisible(False) self.tableWidgetAddressBook.verticalHeader().setVisible(False)
self.verticalLayout_2.addWidget(self.tableWidgetAddressBook) self.verticalLayout_2.addWidget(self.tableWidgetAddressBook)
@ -22,7 +24,7 @@
self.pushButtonAddAddressBook = QtWidgets.QPushButton(parent=self.send) self.pushButtonAddAddressBook = QtWidgets.QPushButton(parent=self.send)
self.pushButtonAddAddressBook.setMaximumSize(QtCore.QSize(200, 16777215)) self.pushButtonAddAddressBook.setMaximumSize(QtCore.QSize(200, 16777215))
self.pushButtonAddAddressBook.setObjectName("pushButtonAddAddressBook") self.pushButtonAddAddressBook.setObjectName("pushButtonAddAddressBook")
@@ -181,6 +187,7 @@ @@ -184,6 +192,7 @@
self.lineEditTo = QtWidgets.QLineEdit(parent=self.tab) self.lineEditTo = QtWidgets.QLineEdit(parent=self.tab)
self.lineEditTo.setObjectName("lineEditTo") self.lineEditTo.setObjectName("lineEditTo")
self.gridLayout_2.addWidget(self.lineEditTo, 1, 1, 1, 1) self.gridLayout_2.addWidget(self.lineEditTo, 1, 1, 1, 1)
@ -30,7 +32,7 @@
self.verticalLayout_5.addLayout(self.gridLayout_2) self.verticalLayout_5.addLayout(self.gridLayout_2)
self.textEditMessage = QtWidgets.QTextEdit(parent=self.tab) self.textEditMessage = QtWidgets.QTextEdit(parent=self.tab)
self.textEditMessage.setObjectName("textEditMessage") self.textEditMessage.setObjectName("textEditMessage")
@@ -260,6 +267,9 @@ @@ -263,6 +272,9 @@
self.labelHumanFriendlyTTLDescription.setMaximumSize(QtCore.QSize(45, 16777215)) self.labelHumanFriendlyTTLDescription.setMaximumSize(QtCore.QSize(45, 16777215))
self.labelHumanFriendlyTTLDescription.setObjectName("labelHumanFriendlyTTLDescription") self.labelHumanFriendlyTTLDescription.setObjectName("labelHumanFriendlyTTLDescription")
self.horizontalLayout_5.addWidget(self.labelHumanFriendlyTTLDescription) self.horizontalLayout_5.addWidget(self.labelHumanFriendlyTTLDescription)
@ -40,7 +42,42 @@
self.pushButtonSend = QtWidgets.QPushButton(parent=self.send) self.pushButtonSend = QtWidgets.QPushButton(parent=self.send)
self.pushButtonSend.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.pushButtonSend.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.pushButtonSend.setObjectName("pushButtonSend") self.pushButtonSend.setObjectName("pushButtonSend")
@@ -546,6 +556,8 @@ @@ -425,8 +437,14 @@
icon8 = QtGui.QIcon()
icon8.addPixmap(QtGui.QPixmap(":/newPrefix/images/can-icon-16px.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.tabWidget.addTab(self.tab_3, icon8, "")
- self.blackwhitelist = QtWidgets.QWidget()
+ self.blackwhitelist = Blacklist()
self.blackwhitelist.setObjectName("blackwhitelist")
+ self.tabWidget.addTab(self.blackwhitelist, QtGui.QIcon(":/newPrefix/images/blacklist.png"), "")
+ # Initialize the Blacklist or Whitelist
+ if config.get('bitmessagesettings', 'blackwhitelist') == 'white':
+ self.blackwhitelist.radioButtonWhitelist.click()
+ self.blackwhitelist.rerenderBlackWhiteList()
+
self.gridLayout_6 = QtWidgets.QGridLayout(self.blackwhitelist)
self.gridLayout_6.setObjectName("gridLayout_6")
self.radioButtonBlacklist = QtWidgets.QRadioButton(parent=self.blackwhitelist)
@@ -462,7 +480,8 @@
icon9 = QtGui.QIcon()
icon9.addPixmap(QtGui.QPixmap(":/newPrefix/images/blacklist.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
self.tabWidget.addTab(self.blackwhitelist, icon9, "")
- self.networkstatus = QtWidgets.QWidget()
+ self.networkstatus = NetworkStatus()
+ self.tabWidget.addTab(self.networkstatus, QtGui.QIcon(":/newPrefix/images/networkstatus.png"), "")
self.networkstatus.setObjectName("networkstatus")
self.pushButtonStatusIcon = QtWidgets.QPushButton(parent=self.networkstatus)
self.pushButtonStatusIcon.setGeometry(QtCore.QRect(680, 440, 21, 23))
@@ -530,7 +549,7 @@
self.tabWidget.addTab(self.networkstatus, icon11, "")
self.gridLayout_10.addWidget(self.tabWidget, 0, 0, 1, 1)
self.MainDock.setWidget(self.centralwidget)
- MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(None), self.MainDock)
+ MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea.AllDockWidgetAreas, self.MainDock)
self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 885, 27))
self.menubar.setObjectName("menubar")
@@ -550,6 +569,8 @@
self.actionManageKeys = QtGui.QAction(parent=MainWindow) self.actionManageKeys = QtGui.QAction(parent=MainWindow)
self.actionManageKeys.setCheckable(False) self.actionManageKeys.setCheckable(False)
self.actionManageKeys.setEnabled(True) self.actionManageKeys.setEnabled(True)
@ -49,7 +86,7 @@
icon = QtGui.QIcon.fromTheme("dialog-password") icon = QtGui.QIcon.fromTheme("dialog-password")
self.actionManageKeys.setIcon(icon) self.actionManageKeys.setIcon(icon)
self.actionManageKeys.setObjectName("actionManageKeys") self.actionManageKeys.setObjectName("actionManageKeys")
@@ -557,6 +569,10 @@ @@ -561,6 +582,10 @@
icon = QtGui.QIcon.fromTheme("help-contents") icon = QtGui.QIcon.fromTheme("help-contents")
self.actionHelp.setIcon(icon) self.actionHelp.setIcon(icon)
self.actionHelp.setObjectName("actionHelp") self.actionHelp.setObjectName("actionHelp")
@ -60,7 +97,7 @@
self.actionAbout = QtGui.QAction(parent=MainWindow) self.actionAbout = QtGui.QAction(parent=MainWindow)
icon = QtGui.QIcon.fromTheme("help-about") icon = QtGui.QIcon.fromTheme("help-about")
self.actionAbout.setIcon(icon) self.actionAbout.setIcon(icon)
@@ -580,9 +596,11 @@ @@ -584,9 +609,11 @@
self.menuFile.addAction(self.actionManageKeys) self.menuFile.addAction(self.actionManageKeys)
self.menuFile.addAction(self.actionDeleteAllTrashedMessages) self.menuFile.addAction(self.actionDeleteAllTrashedMessages)
self.menuFile.addAction(self.actionRegenerateDeterministicAddresses) self.menuFile.addAction(self.actionRegenerateDeterministicAddresses)
@ -72,7 +109,7 @@
self.menuHelp.addAction(self.actionAbout) self.menuHelp.addAction(self.actionAbout)
self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuFile.menuAction())
self.menubar.addAction(self.menuSettings.menuAction()) self.menubar.addAction(self.menuSettings.menuAction())
@@ -606,6 +624,25 @@ @@ -610,6 +637,26 @@
MainWindow.setTabOrder(self.tableWidgetBlacklist, self.tableWidgetConnectionCount) MainWindow.setTabOrder(self.tableWidgetBlacklist, self.tableWidgetConnectionCount)
MainWindow.setTabOrder(self.tableWidgetConnectionCount, self.pushButtonStatusIcon) MainWindow.setTabOrder(self.tableWidgetConnectionCount, self.pushButtonStatusIcon)
@ -85,6 +122,7 @@
+ self.subscriptionsContextMenuToolbar = QtWidgets.QToolBar() + self.subscriptionsContextMenuToolbar = QtWidgets.QToolBar()
+ +
+ def updateNetworkSwitchMenuLabel(self, dontconnect=None): + def updateNetworkSwitchMenuLabel(self, dontconnect=None):
+ _translate = QtCore.QCoreApplication.translate
+ if dontconnect is None: + if dontconnect is None:
+ _translate = QtCore.QCoreApplication.translate + _translate = QtCore.QCoreApplication.translate
+ dontconnect = config.safeGetBoolean( + dontconnect = config.safeGetBoolean(
@ -97,8 +135,8 @@
+ +
def retranslateUi(self, MainWindow): def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate _translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Bitmessage")) self.MainDock.setWindowTitle(_translate("MainWindow", "Bitmessage"))
@@ -653,6 +690,7 @@ @@ -657,6 +704,7 @@
self.tabWidgetSend.setTabText(self.tabWidgetSend.indexOf(self.tab_2), _translate("MainWindow", "Send Message to your Subscribers")) self.tabWidgetSend.setTabText(self.tabWidgetSend.indexOf(self.tab_2), _translate("MainWindow", "Send Message to your Subscribers"))
self.pushButtonTTL.setText(_translate("MainWindow", "TTL:")) self.pushButtonTTL.setText(_translate("MainWindow", "TTL:"))
self.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "X days")) self.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "X days"))
@ -106,7 +144,18 @@
self.pushButtonSend.setText(_translate("MainWindow", "Send")) self.pushButtonSend.setText(_translate("MainWindow", "Send"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.send), _translate("MainWindow", "Send")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.send), _translate("MainWindow", "Send"))
self.treeWidgetSubscriptions.headerItem().setText(0, _translate("MainWindow", "Subscriptions")) self.treeWidgetSubscriptions.headerItem().setText(0, _translate("MainWindow", "Subscriptions"))
@@ -722,8 +760,10 @@ @@ -703,7 +751,10 @@
item.setText(_translate("MainWindow", "Name or Label"))
item = self.tableWidgetBlacklist.horizontalHeaderItem(1)
item.setText(_translate("MainWindow", "Address"))
+ self.blackwhitelist.retranslateUi()
self.tabWidget.setTabText(self.tabWidget.indexOf(self.blackwhitelist), _translate("MainWindow", "Blacklist"))
+ self.networkstatus.retranslateUi()
+ self.tabWidget.setTabText(self.tabWidget.indexOf(self.networkstatus), _translate("MainWindow", "Network Status"))
item = self.tableWidgetConnectionCount.horizontalHeaderItem(0)
item.setText(_translate("MainWindow", "Stream #"))
item = self.tableWidgetConnectionCount.horizontalHeaderItem(1)
@@ -726,8 +777,10 @@
self.actionExit.setShortcut(_translate("MainWindow", "Ctrl+Q")) self.actionExit.setShortcut(_translate("MainWindow", "Ctrl+Q"))
self.actionHelp.setText(_translate("MainWindow", "Help")) self.actionHelp.setText(_translate("MainWindow", "Help"))
self.actionHelp.setShortcut(_translate("MainWindow", "F1")) self.actionHelp.setShortcut(_translate("MainWindow", "F1"))

View File

@ -12,6 +12,7 @@ from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object): class Ui_MainWindow(object):
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow") MainWindow.setObjectName("MainWindow")
MainWindow.resize(885, 580)
self.MainDock = QtWidgets.QDockWidget(parent=MainWindow) self.MainDock = QtWidgets.QDockWidget(parent=MainWindow)
self.MainDock.setGeometry(QtCore.QRect(0, 0, 885, 580)) self.MainDock.setGeometry(QtCore.QRect(0, 0, 885, 580))
icon = QtGui.QIcon() icon = QtGui.QIcon()

View File

@ -2,6 +2,14 @@
<ui version="4.0"> <ui version="4.0">
<class>MainWindow</class> <class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow"> <widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>885</width>
<height>580</height>
</rect>
</property>
<widget class="QDockWidget" name="MainDock"> <widget class="QDockWidget" name="MainDock">
<property name="geometry"> <property name="geometry">
<rect> <rect>

View File

@ -51,13 +51,13 @@ class AccountMixin(object):
def accountBrush(self): def accountBrush(self):
"""Account brush (for QT UI)""" """Account brush (for QT UI)"""
brush = QtGui.QBrush(self.accountColor()) brush = QtGui.QBrush(self.accountColor())
brush.setStyle(QtCore.Qt.NoBrush) brush.setStyle(QtCore.Qt.BrushStyle.NoBrush)
return brush return brush
def folderBrush(self): def folderBrush(self):
"""Folder brush (for QT UI)""" """Folder brush (for QT UI)"""
brush = QtGui.QBrush(self.folderColor()) brush = QtGui.QBrush(self.folderColor())
brush.setStyle(QtCore.Qt.NoBrush) brush.setStyle(QtCore.Qt.BrushStyle.NoBrush)
return brush return brush
def accountString(self): def accountString(self):
@ -124,7 +124,7 @@ class AccountMixin(object):
AccountMixin.NORMAL, AccountMixin.NORMAL,
AccountMixin.CHAN, AccountMixin.MAILINGLIST): AccountMixin.CHAN, AccountMixin.MAILINGLIST):
try: try:
retval = unicode( retval = str(
config.get(self.address, 'label'), 'utf-8') config.get(self.address, 'label'), 'utf-8')
except Exception: except Exception:
queryreturn = sqlQuery( queryreturn = sqlQuery(
@ -136,12 +136,12 @@ class AccountMixin(object):
if queryreturn != []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
retval, = row retval, = row
retval = unicode(retval, 'utf-8') retval = str(retval, 'utf-8')
elif self.address is None or self.type == AccountMixin.ALL: elif self.address is None or self.type == AccountMixin.ALL:
return unicode( return str(
str(_translate("MainWindow", "All accounts")), 'utf-8') str(_translate("MainWindow", "All accounts")), 'utf-8')
return retval or unicode(self.address, 'utf-8') return retval or str(self.address, 'utf-8')
class BMTreeWidgetItem(QtWidgets.QTreeWidgetItem, AccountMixin): class BMTreeWidgetItem(QtWidgets.QTreeWidgetItem, AccountMixin):
@ -210,7 +210,7 @@ class Ui_FolderWidget(BMTreeWidgetItem):
y = self.folderWeight[other.folderName] y = self.folderWeight[other.folderName]
else: else:
y = 99 y = 99
reverse = QtCore.Qt.DescendingOrder == \ reverse = QtCore.Qt.SortOrder.DescendingOrder == \
self.treeWidget().header().sortIndicatorOrder() self.treeWidget().header().sortIndicatorOrder()
if x == y: if x == y:
return self.folderName < other.folderName return self.folderName < other.folderName
@ -232,15 +232,15 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin):
def _getLabel(self): def _getLabel(self):
if self.address is None: if self.address is None:
return unicode(_translate( return _translate(
"MainWindow", "All accounts").toUtf8(), 'utf-8', 'ignore') "MainWindow", "All accounts")
else: else:
try: try:
return unicode( return str(
config.get(self.address, 'label'), config.get(self.address, 'label'),
'utf-8', 'ignore') 'utf-8', 'ignore')
except: except:
return unicode(self.address, 'utf-8') return str(self.address, 'utf-8')
def _getAddressBracket(self, unreadCount=False): def _getAddressBracket(self, unreadCount=False):
ret = "" if self.isExpanded() \ ret = "" if self.isExpanded() \
@ -284,7 +284,7 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin):
def __lt__(self, other): def __lt__(self, other):
# pylint: disable=protected-access # pylint: disable=protected-access
if isinstance(other, Ui_AddressWidget): if isinstance(other, Ui_AddressWidget):
reverse = QtCore.Qt.DescendingOrder == \ reverse = QtCore.Qt.SortOrder.DescendingOrder == \
self.treeWidget().header().sortIndicatorOrder() self.treeWidget().header().sortIndicatorOrder()
if self._getSortRank() == other._getSortRank(): if self._getSortRank() == other._getSortRank():
x = self._getLabel().lower() x = self._getLabel().lower()
@ -311,8 +311,8 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
if queryreturn != []: if queryreturn != []:
for row in queryreturn: for row in queryreturn:
retval, = row retval, = row
return unicode(retval, 'utf-8', 'ignore') return str(retval, 'utf-8', 'ignore')
return unicode(self.address, 'utf-8') return str(self.address, 'utf-8')
def setType(self): def setType(self):
"""Set account type""" """Set account type"""
@ -326,7 +326,7 @@ class Ui_SubscriptionWidget(Ui_AddressWidget):
label = str( label = str(
value.toString().toUtf8()).decode('utf-8', 'ignore') value.toString().toUtf8()).decode('utf-8', 'ignore')
else: else:
label = unicode(value, 'utf-8', 'ignore') label = str(value, 'utf-8', 'ignore')
sqlExecute( sqlExecute(
'''UPDATE subscriptions SET label=? WHERE address=?''', '''UPDATE subscriptions SET label=? WHERE address=?''',
label, self.address) label, self.address)
@ -407,7 +407,7 @@ class MessageList_AddressWidget(BMAddressWidget):
AccountMixin.NORMAL, AccountMixin.NORMAL,
AccountMixin.CHAN, AccountMixin.MAILINGLIST): AccountMixin.CHAN, AccountMixin.MAILINGLIST):
try: try:
newLabel = unicode( newLabel = str(
config.get(self.address, 'label'), config.get(self.address, 'label'),
'utf-8', 'ignore') 'utf-8', 'ignore')
except: except:
@ -418,7 +418,7 @@ class MessageList_AddressWidget(BMAddressWidget):
'''select label from subscriptions where address=?''', self.address) '''select label from subscriptions where address=?''', self.address)
if queryreturn: if queryreturn:
for row in queryreturn: for row in queryreturn:
newLabel = unicode(row[0], 'utf-8', 'ignore') newLabel = str(row[0], 'utf-8', 'ignore')
self.label = newLabel self.label = newLabel
@ -456,7 +456,7 @@ class MessageList_SubjectWidget(BMTableWidgetItem):
if role == QtCore.Qt.ItemDataRole.UserRole: if role == QtCore.Qt.ItemDataRole.UserRole:
return self.subject return self.subject
if role == QtCore.Qt.ItemDataRole.ToolTipRole: if role == QtCore.Qt.ItemDataRole.ToolTipRole:
return escape(unicode(self.subject, 'utf-8')) return escape(str(self.subject, 'utf-8'))
return super(MessageList_SubjectWidget, self).data(role) return super(MessageList_SubjectWidget, self).data(role)
# label (or address) alphabetically, disabled at the end # label (or address) alphabetically, disabled at the end
@ -534,7 +534,7 @@ class Ui_AddressBookWidgetItem(BMAddressWidget):
def __lt__(self, other): def __lt__(self, other):
if isinstance(other, Ui_AddressBookWidgetItem): if isinstance(other, Ui_AddressBookWidgetItem):
reverse = QtCore.Qt.DescendingOrder == \ reverse = QtCore.Qt.SortOrder.DescendingOrder == \
self.tableWidget().horizontalHeader().sortIndicatorOrder() self.tableWidget().horizontalHeader().sortIndicatorOrder()
if self.type == other.type: if self.type == other.type:
@ -584,14 +584,14 @@ class AddressBookCompleter(QtWidgets.QCompleter):
def splitPath(self, path): def splitPath(self, path):
"""Split on semicolon""" """Split on semicolon"""
text = unicode(path.toUtf8(), 'utf-8') text = str(path.toUtf8(), 'utf-8')
return [text[:self.widget().cursorPosition()].split(';')[-1].strip()] return [text[:self.widget().cursorPosition()].split(';')[-1].strip()]
def pathFromIndex(self, index): def pathFromIndex(self, index):
"""Perform autocompletion (reimplemented QCompleter method)""" """Perform autocompletion (reimplemented QCompleter method)"""
autoString = unicode( autoString = str(
index.data(QtCore.Qt.ItemDataRole.EditRole).toString().toUtf8(), 'utf-8') index.data(QtCore.Qt.ItemDataRole.EditRole).toString().toUtf8(), 'utf-8')
text = unicode(self.widget().text().toUtf8(), 'utf-8') text = str(self.widget().text().toUtf8(), 'utf-8')
# If cursor position was saved, restore it, else save it # If cursor position was saved, restore it, else save it
if self.cursorPos != -1: if self.cursorPos != -1:

View File

@ -125,12 +125,12 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
self.labelBytesRecvCount.setText( self.labelBytesRecvCount.setText(
_translate( _translate(
"networkstatus", "networkstatus",
"Down: %1/s Total: %2").arg( "Down: {0}/s Total: {1}").format(
self.formatByteRate(network.stats.downloadSpeed()), self.formatByteRate(network.stats.downloadSpeed()),
self.formatBytes(network.stats.receivedBytes()))) self.formatBytes(network.stats.receivedBytes())))
self.labelBytesSentCount.setText( self.labelBytesSentCount.setText(
_translate( _translate(
"networkstatus", "Up: %1/s Total: %2").arg( "networkstatus", "Up: {0}/s Total: {1}").format(
self.formatByteRate(network.stats.uploadSpeed()), self.formatByteRate(network.stats.uploadSpeed()),
self.formatBytes(network.stats.sentBytes()))) self.formatBytes(network.stats.sentBytes())))
@ -160,19 +160,19 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
self.tableWidgetConnectionCount.insertRow(0) self.tableWidgetConnectionCount.insertRow(0)
self.tableWidgetConnectionCount.setItem( self.tableWidgetConnectionCount.setItem(
0, 0, 0, 0,
QtGui.QTableWidgetItem("%s:%i" % (destination.host, destination.port)) QtWidgets.QTableWidgetItem("%s:%i" % (destination.host, destination.port))
) )
self.tableWidgetConnectionCount.setItem( self.tableWidgetConnectionCount.setItem(
0, 2, 0, 2,
QtGui.QTableWidgetItem("%s" % (c.userAgent)) QtWidgets.QTableWidgetItem("%s" % (c.userAgent))
) )
self.tableWidgetConnectionCount.setItem( self.tableWidgetConnectionCount.setItem(
0, 3, 0, 3,
QtGui.QTableWidgetItem("%s" % (c.tlsVersion)) QtWidgets.QTableWidgetItem("%s" % (c.tlsVersion))
) )
self.tableWidgetConnectionCount.setItem( self.tableWidgetConnectionCount.setItem(
0, 4, 0, 4,
QtGui.QTableWidgetItem("%s" % (",".join(map(str, c.streams)))) QtWidgets.QTableWidgetItem("%s" % (",".join(map(str, c.streams))))
) )
try: try:
# .. todo:: FIXME: hard coded stream no # .. todo:: FIXME: hard coded stream no
@ -181,23 +181,23 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
rating = "-" rating = "-"
self.tableWidgetConnectionCount.setItem( self.tableWidgetConnectionCount.setItem(
0, 1, 0, 1,
QtGui.QTableWidgetItem("%s" % (rating)) QtWidgets.QTableWidgetItem("%s" % (rating))
) )
if outbound: if outbound:
brush = QtGui.QBrush(QtGui.QColor("yellow"), QtCore.Qt.SolidPattern) brush = QtGui.QBrush(QtGui.QColor("yellow"), QtCore.Qt.BrushStyle.SolidPattern)
else: else:
brush = QtGui.QBrush(QtGui.QColor("green"), QtCore.Qt.SolidPattern) brush = QtGui.QBrush(QtGui.QColor("green"), QtCore.Qt.BrushStyle.SolidPattern)
for j in range(1): for j in range(1):
self.tableWidgetConnectionCount.item(0, j).setBackground(brush) self.tableWidgetConnectionCount.item(0, j).setBackground(brush)
self.tableWidgetConnectionCount.item(0, 0).setData(QtCore.Qt.UserRole, destination) self.tableWidgetConnectionCount.item(0, 0).setData(QtCore.Qt.ItemDataRole.UserRole, destination)
self.tableWidgetConnectionCount.item(0, 1).setData(QtCore.Qt.UserRole, outbound) self.tableWidgetConnectionCount.item(0, 1).setData(QtCore.Qt.ItemDataRole.UserRole, outbound)
else: else:
if not connectionpool.pool.inboundConnections: if not connectionpool.pool.inboundConnections:
self.window().setStatusIcon('yellow') self.window().setStatusIcon('yellow')
for i in range(self.tableWidgetConnectionCount.rowCount()): for i in range(self.tableWidgetConnectionCount.rowCount()):
if self.tableWidgetConnectionCount.item(i, 0).data(QtCore.Qt.UserRole).toPyObject() != destination: if self.tableWidgetConnectionCount.item(i, 0).data(QtCore.Qt.ItemDataRole.UserRole).toPyObject() != destination:
continue continue
if self.tableWidgetConnectionCount.item(i, 1).data(QtCore.Qt.UserRole).toPyObject() == outbound: if self.tableWidgetConnectionCount.item(i, 1).data(QtCore.Qt.ItemDataRole.UserRole).toPyObject() == outbound:
self.tableWidgetConnectionCount.removeRow(i) self.tableWidgetConnectionCount.removeRow(i)
break break
@ -205,7 +205,7 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
self.tableWidgetConnectionCount.setSortingEnabled(True) self.tableWidgetConnectionCount.setSortingEnabled(True)
self.labelTotalConnections.setText( self.labelTotalConnections.setText(
_translate( _translate(
"networkstatus", "Total Connections: %1").arg( "networkstatus", "Total Connections: {0}").format(
str(self.tableWidgetConnectionCount.rowCount()))) str(self.tableWidgetConnectionCount.rowCount())))
# FYI: The 'singlelistener' thread sets the icon color to green when it # FYI: The 'singlelistener' thread sets the icon color to green when it
# receives an incoming connection, meaning that the user's firewall is # receives an incoming connection, meaning that the user's firewall is
@ -218,7 +218,7 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
# timer driven # timer driven
def runEveryTwoSeconds(self): def runEveryTwoSeconds(self):
"""Updates counters, runs every 2 seconds if the timer is running""" """Updates counters, runs every 2 seconds if the timer is running"""
self.labelLookupsPerSecond.setText(_translate("networkstatus", "Inventory lookups per second: %1").arg( self.labelLookupsPerSecond.setText(_translate("networkstatus", "Inventory lookups per second: {0}").format(
str(state.Inventory.numberOfInventoryLookupsPerformed / 2))) str(state.Inventory.numberOfInventoryLookupsPerformed / 2)))
state.Inventory.numberOfInventoryLookupsPerformed = 0 state.Inventory.numberOfInventoryLookupsPerformed = 0
self.updateNumberOfBytes() self.updateNumberOfBytes()
@ -229,11 +229,11 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin):
super(NetworkStatus, self).retranslateUi() super(NetworkStatus, self).retranslateUi()
self.labelTotalConnections.setText( self.labelTotalConnections.setText(
_translate( _translate(
"networkstatus", "Total Connections: %1").arg( "networkstatus", "Total Connections: {0}").format(
str(self.tableWidgetConnectionCount.rowCount()))) str(self.tableWidgetConnectionCount.rowCount())))
self.labelStartupTime.setText(_translate( self.labelStartupTime.setText(_translate(
"networkstatus", "Since startup on %1" "networkstatus", "Since startup on {0}"
).arg(l10n.formatTimestamp(self.startup))) ).format(l10n.formatTimestamp(self.startup)))
self.updateNumberOfMessagesProcessed() self.updateNumberOfMessagesProcessed()
self.updateNumberOfBroadcastsProcessed() self.updateNumberOfBroadcastsProcessed()
self.updateNumberOfPubkeysProcessed() self.updateNumberOfPubkeysProcessed()

View File

@ -1,17 +1,17 @@
from os import path from os import path
from PyQt6 import QtGui from PyQt6 import QtGui, QtWidgets
from debug import logger from debug import logger
import bitmessageqt.widgets import bitmessageqt.widgets as widgets
class RetranslateMixin(object): class RetranslateMixin(object):
def retranslateUi(self): def retranslateUi(self):
defaults = QtGui.QWidget() defaults = QtWidgets.QWidget()
widgets.load(self.__class__.__name__.lower() + '.ui', defaults) widgets.load(self.__class__.__name__.lower() + '.ui', defaults)
for attr, value in defaults.__dict__.iteritems(): for attr, value in defaults.__dict__.items():
setTextMethod = getattr(value, "setText", None) setTextMethod = getattr(value, "setText", None)
if callable(setTextMethod): if callable(setTextMethod):
getattr(self, attr).setText(getattr(defaults, attr).text()) getattr(self, attr).setText(getattr(defaults, attr).text())
elif isinstance(value, QtGui.QTableWidget): elif isinstance(value, QtWidgets.QTableWidget):
for i in range (value.columnCount()): for i in range (value.columnCount()):
getattr(self, attr).horizontalHeaderItem(i).setText( getattr(self, attr).horizontalHeaderItem(i).setText(
getattr(defaults, attr).horizontalHeaderItem(i).text()) getattr(defaults, attr).horizontalHeaderItem(i).text())

View File

@ -163,7 +163,7 @@ class SettingsDialog(QtWidgets.QDialog):
self.comboBoxProxyTypeChanged(self.comboBoxProxyType.currentIndex()) self.comboBoxProxyTypeChanged(self.comboBoxProxyType.currentIndex())
if self._proxy_type: if self._proxy_type:
for node, info in six.iteritems( for node, info in six.items(
knownnodes.knownNodes.get( knownnodes.knownNodes.get(
min(state.streamsInWhichIAmParticipating), []) min(state.streamsInWhichIAmParticipating), [])
): ):

View File

@ -43,69 +43,51 @@ class UISignaler(QThread):
command, data = queues.UISignalQueue.get() command, data = queues.UISignalQueue.get()
if command == 'writeNewAddressToTable': if command == 'writeNewAddressToTable':
label, address, streamNumber = data label, address, streamNumber = data
self.emit( self.writeNewAddressToTable.emit(label, address, str(streamNumber))
SIGNAL("writeNewAddressToTable(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
label,
address,
str(streamNumber))
elif command == 'updateStatusBar': elif command == 'updateStatusBar':
self.updateStatusBar.emit(data) self.updateStatusBar.emit(data)
elif command == 'updateSentItemStatusByToAddress': elif command == 'updateSentItemStatusByToAddress':
toAddress, message = data toAddress, message = data
self.emit(SIGNAL( self.updateSentItemStatusByToAddress.emit(toAddress, message)
"updateSentItemStatusByToAddress(PyQt_PyObject,PyQt_PyObject)"), toAddress, message)
elif command == 'updateSentItemStatusByAckdata': elif command == 'updateSentItemStatusByAckdata':
ackData, message = data ackData, message = data
self.emit(SIGNAL( self.updateSentItemStatusByAckdata.emit(ackData, message)
"updateSentItemStatusByAckdata(PyQt_PyObject,PyQt_PyObject)"), ackData, message)
elif command == 'displayNewInboxMessage': elif command == 'displayNewInboxMessage':
inventoryHash, toAddress, fromAddress, subject, body = data inventoryHash, toAddress, fromAddress, subject, body = data
self.emit(SIGNAL( self.displayNewInboxMessage.emit(inventoryHash, toAddress, fromAddress, subject, body)
"displayNewInboxMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
inventoryHash, toAddress, fromAddress, subject, body)
elif command == 'displayNewSentMessage': elif command == 'displayNewSentMessage':
toAddress, fromLabel, fromAddress, subject, message, ackdata = data toAddress, fromLabel, fromAddress, subject, message, ackdata = data
self.emit(SIGNAL( self.displayNewSentMessage.emit(toAddress, fromLabel, fromAddress, subject, message, ackdata)
"displayNewSentMessage(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
toAddress, fromLabel, fromAddress, subject, message, ackdata)
elif command == 'updateNetworkStatusTab': elif command == 'updateNetworkStatusTab':
outbound, add, destination = data outbound, add, destination = data
self.emit( self.updateNetworkStatusTab.emit(outbound, add, destination)
SIGNAL("updateNetworkStatusTab(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)"),
outbound,
add,
destination)
elif command == 'updateNumberOfMessagesProcessed': elif command == 'updateNumberOfMessagesProcessed':
self.emit(SIGNAL("updateNumberOfMessagesProcessed()")) self.updateNumberOfMessagesProcessed.emit()
elif command == 'updateNumberOfPubkeysProcessed': elif command == 'updateNumberOfPubkeysProcessed':
self.emit(SIGNAL("updateNumberOfPubkeysProcessed()")) self.updateNumberOfPubkeysProcessed.emit()
elif command == 'updateNumberOfBroadcastsProcessed': elif command == 'updateNumberOfBroadcastsProcessed':
self.emit(SIGNAL("updateNumberOfBroadcastsProcessed()")) self.updateNumberOfBroadcastsProcessed.emit()
elif command == 'setStatusIcon': elif command == 'setStatusIcon':
self.emit(SIGNAL("setStatusIcon(PyQt_PyObject)"), data) self.setStatusIcon.emit(data)
elif command == 'changedInboxUnread': elif command == 'changedInboxUnread':
self.emit(SIGNAL("changedInboxUnread(PyQt_PyObject)"), data) self.changedInboxUnread.emit(data)
elif command == 'rerenderMessagelistFromLabels': elif command == 'rerenderMessagelistFromLabels':
self.emit(SIGNAL("rerenderMessagelistFromLabels()")) self.rerenderMessagelistFromLabels.emit()
elif command == 'rerenderMessagelistToLabels': elif command == 'rerenderMessagelistToLabels':
self.emit(SIGNAL("rerenderMessagelistToLabels()")) self.rerenderMessagelistToLabels.emit()
elif command == 'rerenderAddressBook': elif command == 'rerenderAddressBook':
self.emit(SIGNAL("rerenderAddressBook()")) self.rerenderAddressBook.emit()
elif command == 'rerenderSubscriptions': elif command == 'rerenderSubscriptions':
self.emit(SIGNAL("rerenderSubscriptions()")) self.rerenderSubscriptions.emit()
elif command == 'rerenderBlackWhiteList': elif command == 'rerenderBlackWhiteList':
self.emit(SIGNAL("rerenderBlackWhiteList()")) self.rerenderBlackWhiteList.emit()
elif command == 'removeInboxRowByMsgid': elif command == 'removeInboxRowByMsgid':
self.emit(SIGNAL("removeInboxRowByMsgid(PyQt_PyObject)"), data) self.removeInboxRowByMsgid.emit(data)
elif command == 'newVersionAvailable': elif command == 'newVersionAvailable':
self.emit(SIGNAL("newVersionAvailable(PyQt_PyObject)"), data) self.newVersionAvailable.emit(data)
elif command == 'alert': elif command == 'alert':
title, text, exitAfterUserClicksOk = data title, text, exitAfterUserClicksOk = data
self.emit( self.displayAlert.emit(title, text, exitAfterUserClicksOk)
SIGNAL("displayAlert(PyQt_PyObject, PyQt_PyObject, PyQt_PyObject)"),
title,
text,
exitAfterUserClicksOk)
else: else:
sys.stderr.write( sys.stderr.write(
'Command sent to UISignaler not recognized: %s\n' % command) 'Command sent to UISignaler not recognized: %s\n' % command)

View File

@ -38,7 +38,7 @@ def identiconize(address):
# stripped from PIL and uses QT instead (by sendiulo, same license) # stripped from PIL and uses QT instead (by sendiulo, same license)
import qidenticon import qidenticon
icon_hash = hashlib.md5( icon_hash = hashlib.md5(
addBMIfNotPresent(address) + identiconsuffix).hexdigest() (addBMIfNotPresent(address) + identiconsuffix).encode()).hexdigest()
use_two_colors = identicon_lib[:len('qidenticon_two')] == 'qidenticon_two' use_two_colors = identicon_lib[:len('qidenticon_two')] == 'qidenticon_two'
opacity = int( opacity = int(
identicon_lib not in ( identicon_lib not in (
@ -51,7 +51,7 @@ def identiconize(address):
# filename = './images/identicons/'+hash+'.png' # filename = './images/identicons/'+hash+'.png'
# image.save(filename) # image.save(filename)
idcon = QtGui.QIcon() idcon = QtGui.QIcon()
idcon.addPixmap(image, QtGui.QIcon.Normal, QtGui.QIcon.Off) idcon.addPixmap(image, QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
return idcon return idcon
elif identicon_lib == 'pydenticon': elif identicon_lib == 'pydenticon':
# Here you could load pydenticon.py # Here you could load pydenticon.py
@ -81,7 +81,7 @@ def avatarize(address):
falls back to identiconize(address) falls back to identiconize(address)
""" """
idcon = QtGui.QIcon() idcon = QtGui.QIcon()
icon_hash = hashlib.md5(addBMIfNotPresent(address)).hexdigest() icon_hash = hashlib.md5(addBMIfNotPresent(address).encode()).hexdigest()
if address == str_broadcast_subscribers: if address == str_broadcast_subscribers:
# don't hash [Broadcast subscribers] # don't hash [Broadcast subscribers]
icon_hash = address icon_hash = address

View File

@ -1511,4 +1511,4 @@ class singleWorker(StoppableThread):
payload = self._doPOWDefaults( payload = self._doPOWDefaults(
payload, TTL, log_prefix='(For ack message)', log_time=True) payload, TTL, log_prefix='(For ack message)', log_time=True)
return protocol.CreatePacket('object', payload) return protocol.CreatePacket(b'object', payload)

View File

@ -12,7 +12,7 @@ def start(config, state):
"""Start network threads""" """Start network threads"""
import state import state
from .announcethread import AnnounceThread from .announcethread import AnnounceThread
import network.connectionpool # pylint: disable=relative-import import network.connectionpool as connectionpool # pylint: disable=relative-import
from .addrthread import AddrThread from .addrthread import AddrThread
from .dandelion import Dandelion from .dandelion import Dandelion
from .downloadthread import DownloadThread from .downloadthread import DownloadThread

View File

@ -5,7 +5,7 @@ from six.moves import queue
# magic imports! # magic imports!
import state import state
import network.connectionpool import network.connectionpool as connectionpool
from helper_random import randomshuffle from helper_random import randomshuffle
from protocol import assembleAddrMessage from protocol import assembleAddrMessage
from queues import addrQueue # FIXME: init with queue from queues import addrQueue # FIXME: init with queue

View File

@ -723,20 +723,21 @@ class dispatcher(object):
if why.args[0] not in (ENOTCONN, EBADF): if why.args[0] not in (ENOTCONN, EBADF):
raise raise
# XXX unresolved
# cheap inheritance, used to pass all other attribute # cheap inheritance, used to pass all other attribute
# references to the underlying socket object. # references to the underlying socket object.
def __getattr__(self, attr): #def __getattr__(self, attr):
try: # try:
retattr = getattr(self.socket, attr) # retattr = getattr(self.socket, attr)
except AttributeError: # except AttributeError:
raise AttributeError( # raise AttributeError(
"%s instance has no attribute '%s'" # "%s instance has no attribute '%s'"
% (self.__class__.__name__, attr)) # % (self.__class__.__name__, attr))
else: # else:
msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s"\ # msg = "%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s"\
" instead" % {'me': self.__class__.__name__, 'attr': attr} # " instead" % {'me': self.__class__.__name__, 'attr': attr}
warnings.warn(msg, DeprecationWarning, stacklevel=2) # warnings.warn(msg, DeprecationWarning, stacklevel=2)
return retattr # return retattr
# log and log_info may be overridden to provide more sophisticated # log and log_info may be overridden to provide more sophisticated
# logging and warning methods. In general, log is for 'hit' logging # logging and warning methods. In general, log is for 'hit' logging

View File

@ -12,10 +12,10 @@ import time
# magic imports! # magic imports!
import addresses import addresses
import network.knownnodes import network.knownnodes as knownnodes
import protocol import protocol
import state import state
import network.connectionpool import network.connectionpool as connectionpool
from bmconfigparser import config from bmconfigparser import config
from queues import invQueue, objectProcessorQueue, portCheckerQueue from queues import invQueue, objectProcessorQueue, portCheckerQueue
from randomtrackingdict import RandomTrackingDict from randomtrackingdict import RandomTrackingDict
@ -82,7 +82,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
"""Process incoming header""" """Process incoming header"""
self.magic, self.command, self.payloadLength, self.checksum = \ self.magic, self.command, self.payloadLength, self.checksum = \
protocol.Header.unpack(self.read_buf[:protocol.Header.size]) protocol.Header.unpack(self.read_buf[:protocol.Header.size])
self.command = self.command.rstrip('\x00') self.command = self.command.rstrip(b'\x00')
if self.magic != protocol.magic: if self.magic != protocol.magic:
# skip 1 byte in order to sync # skip 1 byte in order to sync
self.set_state("bm_header", length=1) self.set_state("bm_header", length=1)
@ -107,18 +107,18 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
self.invalid = True self.invalid = True
retval = True retval = True
if not self.fullyEstablished and self.command not in ( if not self.fullyEstablished and self.command not in (
"error", "version", "verack"): b"error", b"version", b"verack"):
logger.error( logger.error(
'Received command %s before connection was fully' 'Received command %s before connection was fully'
' established, ignoring', self.command) ' established, ignoring', self.command.decode())
self.invalid = True self.invalid = True
if not self.invalid: if not self.invalid:
try: try:
retval = getattr( retval = getattr(
self, "bm_command_" + str(self.command).lower())() self, "bm_command_" + self.command.decode().lower())()
except AttributeError: except AttributeError:
# unimplemented command # unimplemented command
logger.debug('unimplemented command %s', self.command) logger.debug('unimplemented command %s', self.command.decode())
except BMProtoInsufficientDataError: except BMProtoInsufficientDataError:
logger.debug('packet length too short, skipping') logger.debug('packet length too short, skipping')
except BMProtoExcessiveDataError: except BMProtoExcessiveDataError:
@ -141,8 +141,8 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
# broken read, ignore # broken read, ignore
pass pass
else: else:
logger.debug('Closing due to invalid command %s', self.command) logger.debug('Closing due to invalid command %s', self.command.decode())
self.close_reason = "Invalid command %s" % self.command self.close_reason = "Invalid command %s" % self.command.decode()
self.set_state("close") self.set_state("close")
return False return False
if retval: if retval:
@ -168,17 +168,17 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
"""Decode node details from the payload""" """Decode node details from the payload"""
# protocol.checkIPAddress() # protocol.checkIPAddress()
services, host, port = self.decode_payload_content("Q16sH") services, host, port = self.decode_payload_content("Q16sH")
if host[0:12] == '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF': if host[0:12] == b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF':
host = socket.inet_ntop(socket.AF_INET, str(host[12:16])) host = socket.inet_ntop(socket.AF_INET, host[12:16])
elif host[0:6] == '\xfd\x87\xd8\x7e\xeb\x43': elif host[0:6] == b'\xfd\x87\xd8\x7e\xeb\x43':
# Onion, based on BMD/bitcoind # Onion, based on BMD/bitcoind
host = base64.b32encode(host[6:]).lower() + ".onion" host = base64.b32encode(host[6:]).lower() + b".onion"
else: else:
host = socket.inet_ntop(socket.AF_INET6, str(host)) host = socket.inet_ntop(socket.AF_INET6, host)
if host == "": if host == b"":
# This can happen on Windows systems which are not 64-bit # This can happen on Windows systems which are not 64-bit
# compatible so let us drop the IPv6 address. # compatible so let us drop the IPv6 address.
host = socket.inet_ntop(socket.AF_INET, str(host[12:16])) host = socket.inet_ntop(socket.AF_INET, host[12:16])
return Node(services, host, port) return Node(services, host, port)
@ -443,13 +443,16 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
"""Incoming addresses, process them""" """Incoming addresses, process them"""
# not using services # not using services
for seenTime, stream, _, ip, port in self._decode_addr(): for seenTime, stream, _, ip, port in self._decode_addr():
ip = str(ip) if (stream not in state.streamsInWhichIAmParticipating):
if (
stream not in state.streamsInWhichIAmParticipating
# FIXME: should check against complete list
or ip.startswith('bootstrap')
):
continue continue
try:
if (
# FIXME: should check against complete list
ip.decode().startswith('bootstrap')
):
continue
except UnicodeDecodeError:
pass
decodedIP = protocol.checkIPAddress(ip) decodedIP = protocol.checkIPAddress(ip)
if ( if (
decodedIP and time.time() - seenTime > 0 decodedIP and time.time() - seenTime > 0
@ -477,7 +480,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
def bm_command_ping(self): def bm_command_ping(self):
"""Incoming ping, respond to it.""" """Incoming ping, respond to it."""
self.append_write_buf(protocol.CreatePacket('pong')) self.append_write_buf(protocol.CreatePacket(b'pong'))
return True return True
@staticmethod @staticmethod
@ -531,12 +534,12 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
if not self.peerValidityChecks(): if not self.peerValidityChecks():
# ABORT afterwards # ABORT afterwards
return True return True
self.append_write_buf(protocol.CreatePacket('verack')) self.append_write_buf(protocol.CreatePacket(b'verack'))
self.verackSent = True self.verackSent = True
ua_valid = re.match( ua_valid = re.match(
r'^/[a-zA-Z]+:[0-9]+\.?[\w\s\(\)\./:;-]*/$', self.userAgent) r'^/[a-zA-Z]+:[0-9]+\.?[\w\s\(\)\./:;-]*/$', self.userAgent.decode())
if not ua_valid: if not ua_valid:
self.userAgent = '/INVALID:0/' self.userAgent = b'/INVALID:0/'
if not self.isOutbound: if not self.isOutbound:
self.append_write_buf(protocol.assembleVersionMessage( self.append_write_buf(protocol.assembleVersionMessage(
self.destination.host, self.destination.port, self.destination.host, self.destination.port,

View File

@ -5,7 +5,7 @@ Select which node to connect to
import logging import logging
import random import random
import network.knownnodes import network.knownnodes as knownnodes
import protocol import protocol
import state import state
from bmconfigparser import config from bmconfigparser import config
@ -45,7 +45,7 @@ def chooseConnection(stream):
return getDiscoveredPeer() return getDiscoveredPeer()
for _ in range(50): for _ in range(50):
peer = random.choice( # nosec B311 peer = random.choice( # nosec B311
knownnodes.knownNodes[stream].keys()) list(knownnodes.knownNodes[stream].keys()))
try: try:
peer_info = knownnodes.knownNodes[stream][peer] peer_info = knownnodes.knownNodes[stream][peer]
if peer_info.get('self'): if peer_info.get('self'):

View File

@ -10,7 +10,7 @@ import time
import network.asyncore_pollchoose as asyncore import network.asyncore_pollchoose as asyncore
import helper_random import helper_random
import network.knownnodes import network.knownnodes as knownnodes
import protocol import protocol
import state import state
from bmconfigparser import config from bmconfigparser import config
@ -382,14 +382,14 @@ class BMConnectionPool(object):
minTx -= 300 - 20 minTx -= 300 - 20
if i.lastTx < minTx: if i.lastTx < minTx:
if i.fullyEstablished: if i.fullyEstablished:
i.append_write_buf(protocol.CreatePacket('ping')) i.append_write_buf(protocol.CreatePacket(b'ping'))
else: else:
i.close_reason = "Timeout (%is)" % ( i.close_reason = "Timeout (%is)" % (
time.time() - i.lastTx) time.time() - i.lastTx)
i.set_state("close") i.set_state("close")
for i in ( for i in (
self.connections() self.connections()
+ self.listeningSockets.values() + self.udpSockets.values() + list(self.listeningSockets.values()) + list(self.udpSockets.values())
): ):
if not (i.accepting or i.connecting or i.connected): if not (i.accepting or i.connecting or i.connected):
reaper.append(i) reaper.append(i)

View File

@ -7,7 +7,7 @@ from random import choice, expovariate, sample
from threading import RLock from threading import RLock
from time import time from time import time
import network.connectionpool import network.connectionpool as connectionpool
import state import state
from queues import invQueue from queues import invQueue

View File

@ -6,7 +6,7 @@ import state
import addresses import addresses
import helper_random import helper_random
import protocol import protocol
import network.connectionpool import network.connectionpool as connectionpool
from .objectracker import missingObjects from .objectracker import missingObjects
from .threads import StoppableThread from .threads import StoppableThread
@ -71,7 +71,7 @@ class DownloadThread(StoppableThread):
if not chunkCount: if not chunkCount:
continue continue
payload[0:0] = addresses.encodeVarint(chunkCount) payload[0:0] = addresses.encodeVarint(chunkCount)
i.append_write_buf(protocol.CreatePacket('getdata', payload)) i.append_write_buf(protocol.CreatePacket(b'getdata', payload))
self.logger.debug( self.logger.debug(
'%s:%i Requesting %i objects', '%s:%i Requesting %i objects',
i.destination.host, i.destination.port, chunkCount) i.destination.host, i.destination.port, chunkCount)

View File

@ -8,7 +8,7 @@ from time import time
import addresses import addresses
import protocol import protocol
import state import state
import network.connectionpool import network.connectionpool as connectionpool
from queues import invQueue from queues import invQueue
from .threads import StoppableThread from .threads import StoppableThread
@ -90,13 +90,13 @@ class InvThread(StoppableThread):
if fluffs: if fluffs:
random.shuffle(fluffs) random.shuffle(fluffs)
connection.append_write_buf(protocol.CreatePacket( connection.append_write_buf(protocol.CreatePacket(
'inv', b'inv',
addresses.encodeVarint( addresses.encodeVarint(
len(fluffs)) + ''.join(fluffs))) len(fluffs)) + ''.join(fluffs)))
if stems: if stems:
random.shuffle(stems) random.shuffle(stems)
connection.append_write_buf(protocol.CreatePacket( connection.append_write_buf(protocol.CreatePacket(
'dinv', b'dinv',
addresses.encodeVarint( addresses.encodeVarint(
len(stems)) + ''.join(stems))) len(stems)) + ''.join(stems)))

View File

@ -3,7 +3,7 @@ A thread to handle network concerns
""" """
import network.asyncore_pollchoose as asyncore import network.asyncore_pollchoose as asyncore
import state import state
import network.connectionpool import network.connectionpool as connectionpool
from queues import excQueue from queues import excQueue
from .threads import StoppableThread from .threads import StoppableThread

View File

@ -5,7 +5,7 @@ import time
from threading import RLock from threading import RLock
import state import state
import network.connectionpool import network.connectionpool as connectionpool
from randomtrackingdict import RandomTrackingDict from randomtrackingdict import RandomTrackingDict
haveBloom = False haveBloom = False

View File

@ -6,7 +6,7 @@ import queue
import socket import socket
import state import state
import network.connectionpool import network.connectionpool as connectionpool
from network.advanceddispatcher import UnknownStateError from network.advanceddispatcher import UnknownStateError
from queues import receiveDataQueue from queues import receiveDataQueue
from .threads import StoppableThread from .threads import StoppableThread

View File

@ -4,7 +4,7 @@ Network statistics
import time import time
import network.asyncore_pollchoose as asyncore import network.asyncore_pollchoose as asyncore
import network.connectionpool import network.connectionpool as connectionpool
from .objectracker import missingObjects from .objectracker import missingObjects

View File

@ -15,14 +15,14 @@ import helper_random
import l10n import l10n
import protocol import protocol
import state import state
import network.connectionpool import network.connectionpool as connectionpool
from bmconfigparser import config from bmconfigparser import config
from highlevelcrypto import randomBytes from highlevelcrypto import randomBytes
from queues import invQueue, receiveDataQueue, UISignalQueue from queues import invQueue, receiveDataQueue, UISignalQueue
from tr import _translate from tr import _translate
import network.asyncore_pollchoose as asyncore import network.asyncore_pollchoose as asyncore
import network.knownnodes import network.knownnodes as knownnodes
from network.advanceddispatcher import AdvancedDispatcher from network.advanceddispatcher import AdvancedDispatcher
from network.bmproto import BMProto from network.bmproto import BMProto
from network.objectracker import ObjectTracker from network.objectracker import ObjectTracker
@ -180,6 +180,15 @@ class TCPConnection(BMProto, TLSDispatcher):
maxAddrCount = config.safeGetInt( maxAddrCount = config.safeGetInt(
"bitmessagesettings", "maxaddrperstreamsend", 500) "bitmessagesettings", "maxaddrperstreamsend", 500)
def endsWith(s, tail):
try:
return s.endswith(tail)
except:
try:
return s.decode().endswith(tail)
except UnicodeDecodeError:
return False
templist = [] templist = []
addrs = {} addrs = {}
for stream in self.streams: for stream in self.streams:
@ -194,7 +203,7 @@ class TCPConnection(BMProto, TLSDispatcher):
(k, v) for k, v in nodes.items() (k, v) for k, v in nodes.items()
if v["lastseen"] > int(time.time()) if v["lastseen"] > int(time.time())
- maximumAgeOfNodesThatIAdvertiseToOthers - maximumAgeOfNodesThatIAdvertiseToOthers
and v["rating"] >= 0 and not k.host.endswith('.onion') and v["rating"] >= 0 and not endsWith(k.host, '.onion')
] ]
# sent 250 only if the remote isn't interested in it # sent 250 only if the remote isn't interested in it
elemCount = min( elemCount = min(
@ -220,7 +229,7 @@ class TCPConnection(BMProto, TLSDispatcher):
'Sending huge inv message with %i objects to just this' 'Sending huge inv message with %i objects to just this'
' one peer', objectCount) ' one peer', objectCount)
self.append_write_buf(protocol.CreatePacket( self.append_write_buf(protocol.CreatePacket(
'inv', addresses.encodeVarint(objectCount) + payload)) b'inv', addresses.encodeVarint(objectCount) + payload))
# Select all hashes for objects in this stream. # Select all hashes for objects in this stream.
bigInvList = {} bigInvList = {}

View File

@ -49,7 +49,7 @@ class UploadThread(StoppableThread):
break break
try: try:
payload.extend(protocol.CreatePacket( payload.extend(protocol.CreatePacket(
'object', state.Inventory[chunk].payload)) b'object', state.Inventory[chunk].payload))
chunk_count += 1 chunk_count += 1
except KeyError: except KeyError:
i.antiIntersectionDelay() i.antiIntersectionDelay()

View File

@ -173,7 +173,7 @@ def checkIPAddress(host, private=False):
return checkIPv4Address(host[12:], hostStandardFormat, private) return checkIPv4Address(host[12:], hostStandardFormat, private)
elif host[0:6] == b'\xfd\x87\xd8\x7e\xeb\x43': elif host[0:6] == b'\xfd\x87\xd8\x7e\xeb\x43':
# Onion, based on BMD/bitcoind # Onion, based on BMD/bitcoind
hostStandardFormat = base64.b32encode(host[6:]).lower() + ".onion" hostStandardFormat = base64.b32encode(host[6:]).lower() + b".onion"
if private: if private:
return False return False
return hostStandardFormat return hostStandardFormat
@ -250,6 +250,8 @@ def haveSSL(server=False):
python < 2.7.9's ssl library does not support ECDSA server due to python < 2.7.9's ssl library does not support ECDSA server due to
missing initialisation of available curves, but client works ok missing initialisation of available curves, but client works ok
""" """
# XXX debug - disable TLS
return False
if not server: if not server:
return True return True
elif sys.version_info >= (2, 7, 9): elif sys.version_info >= (2, 7, 9):

View File

@ -41,12 +41,7 @@ Returns an instance of :class:`QPixmap` which have generated identicon image.
""" """
from six.moves import range from six.moves import range
from PyQt6 import QtCore, QtGui
try:
from PyQt5 import QtCore, QtGui
except (ImportError, RuntimeError):
from PyQt4 import QtCore, QtGui
class IdenticonRendererBase(object): class IdenticonRendererBase(object):
"""Encapsulate methods around rendering identicons""" """Encapsulate methods around rendering identicons"""
@ -129,11 +124,13 @@ class IdenticonRendererBase(object):
QtCore.QPointF(size, size), QtCore.QPointF(0., size)] QtCore.QPointF(size, size), QtCore.QPointF(0., size)]
rotation = [0, 90, 180, 270] rotation = [0, 90, 180, 270]
nopen = QtGui.QPen(foreColor, QtCore.Qt.NoPen) nopen = QtGui.QPen(foreColor)
foreBrush = QtGui.QBrush(foreColor, QtCore.Qt.SolidPattern) nopen.setStyle(QtCore.Qt.PenStyle.NoPen)
foreBrush = QtGui.QBrush(foreColor, QtCore.Qt.BrushStyle.SolidPattern)
if penwidth > 0: if penwidth > 0:
pen_color = QtGui.QColor(255, 255, 255) pen_color = QtGui.QColor(255, 255, 255)
pen = QtGui.QPen(pen_color, QtCore.Qt.SolidPattern) pen = QtGui.QPen(pen_color)
pen.setBrush(QtCore.Qt.BrushStyle.SolidPattern)
pen.setWidth(penwidth) pen.setWidth(penwidth)
painter = QtGui.QPainter() painter = QtGui.QPainter()
@ -153,10 +150,10 @@ class IdenticonRendererBase(object):
if penwidth > 0: if penwidth > 0:
# draw the borders # draw the borders
painter.setPen(pen) painter.setPen(pen)
painter.drawPolygon(polygon, QtCore.Qt.WindingFill) painter.drawPolygon(polygon, QtCore.Qt.FillRule.WindingFill)
# draw the fill # draw the fill
painter.setPen(nopen) painter.setPen(nopen)
painter.drawPolygon(polygon, QtCore.Qt.WindingFill) painter.drawPolygon(polygon, QtCore.Qt.FillRule.WindingFill)
painter.end() painter.end()

View File

@ -23,7 +23,7 @@ def doCleanShutdown():
objectProcessorQueue.put(('checkShutdownVariable', 'no data')) objectProcessorQueue.put(('checkShutdownVariable', 'no data'))
for thread in threading.enumerate(): for thread in threading.enumerate():
if thread.isAlive() and isinstance(thread, StoppableThread): if thread.is_alive() and isinstance(thread, StoppableThread):
thread.stopThread() thread.stopThread()
UISignalQueue.put(( UISignalQueue.put((

View File

@ -33,7 +33,7 @@ class SqliteInventory(InventoryStorage):
return True return True
rows = sqlQuery( rows = sqlQuery(
'SELECT streamnumber FROM inventory WHERE hash=?', 'SELECT streamnumber FROM inventory WHERE hash=?',
sqlite3.Binary(hash_)) sqlite3.Binary(hash_.encode()))
if not rows: if not rows:
return False return False
self._objects[hash_] = rows[0][0] self._objects[hash_] = rows[0][0]
@ -44,8 +44,8 @@ class SqliteInventory(InventoryStorage):
if hash_ in self._inventory: if hash_ in self._inventory:
return self._inventory[hash_] return self._inventory[hash_]
rows = sqlQuery( rows = sqlQuery(
'SELECT objecttype, streamnumber, payload, expirestime, tag' b'SELECT objecttype, streamnumber, payload, expirestime, tag'
' FROM inventory WHERE hash=?', sqlite3.Binary(hash_)) b' FROM inventory WHERE hash=?', sqlite3.Binary(hash_.encode()))
if not rows: if not rows:
raise KeyError(hash_) raise KeyError(hash_)
return InventoryItem(*rows[0]) return InventoryItem(*rows[0])

View File

@ -28,7 +28,7 @@ class translateClass:
return self.text return self.text
def _translate(context, text, disambiguation=None, encoding=None, n=None): def _translate(context, text, disambiguation=None, n=None):
# pylint: disable=unused-argument # pylint: disable=unused-argument
return translateText(context, text, n) return translateText(context, text, n)
@ -52,7 +52,7 @@ def translateText(context, text, n=None):
os._exit(0) # pylint: disable=protected-access os._exit(0) # pylint: disable=protected-access
if n is None: if n is None:
return QtWidgets.QApplication.translate(context, text) return QtWidgets.QApplication.translate(context, text)
return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, n) return QtWidgets.QApplication.translate(context, text, None, n)
else: else:
if '%' in text: if '%' in text:
return translateClass(context, text.replace('%', '', 1)) return translateClass(context, text.replace('%', '', 1))