9 |
9 |
10 |
10 |
11 import os |
11 import os |
12 |
12 |
13 from PyQt5.QtCore import pyqtSlot, Qt, QPoint, QProcess, QTimer |
13 from PyQt5.QtCore import pyqtSlot, Qt, QPoint, QProcess, QTimer |
14 from PyQt5.QtGui import QCursor |
|
15 from PyQt5.QtWidgets import ( |
14 from PyQt5.QtWidgets import ( |
16 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication, |
15 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication, |
17 QLineEdit |
16 QLineEdit |
18 ) |
17 ) |
19 |
18 |
20 from E5Gui import E5MessageBox |
19 from E5Gui import E5MessageBox |
|
20 from E5Gui.E5OverrideCursor import E5OverrideCursorProcess |
21 |
21 |
22 from .Ui_GitBisectLogBrowserDialog import Ui_GitBisectLogBrowserDialog |
22 from .Ui_GitBisectLogBrowserDialog import Ui_GitBisectLogBrowserDialog |
23 |
23 |
24 import Preferences |
24 import Preferences |
25 from Globals import strToQByteArray |
25 from Globals import strToQByteArray |
62 self.__currentCommitId = "" |
62 self.__currentCommitId = "" |
63 |
63 |
64 self.__initData() |
64 self.__initData() |
65 self.__resetUI() |
65 self.__resetUI() |
66 |
66 |
67 self.process = QProcess() |
67 self.__process = E5OverrideCursorProcess() |
68 self.process.finished.connect(self.__procFinished) |
68 self.__process.finished.connect(self.__procFinished) |
69 self.process.readyReadStandardOutput.connect(self.__readStdout) |
69 self.__process.readyReadStandardOutput.connect(self.__readStdout) |
70 self.process.readyReadStandardError.connect(self.__readStderr) |
70 self.__process.readyReadStandardError.connect(self.__readStderr) |
71 |
71 |
72 def __initData(self): |
72 def __initData(self): |
73 """ |
73 """ |
74 Private method to (re-)initialize some data. |
74 Private method to (re-)initialize some data. |
75 """ |
75 """ |
80 Protected slot implementing a close event handler. |
80 Protected slot implementing a close event handler. |
81 |
81 |
82 @param e close event (QCloseEvent) |
82 @param e close event (QCloseEvent) |
83 """ |
83 """ |
84 if ( |
84 if ( |
85 self.process is not None and |
85 self.__process is not None and |
86 self.process.state() != QProcess.NotRunning |
86 self.__process.state() != QProcess.NotRunning |
87 ): |
87 ): |
88 self.process.terminate() |
88 self.__process.terminate() |
89 QTimer.singleShot(2000, self.process.kill) |
89 QTimer.singleShot(2000, self.__process.kill) |
90 self.process.waitForFinished(3000) |
90 self.__process.waitForFinished(3000) |
91 |
91 |
92 self.__position = self.pos() |
92 self.__position = self.pos() |
93 |
93 |
94 e.accept() |
94 e.accept() |
95 |
95 |
143 |
143 |
144 self.inputGroup.setEnabled(True) |
144 self.inputGroup.setEnabled(True) |
145 self.inputGroup.show() |
145 self.inputGroup.show() |
146 self.refreshButton.setEnabled(False) |
146 self.refreshButton.setEnabled(False) |
147 |
147 |
148 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
|
149 QApplication.processEvents() |
|
150 |
|
151 self.buf = [] |
148 self.buf = [] |
152 self.cancelled = False |
149 self.cancelled = False |
153 self.errors.clear() |
150 self.errors.clear() |
154 self.intercept = False |
151 self.intercept = False |
155 |
152 |
156 args = self.vcs.initCommand("bisect") |
153 args = self.vcs.initCommand("bisect") |
157 args.append("log") |
154 args.append("log") |
158 |
155 |
159 self.process.kill() |
156 self.__process.kill() |
160 |
157 |
161 self.process.setWorkingDirectory(self.repodir) |
158 self.__process.setWorkingDirectory(self.repodir) |
162 |
159 |
163 self.inputGroup.setEnabled(True) |
160 self.inputGroup.setEnabled(True) |
164 self.inputGroup.show() |
161 self.inputGroup.show() |
165 |
162 |
166 self.process.start('git', args) |
163 self.__process.start('git', args) |
167 procStarted = self.process.waitForStarted(5000) |
164 procStarted = self.__process.waitForStarted(5000) |
168 if not procStarted: |
165 if not procStarted: |
169 self.inputGroup.setEnabled(False) |
166 self.inputGroup.setEnabled(False) |
170 self.inputGroup.hide() |
167 self.inputGroup.hide() |
171 E5MessageBox.critical( |
168 E5MessageBox.critical( |
172 self, |
169 self, |
214 """ |
211 """ |
215 Private slot called when the process finished or the user pressed |
212 Private slot called when the process finished or the user pressed |
216 the button. |
213 the button. |
217 """ |
214 """ |
218 if ( |
215 if ( |
219 self.process is not None and |
216 self.__process is not None and |
220 self.process.state() != QProcess.NotRunning |
217 self.__process.state() != QProcess.NotRunning |
221 ): |
218 ): |
222 self.process.terminate() |
219 self.__process.terminate() |
223 QTimer.singleShot(2000, self.process.kill) |
220 QTimer.singleShot(2000, self.__process.kill) |
224 self.process.waitForFinished(3000) |
221 self.__process.waitForFinished(3000) |
225 |
|
226 QApplication.restoreOverrideCursor() |
|
227 |
222 |
228 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
223 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
229 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
224 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
230 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
225 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
231 |
226 |
263 """ |
258 """ |
264 Private slot to handle the readyReadStandardOutput signal. |
259 Private slot to handle the readyReadStandardOutput signal. |
265 |
260 |
266 It reads the output of the process and inserts it into a buffer. |
261 It reads the output of the process and inserts it into a buffer. |
267 """ |
262 """ |
268 self.process.setReadChannel(QProcess.StandardOutput) |
263 self.__process.setReadChannel(QProcess.StandardOutput) |
269 |
264 |
270 while self.process.canReadLine(): |
265 while self.__process.canReadLine(): |
271 line = str(self.process.readLine(), |
266 line = str(self.__process.readLine(), |
272 Preferences.getSystem("IOEncoding"), |
267 Preferences.getSystem("IOEncoding"), |
273 'replace') |
268 'replace') |
274 self.buf.append(line) |
269 self.buf.append(line) |
275 |
270 |
276 def __readStderr(self): |
271 def __readStderr(self): |
278 Private slot to handle the readyReadStandardError signal. |
273 Private slot to handle the readyReadStandardError signal. |
279 |
274 |
280 It reads the error output of the process and inserts it into the |
275 It reads the error output of the process and inserts it into the |
281 error pane. |
276 error pane. |
282 """ |
277 """ |
283 if self.process is not None: |
278 if self.__process is not None: |
284 s = str(self.process.readAllStandardError(), |
279 s = str(self.__process.readAllStandardError(), |
285 Preferences.getSystem("IOEncoding"), |
280 Preferences.getSystem("IOEncoding"), |
286 'replace') |
281 'replace') |
287 self.__showError(s) |
282 self.__showError(s) |
288 |
283 |
289 def __showError(self, out): |
284 def __showError(self, out): |
349 else: |
344 else: |
350 self.errors.insertPlainText(inputTxt) |
345 self.errors.insertPlainText(inputTxt) |
351 self.errors.ensureCursorVisible() |
346 self.errors.ensureCursorVisible() |
352 self.errorGroup.show() |
347 self.errorGroup.show() |
353 |
348 |
354 self.process.write(strToQByteArray(inputTxt)) |
349 self.__process.write(strToQByteArray(inputTxt)) |
355 |
350 |
356 self.passwordCheckBox.setChecked(False) |
351 self.passwordCheckBox.setChecked(False) |
357 self.input.clear() |
352 self.input.clear() |
358 |
353 |
359 def on_input_returnPressed(self): |
354 def on_input_returnPressed(self): |