flake8 for bitmessageqt.MyForm.quit()
This commit is contained in:
parent
44f5e03774
commit
4383b49be8
|
@ -2708,14 +2708,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
# Quit selected from menu or application indicator
|
# Quit selected from menu or application indicator
|
||||||
def quit(self):
|
def quit(self):
|
||||||
'''quit_msg = "Are you sure you want to exit Bitmessage?"
|
"""Quit the bitmessageqt application"""
|
||||||
reply = QtGui.QMessageBox.question(self, 'Message',
|
|
||||||
quit_msg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
|
||||||
|
|
||||||
if reply is QtGui.QMessageBox.No:
|
|
||||||
return
|
|
||||||
'''
|
|
||||||
|
|
||||||
if self.quitAccepted:
|
if self.quitAccepted:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -2729,20 +2722,44 @@ 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(self, _translate("MainWindow", "Proof of work pending"),
|
reply = QtGui.QMessageBox.question(
|
||||||
_translate("MainWindow", "%n object(s) pending proof of work", None, QtCore.QCoreApplication.CodecForTr, powQueueSize()) + ", " +
|
self, _translate("MainWindow", "Proof of work pending"),
|
||||||
_translate("MainWindow", "%n object(s) waiting to be distributed", None, QtCore.QCoreApplication.CodecForTr, pendingUpload()) + "\n\n" +
|
_translate(
|
||||||
_translate("MainWindow", "Wait until these tasks finish?"),
|
"MainWindow",
|
||||||
QtGui.QMessageBox.Yes|QtGui.QMessageBox.No|QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel)
|
"%n object(s) pending proof of work", None,
|
||||||
|
QtCore.QCoreApplication.CodecForTr, powQueueSize()
|
||||||
|
) + ", " +
|
||||||
|
_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"%n object(s) waiting to be distributed", None,
|
||||||
|
QtCore.QCoreApplication.CodecForTr, pendingUpload()
|
||||||
|
) + "\n\n" +
|
||||||
|
_translate(
|
||||||
|
"MainWindow", "Wait until these tasks finish?"),
|
||||||
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
|
||||||
|
QtGui.QMessageBox.Cancel,
|
||||||
|
QtGui.QMessageBox.Cancel
|
||||||
|
)
|
||||||
if reply == QtGui.QMessageBox.No:
|
if reply == QtGui.QMessageBox.No:
|
||||||
waitForPow = False
|
waitForPow = False
|
||||||
elif reply == QtGui.QMessageBox.Cancel:
|
elif reply == QtGui.QMessageBox.Cancel:
|
||||||
return
|
return
|
||||||
|
|
||||||
if pendingDownload() > 0:
|
if pendingDownload() > 0:
|
||||||
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Synchronisation pending"),
|
reply = QtGui.QMessageBox.question(
|
||||||
_translate("MainWindow", "Bitmessage hasn't synchronised with the network, %n object(s) to be downloaded. If you quit now, it may cause delivery delays. Wait until the synchronisation finishes?", None, QtCore.QCoreApplication.CodecForTr, pendingDownload()),
|
self, _translate("MainWindow", "Synchronisation pending"),
|
||||||
QtGui.QMessageBox.Yes|QtGui.QMessageBox.No|QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel)
|
_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"Bitmessage hasn't synchronised with the network,"
|
||||||
|
" %n object(s) to be downloaded. If you quit now,"
|
||||||
|
" it may cause delivery delays. Wait until the"
|
||||||
|
" synchronisation finishes?", None,
|
||||||
|
QtCore.QCoreApplication.CodecForTr, pendingDownload()
|
||||||
|
),
|
||||||
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
|
||||||
|
QtGui.QMessageBox.Cancel,
|
||||||
|
QtGui.QMessageBox.Cancel
|
||||||
|
)
|
||||||
if reply == QtGui.QMessageBox.Yes:
|
if reply == QtGui.QMessageBox.Yes:
|
||||||
waitForSync = True
|
waitForSync = True
|
||||||
elif reply == QtGui.QMessageBox.Cancel:
|
elif reply == QtGui.QMessageBox.Cancel:
|
||||||
|
@ -2750,9 +2767,18 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
|
|
||||||
if shared.statusIconColor == 'red' and not BMConfigParser().safeGetBoolean(
|
if shared.statusIconColor == 'red' and not BMConfigParser().safeGetBoolean(
|
||||||
'bitmessagesettings', 'dontconnect'):
|
'bitmessagesettings', 'dontconnect'):
|
||||||
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Not connected"),
|
reply = QtGui.QMessageBox.question(
|
||||||
_translate("MainWindow", "Bitmessage isn't connected to the network. If you quit now, it may cause delivery delays. Wait until connected and the synchronisation finishes?"),
|
self, _translate("MainWindow", "Not connected"),
|
||||||
QtGui.QMessageBox.Yes|QtGui.QMessageBox.No|QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel)
|
_translate(
|
||||||
|
"MainWindow",
|
||||||
|
"Bitmessage isn't connected to the network. If you"
|
||||||
|
" quit now, it may cause delivery delays. Wait until"
|
||||||
|
" connected and the synchronisation finishes?"
|
||||||
|
),
|
||||||
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
|
||||||
|
QtGui.QMessageBox.Cancel,
|
||||||
|
QtGui.QMessageBox.Cancel
|
||||||
|
)
|
||||||
if reply == QtGui.QMessageBox.Yes:
|
if reply == QtGui.QMessageBox.Yes:
|
||||||
waitForConnection = True
|
waitForConnection = True
|
||||||
waitForSync = True
|
waitForSync = True
|
||||||
|
@ -2773,7 +2799,9 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
QtCore.QEventLoop.AllEvents, 1000
|
QtCore.QEventLoop.AllEvents, 1000
|
||||||
)
|
)
|
||||||
|
|
||||||
# this probably will not work correctly, because there is a delay between the status icon turning red and inventory exchange, but it's better than nothing.
|
# this probably will not work correctly, because there is a delay
|
||||||
|
# between the status icon turning red and inventory exchange,
|
||||||
|
# but it's better than nothing.
|
||||||
if waitForSync:
|
if waitForSync:
|
||||||
self.updateStatusBar(_translate(
|
self.updateStatusBar(_translate(
|
||||||
"MainWindow", "Waiting for finishing synchronisation..."))
|
"MainWindow", "Waiting for finishing synchronisation..."))
|
||||||
|
@ -2795,9 +2823,8 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
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... %1%"
|
||||||
).arg(50 * (maxWorkerQueue - curWorkerQueue)
|
).arg(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.AllEvents, 1000
|
||||||
|
@ -2825,8 +2852,7 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
self.updateStatusBar(_translate(
|
self.updateStatusBar(_translate(
|
||||||
"MainWindow",
|
"MainWindow",
|
||||||
"Waiting for objects to be sent... %1%"
|
"Waiting for objects to be sent... %1%"
|
||||||
).arg(int(50 + 20 * (pendingUpload()/maxPendingUpload)))
|
).arg(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.AllEvents, 1000
|
||||||
|
@ -2869,18 +2895,14 @@ class MyForm(settingsmixin.SMainWindow):
|
||||||
logger.info("Shutdown complete")
|
logger.info("Shutdown complete")
|
||||||
super(MyForm, myapp).close()
|
super(MyForm, myapp).close()
|
||||||
# return
|
# return
|
||||||
os._exit(0)
|
sys.exit()
|
||||||
|
|
||||||
# window close event
|
# window close event
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
self.appIndicatorHide()
|
self.appIndicatorHide()
|
||||||
trayonclose = False
|
|
||||||
|
|
||||||
try:
|
trayonclose = BMConfigParser().safeGetBoolean(
|
||||||
trayonclose = BMConfigParser().getboolean(
|
'bitmessagesettings', 'trayonclose')
|
||||||
'bitmessagesettings', 'trayonclose')
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# always ignore, it shuts down by itself
|
# always ignore, it shuts down by itself
|
||||||
if self.quitAccepted:
|
if self.quitAccepted:
|
||||||
|
|
Reference in New Issue
Block a user