Compare commits

...

6 Commits

1 changed files with 58 additions and 19 deletions

View File

@ -832,6 +832,9 @@ class MyForm(settingsmixin.SMainWindow):
'bitmessagesettings', 'dontconnect') 'bitmessagesettings', 'dontconnect')
self._contact_selected = None self._contact_selected = None
self.progress = QtGui.QProgressBar(self)
self.progress.setGeometry(550, 555, 250, 20)
self.progress.hide()
def getContactSelected(self): def getContactSelected(self):
"""Returns last selected contact once""" """Returns last selected contact once"""
@ -2607,6 +2610,18 @@ class MyForm(settingsmixin.SMainWindow):
dontconnect_option or self.namecoin.test()[0] == 'failed' dontconnect_option or self.namecoin.test()[0] == 'failed'
) )
def processing(self):
"""Processing progress bar"""
completed = 0
self.progress.show()
while completed < 80:
completed += 0.1
self.progress.setValue(completed)
def hideprogressBar(self):
"""Hide progress bar"""
self.progress.hide()
# Quit selected from menu or application indicator # Quit selected from menu or application indicator
def quit(self): def quit(self):
"""Quit the bitmessageqt application""" """Quit the bitmessageqt application"""
@ -2623,8 +2638,9 @@ 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( messagebox = QtGui.QMessageBox(
self, _translate("MainWindow", "Proof of work pending"), QtGui.QMessageBox.Question,
_translate("MainWindow", "Proof of work pending"),
_translate( _translate(
"MainWindow", "MainWindow",
"%n object(s) pending proof of work", None, "%n object(s) pending proof of work", None,
@ -2636,17 +2652,25 @@ class MyForm(settingsmixin.SMainWindow):
QtCore.QCoreApplication.CodecForTr, pendingUpload() QtCore.QCoreApplication.CodecForTr, pendingUpload()
) + "\n\n" + ) + "\n\n" +
_translate( _translate(
"MainWindow", "Wait until these tasks finish?"), "MainWindow", "Wait until these tasks finish?"), parent=self)
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No messagebox.setStandardButtons(
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel)
btnN = messagebox.button(QtGui.QMessageBox.No)
btnN.setText("Quit")
btnN.clicked.connect(self.processing)
btnC = messagebox.button(QtGui.QMessageBox.Cancel)
btnC.setText("Don't Quit")
btnC.clicked.connect(self.hideprogressBar)
reply = messagebox.exec_()
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( messagebox = QtGui.QMessageBox(
self, _translate("MainWindow", "Synchronisation pending"), QtGui.QMessageBox.Question,
_translate("MainWindow", "Synchronisation pending"),
_translate( _translate(
"MainWindow", "MainWindow",
"Bitmessage hasn't synchronised with the network," "Bitmessage hasn't synchronised with the network,"
@ -2654,9 +2678,16 @@ class MyForm(settingsmixin.SMainWindow):
" it may cause delivery delays. Wait until the" " it may cause delivery delays. Wait until the"
" synchronisation finishes?", None, " synchronisation finishes?", None,
QtCore.QCoreApplication.CodecForTr, pendingDownload() QtCore.QCoreApplication.CodecForTr, pendingDownload()
), ), parent=self)
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No messagebox.setStandardButtons(
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel)
btnN = messagebox.button(QtGui.QMessageBox.No)
btnN.setText("Quit")
btnN.clicked.connect(self.processing)
btnC = messagebox.button(QtGui.QMessageBox.Cancel)
btnC.setText("Don't Quit")
btnC.clicked.connect(self.hideprogressBar)
reply = messagebox.exec_()
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:
self.wait = waitForSync = True self.wait = waitForSync = True
elif reply == QtGui.QMessageBox.Cancel: elif reply == QtGui.QMessageBox.Cancel:
@ -2664,16 +2695,24 @@ class MyForm(settingsmixin.SMainWindow):
if state.statusIconColor == 'red' and not BMConfigParser().safeGetBoolean( if state.statusIconColor == 'red' and not BMConfigParser().safeGetBoolean(
'bitmessagesettings', 'dontconnect'): 'bitmessagesettings', 'dontconnect'):
reply = QtGui.QMessageBox.question( messagebox = QtGui.QMessageBox(
self, _translate("MainWindow", "Not connected"), QtGui.QMessageBox.Question,
_translate("MainWindow", "Not connected"),
_translate( _translate(
"MainWindow", "MainWindow",
"Bitmessage isn't connected to the network. If you" "Bitmessage isn't connected to the network. If you"
" 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?"
), ), parent=self)
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No messagebox.setStandardButtons(
| QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel)
btnN = messagebox.button(QtGui.QMessageBox.No)
btnN.setText("Quit")
btnN.clicked.connect(self.processing)
btnC = messagebox.button(QtGui.QMessageBox.Cancel)
btnC.setText("Don't Quit")
btnC.clicked.connect(self.hideprogressBar)
reply = messagebox.exec_()
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:
waitForConnection = True waitForConnection = True
self.wait = waitForSync = True self.wait = waitForSync = True
@ -2684,11 +2723,10 @@ class MyForm(settingsmixin.SMainWindow):
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Shutting down PyBitmessage... %1%").arg(0)) "MainWindow", "Shutting down PyBitmessage... %1%").arg(0))
if waitForConnection: if waitForConnection:
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Waiting for network connection...")) "MainWindow", "Waiting for network connection..."))
while state.statusIconColor == 'red': while state.statusIconColor == 'red' and not self.quitAccepted:
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.AllEvents, 1000
@ -2700,7 +2738,7 @@ class MyForm(settingsmixin.SMainWindow):
if waitForSync: if waitForSync:
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Waiting for finishing synchronisation...")) "MainWindow", "Waiting for finishing synchronisation..."))
while pendingDownload() > 0: while pendingDownload() > 0 and not self.quitAccepted:
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000 QtCore.QEventLoop.AllEvents, 1000
@ -2715,7 +2753,7 @@ class MyForm(settingsmixin.SMainWindow):
curWorkerQueue = powQueueSize() curWorkerQueue = powQueueSize()
if curWorkerQueue > maxWorkerQueue: if curWorkerQueue > maxWorkerQueue:
maxWorkerQueue = curWorkerQueue maxWorkerQueue = curWorkerQueue
if curWorkerQueue > 0: if curWorkerQueue > 0 and not self.quitAccepted:
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) /
@ -2804,6 +2842,7 @@ class MyForm(settingsmixin.SMainWindow):
self.appIndicatorHide() self.appIndicatorHide()
else: else:
# custom quit method # custom quit method
self.wait = False
self.quit() self.quit()
def on_action_InboxMessageForceHtml(self): def on_action_InboxMessageForceHtml(self):