13 |
13 |
14 from PyQt5.QtCore import ( |
14 from PyQt5.QtCore import ( |
15 pyqtSlot, Qt, QDate, QProcess, QTimer, QRegExp, QSize, QPoint, QFileInfo |
15 pyqtSlot, Qt, QDate, QProcess, QTimer, QRegExp, QSize, QPoint, QFileInfo |
16 ) |
16 ) |
17 from PyQt5.QtGui import ( |
17 from PyQt5.QtGui import ( |
18 QCursor, QColor, QPixmap, QPainter, QPen, QIcon, QTextCursor, QPalette |
18 QColor, QPixmap, QPainter, QPen, QIcon, QTextCursor, QPalette |
19 ) |
19 ) |
20 from PyQt5.QtWidgets import ( |
20 from PyQt5.QtWidgets import ( |
21 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication, |
21 QWidget, QDialogButtonBox, QHeaderView, QTreeWidgetItem, QApplication, |
22 QLineEdit, QMenu, QInputDialog |
22 QLineEdit, QMenu, QInputDialog |
23 ) |
23 ) |
24 |
24 |
25 from E5Gui.E5Application import e5App |
25 from E5Gui.E5Application import e5App |
26 from E5Gui import E5MessageBox, E5FileDialog |
26 from E5Gui import E5MessageBox, E5FileDialog |
|
27 from E5Gui.E5OverrideCursor import E5OverrideCursorProcess |
27 |
28 |
28 from Globals import strToQByteArray |
29 from Globals import strToQByteArray |
29 |
30 |
30 from .Ui_GitLogBrowserDialog import Ui_GitLogBrowserDialog |
31 from .Ui_GitLogBrowserDialog import Ui_GitLogBrowserDialog |
31 |
32 |
192 self.__committerMailRole = Qt.UserRole + 7 |
193 self.__committerMailRole = Qt.UserRole + 7 |
193 |
194 |
194 # roles used in the file tree |
195 # roles used in the file tree |
195 self.__diffFileLineRole = Qt.UserRole |
196 self.__diffFileLineRole = Qt.UserRole |
196 |
197 |
197 self.process = QProcess() |
198 self.__process = E5OverrideCursorProcess() |
198 self.process.finished.connect(self.__procFinished) |
199 self.__process.finished.connect(self.__procFinished) |
199 self.process.readyReadStandardOutput.connect(self.__readStdout) |
200 self.__process.readyReadStandardOutput.connect(self.__readStdout) |
200 self.process.readyReadStandardError.connect(self.__readStderr) |
201 self.__process.readyReadStandardError.connect(self.__readStderr) |
201 |
202 |
202 self.flags = { |
203 self.flags = { |
203 'A': self.tr('Added'), |
204 'A': self.tr('Added'), |
204 'D': self.tr('Deleted'), |
205 'D': self.tr('Deleted'), |
205 'M': self.tr('Modified'), |
206 'M': self.tr('Modified'), |
381 Protected slot implementing a close event handler. |
382 Protected slot implementing a close event handler. |
382 |
383 |
383 @param e close event (QCloseEvent) |
384 @param e close event (QCloseEvent) |
384 """ |
385 """ |
385 if ( |
386 if ( |
386 self.process is not None and |
387 self.__process is not None and |
387 self.process.state() != QProcess.NotRunning |
388 self.__process.state() != QProcess.NotRunning |
388 ): |
389 ): |
389 self.process.terminate() |
390 self.__process.terminate() |
390 QTimer.singleShot(2000, self.process.kill) |
391 QTimer.singleShot(2000, self.__process.kill) |
391 self.process.waitForFinished(3000) |
392 self.__process.waitForFinished(3000) |
392 |
393 |
393 self.vcs.getPlugin().setPreferences( |
394 self.vcs.getPlugin().setPreferences( |
394 "LogBrowserGeometry", self.saveGeometry()) |
395 "LogBrowserGeometry", self.saveGeometry()) |
395 self.vcs.getPlugin().setPreferences( |
396 self.vcs.getPlugin().setPreferences( |
396 "LogBrowserSplitterStates", [ |
397 "LogBrowserSplitterStates", [ |
780 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
781 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
781 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
782 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) |
782 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
783 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
783 QApplication.processEvents() |
784 QApplication.processEvents() |
784 |
785 |
785 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
|
786 QApplication.processEvents() |
|
787 |
|
788 self.buf = [] |
786 self.buf = [] |
789 self.cancelled = False |
787 self.cancelled = False |
790 self.errors.clear() |
788 self.errors.clear() |
791 self.intercept = False |
789 self.intercept = False |
792 |
790 |
808 if not self.stopCheckBox.isChecked(): |
806 if not self.stopCheckBox.isChecked(): |
809 args.append('--follow') |
807 args.append('--follow') |
810 args.append('--') |
808 args.append('--') |
811 args.append(self.__filename) |
809 args.append(self.__filename) |
812 |
810 |
813 self.process.kill() |
811 self.__process.kill() |
814 |
812 |
815 self.process.setWorkingDirectory(self.repodir) |
813 self.__process.setWorkingDirectory(self.repodir) |
816 |
814 |
817 self.process.start('git', args) |
815 self.__process.start('git', args) |
818 procStarted = self.process.waitForStarted(5000) |
816 procStarted = self.__process.waitForStarted(5000) |
819 if not procStarted: |
817 if not procStarted: |
820 self.inputGroup.setEnabled(False) |
818 self.inputGroup.setEnabled(False) |
821 self.inputGroup.hide() |
819 self.inputGroup.hide() |
822 E5MessageBox.critical( |
820 E5MessageBox.critical( |
823 self, |
821 self, |
879 """ |
877 """ |
880 Private slot called when the process finished or the user pressed |
878 Private slot called when the process finished or the user pressed |
881 the button. |
879 the button. |
882 """ |
880 """ |
883 if ( |
881 if ( |
884 self.process is not None and |
882 self.__process is not None and |
885 self.process.state() != QProcess.NotRunning |
883 self.__process.state() != QProcess.NotRunning |
886 ): |
884 ): |
887 self.process.terminate() |
885 self.__process.terminate() |
888 QTimer.singleShot(2000, self.process.kill) |
886 QTimer.singleShot(2000, self.__process.kill) |
889 self.process.waitForFinished(3000) |
887 self.__process.waitForFinished(3000) |
890 |
|
891 QApplication.restoreOverrideCursor() |
|
892 |
888 |
893 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
889 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
894 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
890 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
895 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
891 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
896 |
892 |
1050 """ |
1046 """ |
1051 Private slot to handle the readyReadStandardOutput signal. |
1047 Private slot to handle the readyReadStandardOutput signal. |
1052 |
1048 |
1053 It reads the output of the process and inserts it into a buffer. |
1049 It reads the output of the process and inserts it into a buffer. |
1054 """ |
1050 """ |
1055 self.process.setReadChannel(QProcess.StandardOutput) |
1051 self.__process.setReadChannel(QProcess.StandardOutput) |
1056 |
1052 |
1057 while self.process.canReadLine(): |
1053 while self.__process.canReadLine(): |
1058 line = str(self.process.readLine(), |
1054 line = str(self.__process.readLine(), |
1059 Preferences.getSystem("IOEncoding"), |
1055 Preferences.getSystem("IOEncoding"), |
1060 'replace') |
1056 'replace') |
1061 self.buf.append(line) |
1057 self.buf.append(line) |
1062 |
1058 |
1063 def __readStderr(self): |
1059 def __readStderr(self): |
1065 Private slot to handle the readyReadStandardError signal. |
1061 Private slot to handle the readyReadStandardError signal. |
1066 |
1062 |
1067 It reads the error output of the process and inserts it into the |
1063 It reads the error output of the process and inserts it into the |
1068 error pane. |
1064 error pane. |
1069 """ |
1065 """ |
1070 if self.process is not None: |
1066 if self.__process is not None: |
1071 s = str(self.process.readAllStandardError(), |
1067 s = str(self.__process.readAllStandardError(), |
1072 Preferences.getSystem("IOEncoding"), |
1068 Preferences.getSystem("IOEncoding"), |
1073 'replace') |
1069 'replace') |
1074 self.__showError(s) |
1070 self.__showError(s) |
1075 |
1071 |
1076 def __showError(self, out): |
1072 def __showError(self, out): |
1145 else: |
1141 else: |
1146 self.errors.insertPlainText(inputTxt) |
1142 self.errors.insertPlainText(inputTxt) |
1147 self.errors.ensureCursorVisible() |
1143 self.errors.ensureCursorVisible() |
1148 self.errorGroup.show() |
1144 self.errorGroup.show() |
1149 |
1145 |
1150 self.process.write(strToQByteArray(inputTxt)) |
1146 self.__process.write(strToQByteArray(inputTxt)) |
1151 |
1147 |
1152 self.passwordCheckBox.setChecked(False) |
1148 self.passwordCheckBox.setChecked(False) |
1153 self.input.clear() |
1149 self.input.clear() |
1154 |
1150 |
1155 def on_input_returnPressed(self): |
1151 def on_input_returnPressed(self): |