34 @param vcs reference to the vcs object |
34 @param vcs reference to the vcs object |
35 @param parent reference to the parent widget (QWidget) |
35 @param parent reference to the parent widget (QWidget) |
36 """ |
36 """ |
37 super(GitBlameDialog, self).__init__(parent) |
37 super(GitBlameDialog, self).__init__(parent) |
38 self.setupUi(self) |
38 self.setupUi(self) |
39 self.setWindowFlags(Qt.Window) |
39 self.setWindowFlags(Qt.WindowType.Window) |
40 |
40 |
41 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
41 self.buttonBox.button( |
42 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) |
42 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
|
43 self.buttonBox.button( |
|
44 QDialogButtonBox.StandardButton.Cancel).setDefault(True) |
43 |
45 |
44 self.vcs = vcs |
46 self.vcs = vcs |
45 |
47 |
46 self.__blameRe = re.compile( |
48 self.__blameRe = re.compile( |
47 r"""\^?([0-9a-fA-F]+)\s+\((.+)\s+(\d{4}-\d{2}-\d{2})\s+""" |
49 r"""\^?([0-9a-fA-F]+)\s+\((.+)\s+(\d{4}-\d{2}-\d{2})\s+""" |
67 |
69 |
68 @param e close event (QCloseEvent) |
70 @param e close event (QCloseEvent) |
69 """ |
71 """ |
70 if ( |
72 if ( |
71 self.process is not None and |
73 self.process is not None and |
72 self.process.state() != QProcess.NotRunning |
74 self.process.state() != QProcess.ProcessState.NotRunning |
73 ): |
75 ): |
74 self.process.terminate() |
76 self.process.terminate() |
75 QTimer.singleShot(2000, self.process.kill) |
77 QTimer.singleShot(2000, self.process.kill) |
76 self.process.waitForFinished(3000) |
78 self.process.waitForFinished(3000) |
77 |
79 |
128 Private slot called when the process finished or the user pressed |
130 Private slot called when the process finished or the user pressed |
129 the button. |
131 the button. |
130 """ |
132 """ |
131 if ( |
133 if ( |
132 self.process is not None and |
134 self.process is not None and |
133 self.process.state() != QProcess.NotRunning |
135 self.process.state() != QProcess.ProcessState.NotRunning |
134 ): |
136 ): |
135 self.process.terminate() |
137 self.process.terminate() |
136 QTimer.singleShot(2000, self.process.kill) |
138 QTimer.singleShot(2000, self.process.kill) |
137 self.process.waitForFinished(3000) |
139 self.process.waitForFinished(3000) |
138 |
140 |
139 self.inputGroup.setEnabled(False) |
141 self.inputGroup.setEnabled(False) |
140 self.inputGroup.hide() |
142 self.inputGroup.hide() |
141 |
143 |
142 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
144 self.buttonBox.button( |
143 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) |
145 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
144 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
146 self.buttonBox.button( |
145 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
147 QDialogButtonBox.StandardButton.Cancel).setEnabled(False) |
146 Qt.OtherFocusReason) |
148 self.buttonBox.button( |
|
149 QDialogButtonBox.StandardButton.Close).setDefault(True) |
|
150 self.buttonBox.button( |
|
151 QDialogButtonBox.StandardButton.Close).setFocus( |
|
152 Qt.FocusReason.OtherFocusReason) |
147 |
153 |
148 self.__resizeColumns() |
154 self.__resizeColumns() |
149 |
155 |
150 def on_buttonBox_clicked(self, button): |
156 def on_buttonBox_clicked(self, button): |
151 """ |
157 """ |
152 Private slot called by a button of the button box clicked. |
158 Private slot called by a button of the button box clicked. |
153 |
159 |
154 @param button button that was clicked (QAbstractButton) |
160 @param button button that was clicked (QAbstractButton) |
155 """ |
161 """ |
156 if button == self.buttonBox.button(QDialogButtonBox.Close): |
162 if button == self.buttonBox.button( |
|
163 QDialogButtonBox.StandardButton.Close |
|
164 ): |
157 self.close() |
165 self.close() |
158 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): |
166 elif button == self.buttonBox.button( |
|
167 QDialogButtonBox.StandardButton.Cancel |
|
168 ): |
159 self.__finish() |
169 self.__finish() |
160 |
170 |
161 def __procFinished(self, exitCode, exitStatus): |
171 def __procFinished(self, exitCode, exitStatus): |
162 """ |
172 """ |
163 Private slot connected to the finished signal. |
173 Private slot connected to the finished signal. |
169 |
179 |
170 def __resizeColumns(self): |
180 def __resizeColumns(self): |
171 """ |
181 """ |
172 Private method to resize the list columns. |
182 Private method to resize the list columns. |
173 """ |
183 """ |
174 self.blameList.header().resizeSections(QHeaderView.ResizeToContents) |
184 self.blameList.header().resizeSections( |
|
185 QHeaderView.ResizeMode.ResizeToContents) |
175 |
186 |
176 def __generateItem(self, commitId, author, date, time, lineno, text): |
187 def __generateItem(self, commitId, author, date, time, lineno, text): |
177 """ |
188 """ |
178 Private method to generate a blame item in the annotation list. |
189 Private method to generate a blame item in the annotation list. |
179 |
190 |
185 @param text name (path) of the tag (string) |
196 @param text name (path) of the tag (string) |
186 """ |
197 """ |
187 itm = QTreeWidgetItem( |
198 itm = QTreeWidgetItem( |
188 self.blameList, |
199 self.blameList, |
189 [commitId, author, date, time, lineno, text]) |
200 [commitId, author, date, time, lineno, text]) |
190 itm.setTextAlignment(0, Qt.AlignRight) |
201 itm.setTextAlignment(0, Qt.AlignmentFlag.AlignRight) |
191 itm.setTextAlignment(4, Qt.AlignRight) |
202 itm.setTextAlignment(4, Qt.AlignmentFlag.AlignRight) |
192 |
203 |
193 def __readStdout(self): |
204 def __readStdout(self): |
194 """ |
205 """ |
195 Private slot to handle the readyReadStdout signal. |
206 Private slot to handle the readyReadStdout signal. |
196 |
207 |
197 It reads the output of the process, formats it and inserts it into |
208 It reads the output of the process, formats it and inserts it into |
198 the annotation list. |
209 the annotation list. |
199 """ |
210 """ |
200 self.process.setReadChannel(QProcess.StandardOutput) |
211 self.process.setReadChannel(QProcess.ProcessChannel.StandardOutput) |
201 |
212 |
202 while self.process.canReadLine(): |
213 while self.process.canReadLine(): |
203 line = str(self.process.readLine(), |
214 line = str(self.process.readLine(), |
204 Preferences.getSystem("IOEncoding"), |
215 Preferences.getSystem("IOEncoding"), |
205 'replace').strip() |
216 'replace').strip() |
257 Private slot to handle the password checkbox toggled. |
268 Private slot to handle the password checkbox toggled. |
258 |
269 |
259 @param checked flag indicating the status of the check box (boolean) |
270 @param checked flag indicating the status of the check box (boolean) |
260 """ |
271 """ |
261 if checked: |
272 if checked: |
262 self.input.setEchoMode(QLineEdit.Password) |
273 self.input.setEchoMode(QLineEdit.EchoMode.Password) |
263 else: |
274 else: |
264 self.input.setEchoMode(QLineEdit.Normal) |
275 self.input.setEchoMode(QLineEdit.EchoMode.Normal) |
265 |
276 |
266 def keyPressEvent(self, evt): |
277 def keyPressEvent(self, evt): |
267 """ |
278 """ |
268 Protected slot to handle a key press event. |
279 Protected slot to handle a key press event. |
269 |
280 |