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