10 from PyQt6.QtCore import QCoreApplication, QEventLoop, Qt |
10 from PyQt6.QtCore import QCoreApplication, QEventLoop, Qt |
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
12 |
12 |
13 from eric7 import Preferences, Utilities |
13 from eric7 import Preferences, Utilities |
14 |
14 |
|
15 from .HgUtilities import parseProgressInfo |
15 from .Ui_HgDialog import Ui_HgDialog |
16 from .Ui_HgDialog import Ui_HgDialog |
16 |
17 |
17 |
18 |
18 class HgDialog(QDialog, Ui_HgDialog): |
19 class HgDialog(QDialog, Ui_HgDialog): |
19 """ |
20 """ |
54 def __finish(self): |
55 def __finish(self): |
55 """ |
56 """ |
56 Private slot called when the process finished or the user pressed |
57 Private slot called when the process finished or the user pressed |
57 the button. |
58 the button. |
58 """ |
59 """ |
|
60 self.progressWidget.hide() |
|
61 |
59 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True) |
62 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setEnabled(True) |
60 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
63 self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
61 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True) |
64 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setDefault(True) |
62 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setFocus( |
65 self.buttonBox.button(QDialogButtonBox.StandardButton.Close).setFocus( |
63 Qt.FocusReason.OtherFocusReason |
66 Qt.FocusReason.OtherFocusReason |
93 @param client reference to a non-standard command client |
96 @param client reference to a non-standard command client |
94 @type HgClient |
97 @type HgClient |
95 @return flag indicating a successful start of the process |
98 @return flag indicating a successful start of the process |
96 @rtype bool |
99 @rtype bool |
97 """ |
100 """ |
|
101 self.progressWidget.hide() |
98 self.errorGroup.hide() |
102 self.errorGroup.hide() |
99 self.inputGroup.hide() |
103 self.inputGroup.hide() |
100 self.normal = False |
104 self.normal = False |
101 |
105 |
102 self.__hasAddOrDelete = False |
106 self.__hasAddOrDelete = False |
166 |
171 |
167 def __showOutput(self, out): |
172 def __showOutput(self, out): |
168 """ |
173 """ |
169 Private slot to show some output. |
174 Private slot to show some output. |
170 |
175 |
171 @param out output to be shown |
176 @param out output sent to the stdout channel |
172 @type str |
177 @type str |
173 """ |
178 """ |
|
179 self.progressWidget.hide() |
|
180 |
174 self.resultbox.insertPlainText(Utilities.filterAnsiSequences(out)) |
181 self.resultbox.insertPlainText(Utilities.filterAnsiSequences(out)) |
175 self.resultbox.ensureCursorVisible() |
182 self.resultbox.ensureCursorVisible() |
176 |
183 |
177 # check for a changed project file |
184 # check for a changed project file |
178 if self.__updateCommand: |
185 if self.__updateCommand: |
183 |
190 |
184 QCoreApplication.processEvents() |
191 QCoreApplication.processEvents() |
185 |
192 |
186 def __showError(self, out): |
193 def __showError(self, out): |
187 """ |
194 """ |
188 Private slot to show some error. |
195 Private slot to show some error or progress information. |
189 |
196 |
190 @param out error to be shown |
197 @param out output sent to the stderr channel |
191 @type str |
198 @type str |
192 """ |
199 """ |
193 self.errorGroup.show() |
200 for line in out.splitlines(keepends=True): |
194 self.errors.insertPlainText(Utilities.filterAnsiSequences(out)) |
201 if line.strip(): |
195 self.errors.ensureCursorVisible() |
202 topic, value, maximum, estimate = parseProgressInfo(line.strip()) |
|
203 if topic: |
|
204 self.topicLabel.setText(topic.capitalize()) |
|
205 self.remainingTimeLabel.setText( |
|
206 self.tr("Time remaining: {0}").format(estimate) |
|
207 ) |
|
208 self.progressBar.setMaximum(maximum) |
|
209 self.progressBar.setValue(value) |
|
210 self.progressWidget.setVisible(value != maximum) |
|
211 else: |
|
212 self.errorGroup.show() |
|
213 self.errors.insertPlainText(Utilities.filterAnsiSequences(line)) |
|
214 self.errors.ensureCursorVisible() |
196 |
215 |
197 QCoreApplication.processEvents() |
216 QCoreApplication.processEvents() |
198 |
217 |
199 def hasAddOrDelete(self): |
218 def hasAddOrDelete(self): |
200 """ |
219 """ |