diff -r 9a4e93471a06 -r 704c46e040a2 eric6/PipInterface/PipDialog.py --- a/eric6/PipInterface/PipDialog.py Sun Nov 01 11:07:43 2020 +0100 +++ b/eric6/PipInterface/PipDialog.py Sun Nov 08 11:42:46 2020 +0100 @@ -36,6 +36,9 @@ super(PipDialog, self).__init__(parent) self.setupUi(self) + self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) + self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) + self.proc = None self.__processQueue = [] self.__ioEncoding = Preferences.getSystem("IOEncoding") @@ -52,18 +55,7 @@ @param e close event @type QCloseEvent """ - self.__processQueue = [] - - if ( - self.proc is not None and - self.proc.state() != QProcess.NotRunning - ): - self.proc.terminate() - QTimer.singleShot(2000, self.proc.kill) - self.proc.waitForFinished(3000) - - self.proc = None - + self.__cancel() e.accept() def __finish(self): @@ -81,14 +73,38 @@ self.proc = None - self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) - self.buttonBox.button(QDialogButtonBox.Close).setFocus( - Qt.OtherFocusReason) - if self.__processQueue: cmd, args = self.__processQueue.pop(0) self.__addOutput("\n\n") self.startProcess(cmd, args) + else: + self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) + self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) + self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + self.buttonBox.button(QDialogButtonBox.Close).setFocus( + Qt.OtherFocusReason) + + def __cancel(self): + """ + Private slot to cancel the current action. + """ + self.__processQueue = [] + + if ( + self.proc is not None and + self.proc.state() != QProcess.NotRunning + ): + self.proc.terminate() + QTimer.singleShot(2000, self.proc.kill) + self.proc.waitForFinished(3000) + + self.proc = None + + self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) + self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) + self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) + self.buttonBox.button(QDialogButtonBox.Close).setFocus( + Qt.OtherFocusReason) @pyqtSlot(QAbstractButton) def on_buttonBox_clicked(self, button): @@ -100,6 +116,8 @@ """ if button == self.buttonBox.button(QDialogButtonBox.Close): self.close() + elif button == self.buttonBox.button(QDialogButtonBox.Cancel): + self.__cancel() def __procFinished(self, exitCode, exitStatus): """