34 @type QWidget |
34 @type QWidget |
35 """ |
35 """ |
36 super(PipDialog, self).__init__(parent) |
36 super(PipDialog, self).__init__(parent) |
37 self.setupUi(self) |
37 self.setupUi(self) |
38 |
38 |
|
39 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
|
40 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
|
41 |
39 self.proc = None |
42 self.proc = None |
40 self.__processQueue = [] |
43 self.__processQueue = [] |
41 self.__ioEncoding = Preferences.getSystem("IOEncoding") |
44 self.__ioEncoding = Preferences.getSystem("IOEncoding") |
42 |
45 |
43 self.outputGroup.setTitle(text) |
46 self.outputGroup.setTitle(text) |
50 Protected slot implementing a close event handler. |
53 Protected slot implementing a close event handler. |
51 |
54 |
52 @param e close event |
55 @param e close event |
53 @type QCloseEvent |
56 @type QCloseEvent |
54 """ |
57 """ |
55 self.__processQueue = [] |
58 self.__cancel() |
56 |
59 e.accept() |
|
60 |
|
61 def __finish(self): |
|
62 """ |
|
63 Private slot called when the process finished or the user pressed |
|
64 the button. |
|
65 """ |
57 if ( |
66 if ( |
58 self.proc is not None and |
67 self.proc is not None and |
59 self.proc.state() != QProcess.NotRunning |
68 self.proc.state() != QProcess.NotRunning |
60 ): |
69 ): |
61 self.proc.terminate() |
70 self.proc.terminate() |
62 QTimer.singleShot(2000, self.proc.kill) |
71 QTimer.singleShot(2000, self.proc.kill) |
63 self.proc.waitForFinished(3000) |
72 self.proc.waitForFinished(3000) |
64 |
73 |
65 self.proc = None |
74 self.proc = None |
66 |
75 |
67 e.accept() |
76 if self.__processQueue: |
68 |
77 cmd, args = self.__processQueue.pop(0) |
69 def __finish(self): |
78 self.__addOutput("\n\n") |
70 """ |
79 self.startProcess(cmd, args) |
71 Private slot called when the process finished or the user pressed |
80 else: |
72 the button. |
81 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
73 """ |
82 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
|
83 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
|
84 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
|
85 Qt.OtherFocusReason) |
|
86 |
|
87 def __cancel(self): |
|
88 """ |
|
89 Private slot to cancel the current action. |
|
90 """ |
|
91 self.__processQueue = [] |
|
92 |
74 if ( |
93 if ( |
75 self.proc is not None and |
94 self.proc is not None and |
76 self.proc.state() != QProcess.NotRunning |
95 self.proc.state() != QProcess.NotRunning |
77 ): |
96 ): |
78 self.proc.terminate() |
97 self.proc.terminate() |
80 self.proc.waitForFinished(3000) |
99 self.proc.waitForFinished(3000) |
81 |
100 |
82 self.proc = None |
101 self.proc = None |
83 |
102 |
84 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
103 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
|
104 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
|
105 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
85 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
106 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
86 Qt.OtherFocusReason) |
107 Qt.OtherFocusReason) |
87 |
|
88 if self.__processQueue: |
|
89 cmd, args = self.__processQueue.pop(0) |
|
90 self.__addOutput("\n\n") |
|
91 self.startProcess(cmd, args) |
|
92 |
108 |
93 @pyqtSlot(QAbstractButton) |
109 @pyqtSlot(QAbstractButton) |
94 def on_buttonBox_clicked(self, button): |
110 def on_buttonBox_clicked(self, button): |
95 """ |
111 """ |
96 Private slot called by a button of the button box clicked. |
112 Private slot called by a button of the button box clicked. |
98 @param button button that was clicked |
114 @param button button that was clicked |
99 @type QAbstractButton |
115 @type QAbstractButton |
100 """ |
116 """ |
101 if button == self.buttonBox.button(QDialogButtonBox.Close): |
117 if button == self.buttonBox.button(QDialogButtonBox.Close): |
102 self.close() |
118 self.close() |
|
119 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
|
120 self.__cancel() |
103 |
121 |
104 def __procFinished(self, exitCode, exitStatus): |
122 def __procFinished(self, exitCode, exitStatus): |
105 """ |
123 """ |
106 Private slot connected to the finished signal. |
124 Private slot connected to the finished signal. |
107 |
125 |