35 """ |
35 """ |
36 super(EricdocExecDialog, self).__init__(parent) |
36 super(EricdocExecDialog, self).__init__(parent) |
37 self.setModal(True) |
37 self.setModal(True) |
38 self.setupUi(self) |
38 self.setupUi(self) |
39 |
39 |
40 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
40 self.buttonBox.button( |
41 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
41 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
|
42 self.buttonBox.button( |
|
43 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
42 |
44 |
43 self.process = None |
45 self.process = None |
44 self.cmdname = cmdname |
46 self.cmdname = cmdname |
45 |
47 |
46 def start(self, args, fn): |
48 def start(self, args, fn): |
97 """ |
99 """ |
98 Private slot called by a button of the button box clicked. |
100 Private slot called by a button of the button box clicked. |
99 |
101 |
100 @param button button that was clicked (QAbstractButton) |
102 @param button button that was clicked (QAbstractButton) |
101 """ |
103 """ |
102 if button == self.buttonBox.button(QDialogButtonBox.Close): |
104 if button == self.buttonBox.button( |
|
105 QDialogButtonBox.StandardButton.Close |
|
106 ): |
103 self.accept() |
107 self.accept() |
104 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
108 elif button == self.buttonBox.button( |
|
109 QDialogButtonBox.StandardButton.Cancel |
|
110 ): |
105 self.__finish() |
111 self.__finish() |
106 |
112 |
107 def __finish(self): |
113 def __finish(self): |
108 """ |
114 """ |
109 Private slot called when the process finished. |
115 Private slot called when the process finished. |
110 |
116 |
111 It is called when the process finished or |
117 It is called when the process finished or |
112 the user pressed the button. |
118 the user pressed the button. |
113 """ |
119 """ |
114 if self.process is not None: |
120 if self.process is not None: |
115 if self.process.state() != QProcess.NotRunning: |
121 if self.process.state() != QProcess.ProcessState.NotRunning: |
116 self.process.terminate() |
122 self.process.terminate() |
117 QTimer.singleShot(2000, self.process.kill) |
123 QTimer.singleShot(2000, self.process.kill) |
118 self.process.waitForFinished(3000) |
124 self.process.waitForFinished(3000) |
119 if self.process.exitStatus() == QProcess.CrashExit: |
125 if self.process.exitStatus() == QProcess.ExitStatus.CrashExit: |
120 self.contents.insertPlainText( |
126 self.contents.insertPlainText( |
121 self.tr('\n{0} crashed.\n').format(self.cmdname)) |
127 self.tr('\n{0} crashed.\n').format(self.cmdname)) |
122 |
128 |
123 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
129 self.buttonBox.button( |
124 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
130 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
125 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
131 self.buttonBox.button( |
|
132 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
|
133 self.buttonBox.button( |
|
134 QDialogButtonBox.StandardButton.Close).setDefault(True) |
126 |
135 |
127 self.process = None |
136 self.process = None |
128 |
137 |
129 self.contents.insertPlainText( |
138 self.contents.insertPlainText( |
130 self.tr('\n{0} finished.\n').format(self.cmdname)) |
139 self.tr('\n{0} finished.\n').format(self.cmdname)) |
135 Private slot to handle the readyReadStandardOutput signal. |
144 Private slot to handle the readyReadStandardOutput signal. |
136 |
145 |
137 It reads the output of the process, formats it and inserts it into |
146 It reads the output of the process, formats it and inserts it into |
138 the contents pane. |
147 the contents pane. |
139 """ |
148 """ |
140 self.process.setReadChannel(QProcess.StandardOutput) |
149 self.process.setReadChannel(QProcess.ProcessChannel.StandardOutput) |
141 |
150 |
142 while self.process.canReadLine(): |
151 while self.process.canReadLine(): |
143 s = str(self.process.readLine(), |
152 s = str(self.process.readLine(), |
144 Preferences.getSystem("IOEncoding"), |
153 Preferences.getSystem("IOEncoding"), |
145 'replace') |
154 'replace') |
151 Private slot to handle the readyReadStandardError signal. |
160 Private slot to handle the readyReadStandardError signal. |
152 |
161 |
153 It reads the error output of the process and inserts it into the |
162 It reads the error output of the process and inserts it into the |
154 error pane. |
163 error pane. |
155 """ |
164 """ |
156 self.process.setReadChannel(QProcess.StandardError) |
165 self.process.setReadChannel(QProcess.ProcessChannel.StandardError) |
157 |
166 |
158 while self.process.canReadLine(): |
167 while self.process.canReadLine(): |
159 self.errorGroup.show() |
168 self.errorGroup.show() |
160 s = str(self.process.readLine(), |
169 s = str(self.process.readLine(), |
161 Preferences.getSystem("IOEncoding"), |
170 Preferences.getSystem("IOEncoding"), |