7 Module implementing a TaskHandle class with a progress dialog. |
7 Module implementing a TaskHandle class with a progress dialog. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt4.QtGui import QApplication, QLabel |
12 from PyQt5.QtCore import QCoreApplication |
|
13 from PyQt5.QtWidgets import QApplication, QLabel |
13 |
14 |
14 import rope.base.taskhandle |
15 import rope.base.taskhandle |
15 |
16 |
16 |
17 |
17 class ProgressHandle(rope.base.taskhandle.TaskHandle): |
18 class ProgressHandle(rope.base.taskhandle.TaskHandle): |
27 interrupted (boolean) |
28 interrupted (boolean) |
28 @param parent reference to the parent widget (QWidget) |
29 @param parent reference to the parent widget (QWidget) |
29 """ |
30 """ |
30 rope.base.taskhandle.TaskHandle.__init__(self, title, interruptable) |
31 rope.base.taskhandle.TaskHandle.__init__(self, title, interruptable) |
31 if interruptable: |
32 if interruptable: |
32 cancelLabel = QApplication.translate("ProgressHandle", "Interrupt") |
33 cancelLabel = QCoreApplication.translate( |
|
34 "ProgressHandle", "Interrupt") |
33 else: |
35 else: |
34 cancelLabel = "" |
36 cancelLabel = "" |
35 barFormat = QApplication.translate("ProgressHandle", "%v/%m files") |
37 barFormat = QCoreApplication.translate("ProgressHandle", "%v/%m files") |
36 try: |
38 try: |
37 from E5Gui.E5ProgressDialog import E5ProgressDialog |
39 from E5Gui.E5ProgressDialog import E5ProgressDialog |
38 self.__progress = E5ProgressDialog("", cancelLabel, 0, 1, |
40 self.__progress = E5ProgressDialog("", cancelLabel, 0, 1, |
39 barFormat, parent) |
41 barFormat, parent) |
40 except ImportError: |
42 except ImportError: |
41 from PyQt4.QtGui import QProgressDialog, QProgressBar |
43 from PyQt5.QtWidgets import QProgressDialog, QProgressBar |
42 self.__progress = QProgressDialog("", cancelLabel, 0, 1, parent) |
44 self.__progress = QProgressDialog("", cancelLabel, 0, 1, parent) |
43 bar = QProgressBar(self.__progress) |
45 bar = QProgressBar(self.__progress) |
44 bar.setFormat(barFormat) |
46 bar.setFormat(barFormat) |
45 self.__progress.setBar(bar) |
47 self.__progress.setBar(bar) |
46 label = QLabel("") |
48 label = QLabel("") |
47 label.setWordWrap(True) |
49 label.setWordWrap(True) |
48 self.__progress.setLabel(label) |
50 self.__progress.setLabel(label) |
49 self.__progress.setWindowTitle( |
51 self.__progress.setWindowTitle( |
50 QApplication.translate("ProgressHandle", "eric5 - {0}") |
52 QCoreApplication.translate("ProgressHandle", "eric6 - {0}") |
51 .format(title)) |
53 .format(title)) |
52 self.add_observer(self.__updateProgress) |
54 self.add_observer(self.__updateProgress) |
53 |
55 |
54 def __updateProgress(self): |
56 def __updateProgress(self): |
55 """ |
57 """ |
56 Private slot to handle the task progress. |
58 Private slot to handle the task progress. |