diff -r 6a9e7b37a18b -r 121d426d4ed7 RefactoringRope/ProgressHandle.py --- a/RefactoringRope/ProgressHandle.py Tue Sep 12 18:55:25 2017 +0200 +++ b/RefactoringRope/ProgressHandle.py Thu Sep 14 19:39:11 2017 +0200 @@ -9,9 +9,6 @@ from __future__ import unicode_literals -from PyQt5.QtCore import QCoreApplication -from PyQt5.QtWidgets import QApplication, QLabel - import rope.base.taskhandle @@ -19,38 +16,27 @@ """ Class implementing TaskHandle with a progress dialog. """ - def __init__(self, title, interruptable=True, parent=None): + def __init__(self, client, title, interruptable=True): """ Constructor - @param title title for the taskhandle (string) + @param client reference to the JSON client + @type JsonClient + @param title title for the taskhandle + @type str @param interruptable flag indicating, that the task may be - interrupted (boolean) - @param parent reference to the parent widget (QWidget) + interrupted + @type bool """ rope.base.taskhandle.TaskHandle.__init__(self, title, interruptable) - if interruptable: - cancelLabel = QCoreApplication.translate( - "ProgressHandle", "Interrupt") - else: - cancelLabel = "" - barFormat = QCoreApplication.translate("ProgressHandle", "%v/%m files") - try: - from E5Gui.E5ProgressDialog import E5ProgressDialog - self.__progress = E5ProgressDialog("", cancelLabel, 0, 1, - barFormat, parent) - except ImportError: - from PyQt5.QtWidgets import QProgressDialog, QProgressBar - self.__progress = QProgressDialog("", cancelLabel, 0, 1, parent) - bar = QProgressBar(self.__progress) - bar.setFormat(barFormat) - self.__progress.setBar(bar) - label = QLabel("") - label.setWordWrap(True) - self.__progress.setLabel(label) - self.__progress.setWindowTitle( - QCoreApplication.translate("ProgressHandle", "eric6 - {0}") - .format(title)) + + self.__client = client + + self.__client.sendJson("ProgressInit", { + "Title": title, + "Interrutable": interruptable, + }) + self.add_observer(self.__updateProgress) def __updateProgress(self): @@ -64,22 +50,21 @@ text += jobset.get_name() if jobset.get_active_job_name() is not None: text += ': ' + jobset.get_active_job_name() - self.__progress.setLabelText(text) + params = { + "Text": text, + } if jobset.count is not None: - self.__progress.setMaximum(jobset.count) - self.__progress.setValue(jobset.done) - QApplication.processEvents() - if not self.is_stopped() and self.__progress.wasCanceled(): - self.stop() - - def show(self): - """ - Public slot to show the progress dialog. - """ - self.__progress.show() + params["Maximum"] = jobset.count + params["Value"] = jobset.done + else: + params = {} + + self.__client.sendJson("Progress", params) + self.__client.poll() def reset(self): """ Public slot to reset the progress dialog. """ - self.__progress.reset() + self.__client.sendJson("ProgressReset", {}) + self.__client.poll()