Revert "fix complains from flake8; part 2"

This reverts commit bcf02ff9bb.
This commit is contained in:
Kashiko Koibumi 2024-05-17 11:51:03 +09:00
parent 416463f8b7
commit 1077548eb6
No known key found for this signature in database
GPG Key ID: 8F06E069E37C40C4
14 changed files with 108 additions and 136 deletions

View File

@ -1,2 +1,2 @@
#!/bin/sh #!/bin/sh
autopep8 --in-place --recursive --max-line-length=119 src src/bitmessageqt autopep8 --in-place --recursive src src/bitmessageqt

View File

@ -1,2 +0,0 @@
#!/bin/sh
flake8 --max-line-length=119 --config=setup.cfg src/*.py src/network/*.py src/storage/*.py src/bitmessageqt/*.py

View File

@ -16,8 +16,8 @@ from datetime import datetime, timedelta
from sqlite3 import register_adapter from sqlite3 import register_adapter
from PyQt6 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtWidgets import QMessageBox
from PyQt6.QtNetwork import QLocalSocket, QLocalServer from PyQt6.QtNetwork import QLocalSocket, QLocalServer
import shared import shared
import state import state
from debug import logger from debug import logger
@ -613,11 +613,9 @@ class MyForm(settingsmixin.SMainWindow):
"One of your addresses, {0}, 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?").format(addressInKeysFile) "May we delete it now?").format(addressInKeysFile)
reply = QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, 'Message', displayMsg, self, 'Message', displayMsg, QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No)
QMessageBox.StandardButton.Yes, if reply == QtWidgets.QMessageBox.StandardButton.Yes:
QMessageBox.StandardButton.No)
if reply == QMessageBox.StandardButton.Yes:
config.remove_section(addressInKeysFile) config.remove_section(addressInKeysFile)
config.save() config.save()
@ -1504,11 +1502,11 @@ class MyForm(settingsmixin.SMainWindow):
def click_actionManageKeys(self): def click_actionManageKeys(self):
if 'darwin' in sys.platform or 'linux' in sys.platform: if 'darwin' in sys.platform or 'linux' in sys.platform:
if state.appdata == '': if state.appdata == '':
# reply = QMessageBox.information(self, 'keys.dat?','You # reply = QtWidgets.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.StandardButton.Ok) # back up this file.', QMessageBox.StandardButton.Ok)
reply = QMessageBox.information( reply = QtWidgets.QMessageBox.information(
self, self,
'keys.dat?', 'keys.dat?',
_translate( _translate(
@ -1516,10 +1514,10 @@ 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."
), ),
QMessageBox.StandardButton.Ok) QtWidgets.QMessageBox.StandardButton.Ok)
else: else:
QMessageBox.information( QtWidgets.QMessageBox.information(
self, self,
'keys.dat?', 'keys.dat?',
_translate( _translate(
@ -1528,10 +1526,10 @@ class MyForm(settingsmixin.SMainWindow):
"\n {0} \n" "\n {0} \n"
"It is important that you back up this file." "It is important that you back up this file."
).format(state.appdata), ).format(state.appdata),
QMessageBox.StandardButton.Ok) QtWidgets.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 = QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, self,
_translate("MainWindow", "Open keys.dat?"), _translate("MainWindow", "Open keys.dat?"),
_translate( _translate(
@ -1540,10 +1538,10 @@ 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.)"),
QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.Yes,
QMessageBox.StandardButton.No) QtWidgets.QMessageBox.StandardButton.No)
else: else:
reply = QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, self,
_translate("MainWindow", "Open keys.dat?"), _translate("MainWindow", "Open keys.dat?"),
_translate( _translate(
@ -1551,18 +1549,18 @@ class MyForm(settingsmixin.SMainWindow):
"You may manage your keys by editing the keys.dat file stored in\n {0} \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.)").format(state.appdata), "(Be sure to close Bitmessage before making any changes.)").format(state.appdata),
QMessageBox.StandardButton.Yes, QMessageBox.StandardButton.No) QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No)
if reply == QMessageBox.StandardButton.Yes: if reply == QtWidgets.QMessageBox.StandardButton.Yes:
openKeysFile() openKeysFile()
# menu button 'delete all treshed messages' # menu button 'delete all treshed messages'
def click_actionDeleteAllTrashedMessages(self): def click_actionDeleteAllTrashedMessages(self):
if QMessageBox.question( if QtWidgets.QMessageBox.question(
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?"),
QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.Yes,
QMessageBox.StandardButton.No) == QMessageBox.StandardButton.No: QtWidgets.QMessageBox.StandardButton.No) == QtWidgets.QMessageBox.StandardButton.No:
return return
sqlStoredProcedure('deleteandvacuume') sqlStoredProcedure('deleteandvacuume')
self.rerenderTabTreeMessages() self.rerenderTabTreeMessages()
@ -1589,7 +1587,7 @@ class MyForm(settingsmixin.SMainWindow):
dialog = dialogs.RegenerateAddressesDialog(self) dialog = dialogs.RegenerateAddressesDialog(self)
if dialog.exec(): if dialog.exec():
if dialog.lineEditPassphrase.text() == "": if dialog.lineEditPassphrase.text() == "":
QMessageBox.about( QtWidgets.QMessageBox.about(
self, _translate("MainWindow", "bad passphrase"), self, _translate("MainWindow", "bad passphrase"),
_translate( _translate(
"MainWindow", "MainWindow",
@ -1602,7 +1600,7 @@ class MyForm(settingsmixin.SMainWindow):
addressVersionNumber = int( addressVersionNumber = int(
dialog.lineEditAddressVersionNumber.text()) dialog.lineEditAddressVersionNumber.text())
except: except:
QMessageBox.about( QtWidgets.QMessageBox.about(
self, self,
_translate("MainWindow", "Bad address version number"), _translate("MainWindow", "Bad address version number"),
_translate( _translate(
@ -1612,7 +1610,7 @@ class MyForm(settingsmixin.SMainWindow):
)) ))
return return
if addressVersionNumber < 3 or addressVersionNumber > 4: if addressVersionNumber < 3 or addressVersionNumber > 4:
QMessageBox.about( QtWidgets.QMessageBox.about(
self, self,
_translate("MainWindow", "Bad address version number"), _translate("MainWindow", "Bad address version number"),
_translate( _translate(
@ -1668,7 +1666,7 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.blackwhitelist.init_blacklist_popup_menu(False) self.ui.blackwhitelist.init_blacklist_popup_menu(False)
if event.type() == QtCore.QEvent.Type.WindowStateChange: if event.type() == QtCore.QEvent.Type.WindowStateChange:
if self.windowState() & QtCore.Qt.WindowState.WindowMinimized: if self.windowState() & QtCore.Qt.WindowState.WindowMinimized:
if config.getboolean('bitmessagesettings', 'minimizetotray') and 'darwin' not 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)
elif event.oldState() & QtCore.Qt.WindowState.WindowMinimized: elif event.oldState() & QtCore.Qt.WindowState.WindowMinimized:
# The window state has just been changed to # The window state has just been changed to
@ -1901,7 +1899,7 @@ class MyForm(settingsmixin.SMainWindow):
def displayAlert(self, title, text, exitAfterUserClicksOk): def displayAlert(self, title, text, exitAfterUserClicksOk):
self.updateStatusBar(text) self.updateStatusBar(text)
QMessageBox.critical(self, title, text, QMessageBox.StandardButton.Ok) QtWidgets.QMessageBox.critical(self, title, text, QtWidgets.QMessageBox.StandardButton.Ok)
if exitAfterUserClicksOk: if exitAfterUserClicksOk:
os._exit(0) os._exit(0)
@ -1977,7 +1975,7 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderTabTreeSubscriptions() self.rerenderTabTreeSubscriptions()
def click_pushButtonTTL(self): def click_pushButtonTTL(self):
QMessageBox.information( QtWidgets.QMessageBox.information(
self, self,
'Time To Live', 'Time To Live',
_translate( _translate(
@ -1986,7 +1984,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."""),
QMessageBox.StandardButton.Ok) QtWidgets.QMessageBox.StandardButton.Ok)
def click_pushButtonClear(self): def click_pushButtonClear(self):
self.ui.lineEditSubject.setText("") self.ui.lineEditSubject.setText("")
@ -1999,9 +1997,7 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.textEditMessageBroadcast.clear() self.ui.textEditMessageBroadcast.clear()
def click_pushButtonSend(self): def click_pushButtonSend(self):
encoding = 2 encoding = 3 if QtWidgets.QApplication.queryKeyboardModifiers() & QtCore.Qt.KeyboardModifier.ShiftModifier else 2
if QtWidgets.QApplication.queryKeyboardModifiers() & QtCore.Qt.KeyboardModifier.ShiftModifier:
encoding = 3
self.statusbar.clearMessage() self.statusbar.clearMessage()
@ -2031,7 +2027,7 @@ class MyForm(settingsmixin.SMainWindow):
users can send messages of any length. users can send messages of any length.
""" """
if len(message) > (2 ** 18 - 500): if len(message) > (2 ** 18 - 500):
QMessageBox.about( QtWidgets.QMessageBox.about(
self, _translate("MainWindow", "Message too long"), self, _translate("MainWindow", "Message too long"),
_translate( _translate(
"MainWindow", "MainWindow",
@ -2063,15 +2059,14 @@ class MyForm(settingsmixin.SMainWindow):
subject = acct.subject subject = acct.subject
toAddress = acct.toAddress toAddress = acct.toAddress
else: else:
if QMessageBox.question( if QtWidgets.QMessageBox.question(
self, self,
"Sending an email?", "Sending an email?",
_translate( _translate(
"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?"),
QMessageBox.StandardButton.Yes QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No) != QtWidgets.QMessageBox.StandardButton.Yes:
| QMessageBox.StandardButton.No) != 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
@ -2168,7 +2163,7 @@ class MyForm(settingsmixin.SMainWindow):
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
if addressVersionNumber > 4 or addressVersionNumber <= 1: if addressVersionNumber > 4 or addressVersionNumber <= 1:
QMessageBox.about( QtWidgets.QMessageBox.about(
self, self,
_translate("MainWindow", "Address version number"), _translate("MainWindow", "Address version number"),
_translate( _translate(
@ -2178,7 +2173,7 @@ class MyForm(settingsmixin.SMainWindow):
).format(toAddress, str(addressVersionNumber))) ).format(toAddress, str(addressVersionNumber)))
continue continue
if streamNumber > 1 or streamNumber == 0: if streamNumber > 1 or streamNumber == 0:
QMessageBox.about( QtWidgets.QMessageBox.about(
self, self,
_translate("MainWindow", "Stream number"), _translate("MainWindow", "Stream number"),
_translate( _translate(
@ -2587,13 +2582,13 @@ class MyForm(settingsmixin.SMainWindow):
self.ui.textEditMessage.setFocus() self.ui.textEditMessage.setFocus()
def on_action_MarkAllRead(self): def on_action_MarkAllRead(self):
if QMessageBox.question( if QtWidgets.QMessageBox.question(
self, "Marking all messages as read?", self, "Marking all messages as read?",
_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?"
), QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No ), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
) != QMessageBox.StandardButton.Yes: ) != QtWidgets.QMessageBox.StandardButton.Yes:
return return
tableWidget = self.getCurrentMessagelist() tableWidget = self.getCurrentMessagelist()
@ -2604,7 +2599,7 @@ class MyForm(settingsmixin.SMainWindow):
msgids = [] msgids = []
for i in range(0, idCount): for i in range(0, idCount):
msgids.append(tableWidget.item(i, 3).data()) msgids.append(tableWidget.item(i, 3).data())
for col in range(tableWidget.columnCount()): for col in xrange(tableWidget.columnCount()):
tableWidget.item(i, col).setUnread(False) tableWidget.item(i, col).setUnread(False)
markread = sqlExecuteChunked( markread = sqlExecuteChunked(
@ -2621,7 +2616,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 = 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(
@ -2630,9 +2625,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?"
), QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.Cancel, ), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.Cancel,
QMessageBox.StandardButton.Cancel) QtWidgets.QMessageBox.StandardButton.Cancel)
if reply != QMessageBox.StandardButton.Yes: if reply != QtWidgets.QMessageBox.StandardButton.Yes:
return return
config.set( config.set(
'bitmessagesettings', 'dontconnect', str(dontconnect_option)) 'bitmessagesettings', 'dontconnect', str(dontconnect_option))
@ -2659,7 +2654,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 = QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Proof of work pending"), self, _translate("MainWindow", "Proof of work pending"),
_translate( _translate(
"MainWindow", "MainWindow",
@ -2673,15 +2668,15 @@ class MyForm(settingsmixin.SMainWindow):
) + "\n\n" ) + "\n\n"
+ _translate( + _translate(
"MainWindow", "Wait until these tasks finish?"), "MainWindow", "Wait until these tasks finish?"),
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
| QMessageBox.StandardButton.Cancel, QMessageBox.StandardButton.Cancel) | QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel)
if reply == QMessageBox.StandardButton.No: if reply == QtWidgets.QMessageBox.StandardButton.No:
waitForPow = False waitForPow = False
elif reply == QMessageBox.StandardButton.Cancel: elif reply == QtWidgets.QMessageBox.StandardButton.Cancel:
return return
if pendingDownload() > 0: if pendingDownload() > 0:
reply = QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Synchronisation pending"), self, _translate("MainWindow", "Synchronisation pending"),
_translate( _translate(
"MainWindow", "MainWindow",
@ -2691,16 +2686,16 @@ class MyForm(settingsmixin.SMainWindow):
" synchronisation finishes?", None, " synchronisation finishes?", None,
pendingDownload() pendingDownload()
), ),
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
| QMessageBox.StandardButton.Cancel, QMessageBox.StandardButton.Cancel) | QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel)
if reply == QMessageBox.StandardButton.Yes: if reply == QtWidgets.QMessageBox.StandardButton.Yes:
self.wait = waitForSync = True self.wait = waitForSync = True
elif reply == QMessageBox.StandardButton.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 = QMessageBox.question( reply = QtWidgets.QMessageBox.question(
self, _translate("MainWindow", "Not connected"), self, _translate("MainWindow", "Not connected"),
_translate( _translate(
"MainWindow", "MainWindow",
@ -2708,12 +2703,12 @@ 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?"
), ),
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
| QMessageBox.StandardButton.Cancel, QMessageBox.StandardButton.Cancel) | QtWidgets.QMessageBox.StandardButton.Cancel, QtWidgets.QMessageBox.StandardButton.Cancel)
if reply == QMessageBox.StandardButton.Yes: if reply == QtWidgets.QMessageBox.StandardButton.Yes:
waitForConnection = True waitForConnection = True
self.wait = waitForSync = True self.wait = waitForSync = True
elif reply == QMessageBox.StandardButton.Cancel: elif reply == QtWidgets.QMessageBox.StandardButton.Cancel:
return return
self.quitAccepted = True self.quitAccepted = True
@ -2855,7 +2850,7 @@ class MyForm(settingsmixin.SMainWindow):
lines = messageText.split('\n') lines = messageText.split('\n')
totalLines = len(lines) totalLines = len(lines)
for i in range(totalLines): for i in xrange(totalLines):
if 'Message ostensibly from ' in lines[i]: if 'Message ostensibly from ' in lines[i]:
lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % ( lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % (
lines[i]) lines[i])
@ -2921,8 +2916,7 @@ class MyForm(settingsmixin.SMainWindow):
# Wrap and quote lines/paragraphs new to this message. # Wrap and quote lines/paragraphs new to this message.
else: else:
return quoteWrapper.fill(line) return quoteWrapper.fill(line)
return '\n'.join( return '\n'.join([quote_line(l) for l in message.splitlines()]) + '\n\n'
[quote_line(line) for line in message.splitlines()]) + '\n\n'
def setSendFromComboBox(self, address=None): def setSendFromComboBox(self, address=None):
if address is None: if address is None:
@ -2992,23 +2986,23 @@ class MyForm(settingsmixin.SMainWindow):
) )
# toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow # toAddressAtCurrentInboxRow = fromAddressAtCurrentInboxRow
elif not config.has_section(toAddressAtCurrentInboxRow): elif not config.has_section(toAddressAtCurrentInboxRow):
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 {0}. Perhaps you" "Bitmessage cannot find your address {0}. Perhaps you"
" removed it?" " removed it?"
).format(toAddressAtCurrentInboxRow), QMessageBox.StandardButton.Ok) ).format(toAddressAtCurrentInboxRow), QtWidgets.QMessageBox.StandardButton.Ok)
elif not config.getboolean( elif not config.getboolean(
toAddressAtCurrentInboxRow, 'enabled'): toAddressAtCurrentInboxRow, 'enabled'):
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."
), QMessageBox.StandardButton.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(
@ -3154,8 +3148,8 @@ class MyForm(settingsmixin.SMainWindow):
idCount = len(inventoryHashesToTrash) idCount = len(inventoryHashesToTrash)
sqlExecuteChunked( sqlExecuteChunked(
("DELETE FROM inbox" if folder == "trash" or shifted else ("DELETE FROM inbox" if folder == "trash" or shifted else
"UPDATE inbox SET folder='trash', read=1") "UPDATE inbox SET folder='trash', read=1") +
+ " WHERE msgid IN ({0})", idCount, *inventoryHashesToTrash) " WHERE msgid IN ({0})", idCount, *inventoryHashesToTrash)
tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1) tableWidget.selectRow(0 if currentRow == 0 else currentRow - 1)
tableWidget.setUpdatesEnabled(True) tableWidget.setUpdatesEnabled(True)
self.propagateUnreadCount(folder) self.propagateUnreadCount(folder)
@ -3362,7 +3356,7 @@ class MyForm(settingsmixin.SMainWindow):
self.click_pushButtonAddSubscription() self.click_pushButtonAddSubscription()
def on_action_SubscriptionsDelete(self): def on_action_SubscriptionsDelete(self):
if QMessageBox.question( if QtWidgets.QMessageBox.question(
self, "Delete subscription?", self, "Delete subscription?",
_translate( _translate(
"MainWindow", "MainWindow",
@ -3373,8 +3367,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?"
), QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No ), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
) != QMessageBox.StandardButton.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=?''',
@ -3597,7 +3591,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 QMessageBox.question( if QtWidgets.QMessageBox.question(
self, "Delete channel?", self, "Delete channel?",
_translate( _translate(
"MainWindow", "MainWindow",
@ -3608,8 +3602,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?"
), QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No ), QtWidgets.QMessageBox.StandardButton.Yes | QtWidgets.QMessageBox.StandardButton.No
) == QMessageBox.StandardButton.Yes: ) == QtWidgets.QMessageBox.StandardButton.Yes:
config.remove_section(str(account.address)) config.remove_section(str(account.address))
else: else:
return return
@ -3745,11 +3739,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 = QMessageBox.question( overwrite = QtWidgets.QMessageBox.question(
self, 'Message', displayMsg, self, 'Message', displayMsg,
QMessageBox.StandardButton.Yes, QMessageBox.StandardButton.No) QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No)
else: else:
overwrite = QMessageBox.StandardButton.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):
@ -3757,15 +3751,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 = QMessageBox.question( overwrite = QtWidgets.QMessageBox.question(
self, 'Message', displayMsg, self, 'Message', displayMsg,
QMessageBox.StandardButton.Yes, QMessageBox.StandardButton.No) QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No)
else: else:
overwrite = QMessageBox.StandardButton.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 == QMessageBox.StandardButton.Yes): if (not exists) | (overwrite == QtWidgets.QMessageBox.StandardButton.Yes):
if overwrite == QMessageBox.StandardButton.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)
@ -3815,15 +3809,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 = 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?"),
QMessageBox.StandardButton.Yes, QMessageBox.StandardButton.No QtWidgets.QMessageBox.StandardButton.Yes, QtWidgets.QMessageBox.StandardButton.No
) == QMessageBox.StandardButton.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

View File

@ -5,7 +5,7 @@ Dialogs that work with BM address.
import hashlib import hashlib
from PyQt6 import QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
import queues import queues
import bitmessageqt.widgets as widgets import bitmessageqt.widgets as widgets

View File

@ -608,41 +608,22 @@ class Ui_MainWindow(object):
self.label_3.setText(_translate("MainWindow", "Subject:")) self.label_3.setText(_translate("MainWindow", "Subject:"))
self.label_2.setText(_translate("MainWindow", "From:")) self.label_2.setText(_translate("MainWindow", "From:"))
self.label.setText(_translate("MainWindow", "To:")) self.label.setText(_translate("MainWindow", "To:"))
self.textEditMessage.setHtml( self.textEditMessage.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "p, li { white-space: pre-wrap; }\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" />" "</style></head><body style=\" font-family:\'Droid Sans\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<style type=\"text/css\">\n" "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'MS Shell Dlg 2\';\"><br /></p></body></html>"))
"p, li { white-space: pre-wrap; }\n" self.tabWidgetSend.setTabText(self.tabWidgetSend.indexOf(self.sendDirect),
"</style></head><body style=" _translate("MainWindow", "Send ordinary Message"))
"\" font-family:\'Droid Sans\'; font-size:9pt;"
" font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px;"
" margin-bottom:0px; margin-left:0px; margin-right:0px;"
" -qt-block-indent:0; text-indent:0px; font-family:"
"\'MS Shell Dlg 2\';\"><br /></p></body></html>"))
self.tabWidgetSend.setTabText(
self.tabWidgetSend.indexOf(self.sendDirect),
_translate("MainWindow", "Send ordinary Message"))
self.label_8.setText(_translate("MainWindow", "From:")) self.label_8.setText(_translate("MainWindow", "From:"))
self.label_7.setText(_translate("MainWindow", "Subject:")) self.label_7.setText(_translate("MainWindow", "Subject:"))
self.textEditMessageBroadcast.setHtml( self.textEditMessageBroadcast.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/" "p, li { white-space: pre-wrap; }\n"
"strict.dtd\">\n" "</style></head><body style=\" font-family:\'Droid Sans\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" />" "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:\'MS Shell Dlg 2\';\"><br /></p></body></html>"))
"<style type=\"text/css\">\n" self.tabWidgetSend.setTabText(self.tabWidgetSend.indexOf(self.sendBroadcast),
"p, li { white-space: pre-wrap; }\n" _translate("MainWindow", "Send Message to your Subscribers"))
"</style></head><body style=\" font-family:"
"\'Droid Sans\'; font-size:9pt; font-weight:400;"
" font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px;"
" margin-bottom:0px; margin-left:0px; margin-right:0px;"
" -qt-block-indent:0; text-indent:0px; font-family:"
"\'MS Shell Dlg 2\';\"><br /></p></body></html>"))
self.tabWidgetSend.setTabText(
self.tabWidgetSend.indexOf(self.sendBroadcast),
_translate("MainWindow", "Send Message to your Subscribers"))
self.pushButtonTTL.setText(_translate("MainWindow", "TTL:")) self.pushButtonTTL.setText(_translate("MainWindow", "TTL:"))
self.pushButtonClear.setText(_translate("MainWindow", "Clear")) self.pushButtonClear.setText(_translate("MainWindow", "Clear"))
self.pushButtonSend.setText(_translate("MainWindow", "Send")) self.pushButtonSend.setText(_translate("MainWindow", "Send"))

View File

@ -2,7 +2,7 @@
Custom dialog classes Custom dialog classes
""" """
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
from PyQt6 import QtWidgets from PyQt6 import QtGui, QtWidgets
import paths import paths
import bitmessageqt.widgets as widgets import bitmessageqt.widgets as widgets

View File

@ -3,7 +3,7 @@
import glob import glob
import os import os
from PyQt6 import QtCore, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
import paths import paths
from bmconfigparser import config from bmconfigparser import config

View File

@ -38,9 +38,7 @@ class MessageView(QtWidgets.QTextBrowser):
def mousePressEvent(self, event): def mousePressEvent(self, event):
"""Mouse press button event handler""" """Mouse press button event handler"""
b = event.button() if event.button() == QtCore.Qt.MouseButton.LeftButton and self.html and self.html.has_html and self.cursorForPosition(
lb = QtCore.Qt.MouseButton.LeftButton
if b == lb and self.html and self.html.has_html and self.cursorForPosition(
event.pos()).block().blockNumber() == 0: event.pos()).block().blockNumber() == 0:
if self.mode == MessageView.MODE_PLAIN: if self.mode == MessageView.MODE_PLAIN:
self.showHTML() self.showHTML()

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
from PyQt6 import QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
class MigrationWizardIntroPage(QtWidgets.QWizardPage): class MigrationWizardIntroPage(QtWidgets.QWizardPage):
@ -8,8 +8,7 @@ class MigrationWizardIntroPage(QtWidgets.QWizardPage):
self.setTitle("Migrating configuration") self.setTitle("Migrating configuration")
label = QtGui.QLabel("This wizard will help you to migrate your configuration. " label = QtGui.QLabel("This wizard will help you to migrate your configuration. "
"You can still keep using PyBitMessage" "You can still keep using PyBitMessage once you migrate, the changes are backwards compatible.")
" once you migrate, the changes are backwards compatible.")
label.setWordWrap(True) label.setWordWrap(True)
layout = QtGui.QVBoxLayout() layout = QtGui.QVBoxLayout()

View File

@ -4,12 +4,11 @@ src/bitmessageqt/newchandialog.py
""" """
from PyQt6 import QtCore, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
import bitmessageqt.widgets as widgets import bitmessageqt.widgets as widgets
from addresses import addBMIfNotPresent from addresses import addBMIfNotPresent
# XXX unresolved from .addressvalidator import AddressValidator, PassPhraseValidator
# from .addressvalidator import AddressValidator, PassPhraseValidator
from queues import ( from queues import (
addressGeneratorQueue, apiAddressGeneratorReturnQueue, UISignalQueue) addressGeneratorQueue, apiAddressGeneratorReturnQueue, UISignalQueue)
from tr import _translate from tr import _translate

View File

@ -1,4 +1,6 @@
from PyQt6 import QtWidgets from os import path
from PyQt6 import QtGui, QtWidgets
from debug import logger
import bitmessageqt.widgets as widgets import bitmessageqt.widgets as widgets

View File

@ -5,7 +5,7 @@ src/settingsmixin.py
""" """
from PyQt6 import QtCore, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
class SettingsMixin(object): class SettingsMixin(object):

View File

@ -2,7 +2,7 @@
"""Status bar Module""" """Status bar Module"""
from time import time from time import time
from PyQt6 import QtWidgets from PyQt6 import QtGui, QtWidgets
class BMStatusBar(QtWidgets.QStatusBar): class BMStatusBar(QtWidgets.QStatusBar):

View File

@ -1,6 +1,7 @@
from PyQt6 import uic from PyQt6 import uic
import os.path import os.path
import paths import paths
import sys
def resource_path(resFile): def resource_path(resFile):