38 """ |
38 """ |
39 super(GitDiffDialog, self).__init__(parent) |
39 super(GitDiffDialog, self).__init__(parent) |
40 self.setupUi(self) |
40 self.setupUi(self) |
41 |
41 |
42 self.refreshButton = self.buttonBox.addButton( |
42 self.refreshButton = self.buttonBox.addButton( |
43 self.tr("Refresh"), QDialogButtonBox.ActionRole) |
43 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole) |
44 self.refreshButton.setToolTip( |
44 self.refreshButton.setToolTip( |
45 self.tr("Press to refresh the display")) |
45 self.tr("Press to refresh the display")) |
46 self.refreshButton.setEnabled(False) |
46 self.refreshButton.setEnabled(False) |
47 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) |
47 self.buttonBox.button( |
48 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
48 QDialogButtonBox.StandardButton.Save).setEnabled(False) |
|
49 self.buttonBox.button( |
|
50 QDialogButtonBox.StandardButton.Close).setDefault(True) |
49 |
51 |
50 try: |
52 try: |
51 # insert the search widget if it is available |
53 # insert the search widget if it is available |
52 from E5Gui.E5TextEditSearchWidget import E5TextEditSearchWidget |
54 from E5Gui.E5TextEditSearchWidget import E5TextEditSearchWidget |
53 self.searchWidget = E5TextEditSearchWidget(self.contentsGroup) |
55 self.searchWidget = E5TextEditSearchWidget(self.contentsGroup) |
54 self.searchWidget.setFocusPolicy(Qt.WheelFocus) |
56 self.searchWidget.setFocusPolicy(Qt.FocusPolicy.WheelFocus) |
55 self.searchWidget.setObjectName("searchWidget") |
57 self.searchWidget.setObjectName("searchWidget") |
56 self.contentsGroup.layout().insertWidget(1, self.searchWidget) |
58 self.contentsGroup.layout().insertWidget(1, self.searchWidget) |
57 self.searchWidget.attachTextEdit(self.contents) |
59 self.searchWidget.attachTextEdit(self.contents) |
58 |
60 |
59 self.searchWidget2 = E5TextEditSearchWidget(self.contentsGroup) |
61 self.searchWidget2 = E5TextEditSearchWidget(self.contentsGroup) |
60 self.searchWidget2.setFocusPolicy(Qt.WheelFocus) |
62 self.searchWidget2.setFocusPolicy(Qt.FocusPolicy.WheelFocus) |
61 self.searchWidget2.setObjectName("searchWidget2") |
63 self.searchWidget2.setObjectName("searchWidget2") |
62 self.contentsGroup.layout().addWidget(self.searchWidget2) |
64 self.contentsGroup.layout().addWidget(self.searchWidget2) |
63 self.searchWidget2.attachTextEdit(self.contents2) |
65 self.searchWidget2.attachTextEdit(self.contents2) |
64 |
66 |
65 self.setTabOrder(self.filesCombo, self.searchWidget) |
67 self.setTabOrder(self.filesCombo, self.searchWidget) |
201 if errors: |
203 if errors: |
202 self.errorGroup.show() |
204 self.errorGroup.show() |
203 self.errors.setPlainText(errors) |
205 self.errors.setPlainText(errors) |
204 self.errors.ensureCursorVisible() |
206 self.errors.ensureCursorVisible() |
205 |
207 |
206 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(bool(diff2)) |
208 self.buttonBox.button( |
207 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
209 QDialogButtonBox.StandardButton.Save).setEnabled(bool(diff2)) |
208 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
210 self.buttonBox.button( |
209 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
211 QDialogButtonBox.StandardButton.Close).setEnabled(True) |
210 Qt.OtherFocusReason) |
212 self.buttonBox.button( |
|
213 QDialogButtonBox.StandardButton.Close).setDefault(True) |
|
214 self.buttonBox.button( |
|
215 QDialogButtonBox.StandardButton.Close).setFocus( |
|
216 Qt.FocusReason.OtherFocusReason) |
211 |
217 |
212 for contents in [self.contents, self.contents2]: |
218 for contents in [self.contents, self.contents2]: |
213 tc = contents.textCursor() |
219 tc = contents.textCursor() |
214 tc.movePosition(QTextCursor.Start) |
220 tc.movePosition(QTextCursor.MoveOperation.Start) |
215 contents.setTextCursor(tc) |
221 contents.setTextCursor(tc) |
216 contents.ensureCursorVisible() |
222 contents.ensureCursorVisible() |
217 |
223 |
218 fileSeparators = self.__mergeFileSeparators(fileSeparators) |
224 fileSeparators = self.__mergeFileSeparators(fileSeparators) |
219 self.filesCombo.addItem(self.tr("<Start>"), (0, 0)) |
225 self.filesCombo.addItem(self.tr("<Start>"), (0, 0)) |
247 """ |
253 """ |
248 Private slot called by a button of the button box clicked. |
254 Private slot called by a button of the button box clicked. |
249 |
255 |
250 @param button button that was clicked (QAbstractButton) |
256 @param button button that was clicked (QAbstractButton) |
251 """ |
257 """ |
252 if button == self.buttonBox.button(QDialogButtonBox.Save): |
258 if button == self.buttonBox.button( |
|
259 QDialogButtonBox.StandardButton.Save |
|
260 ): |
253 self.on_saveButton_clicked() |
261 self.on_saveButton_clicked() |
254 elif button == self.refreshButton: |
262 elif button == self.refreshButton: |
255 self.on_refreshButton_clicked() |
263 self.on_refreshButton_clicked() |
256 |
264 |
257 @pyqtSlot(int) |
265 @pyqtSlot(int) |
265 |
273 |
266 for para, contents in [(para1, self.contents), |
274 for para, contents in [(para1, self.contents), |
267 (para2, self.contents2)]: |
275 (para2, self.contents2)]: |
268 if para == 0: |
276 if para == 0: |
269 tc = contents.textCursor() |
277 tc = contents.textCursor() |
270 tc.movePosition(QTextCursor.Start) |
278 tc.movePosition(QTextCursor.MoveOperation.Start) |
271 contents.setTextCursor(tc) |
279 contents.setTextCursor(tc) |
272 contents.ensureCursorVisible() |
280 contents.ensureCursorVisible() |
273 elif para == -1: |
281 elif para == -1: |
274 tc = contents.textCursor() |
282 tc = contents.textCursor() |
275 tc.movePosition(QTextCursor.End) |
283 tc.movePosition(QTextCursor.MoveOperation.End) |
276 contents.setTextCursor(tc) |
284 contents.setTextCursor(tc) |
277 contents.ensureCursorVisible() |
285 contents.ensureCursorVisible() |
278 else: |
286 else: |
279 # step 1: move cursor to end |
287 # step 1: move cursor to end |
280 tc = contents.textCursor() |
288 tc = contents.textCursor() |
281 tc.movePosition(QTextCursor.End) |
289 tc.movePosition(QTextCursor.MoveOperation.End) |
282 contents.setTextCursor(tc) |
290 contents.setTextCursor(tc) |
283 contents.ensureCursorVisible() |
291 contents.ensureCursorVisible() |
284 |
292 |
285 # step 2: move cursor to desired line |
293 # step 2: move cursor to desired line |
286 tc = contents.textCursor() |
294 tc = contents.textCursor() |
287 delta = tc.blockNumber() - para |
295 delta = tc.blockNumber() - para |
288 tc.movePosition(QTextCursor.PreviousBlock, |
296 tc.movePosition(QTextCursor.MoveOperation.PreviousBlock, |
289 QTextCursor.MoveAnchor, |
297 QTextCursor.MoveMode.MoveAnchor, |
290 delta) |
298 delta) |
291 contents.setTextCursor(tc) |
299 contents.setTextCursor(tc) |
292 contents.ensureCursorVisible() |
300 contents.ensureCursorVisible() |
293 |
301 |
294 @pyqtSlot() |
302 @pyqtSlot() |
354 @pyqtSlot() |
362 @pyqtSlot() |
355 def on_refreshButton_clicked(self): |
363 def on_refreshButton_clicked(self): |
356 """ |
364 """ |
357 Private slot to refresh the display. |
365 Private slot to refresh the display. |
358 """ |
366 """ |
359 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
367 self.buttonBox.button( |
360 |
368 QDialogButtonBox.StandardButton.Close).setEnabled(False) |
361 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) |
369 |
|
370 self.buttonBox.button( |
|
371 QDialogButtonBox.StandardButton.Save).setEnabled(False) |
362 self.refreshButton.setEnabled(False) |
372 self.refreshButton.setEnabled(False) |
363 |
373 |
364 self.start(self.__filename, diffMode=self.__diffMode, refreshable=True) |
374 self.start(self.__filename, diffMode=self.__diffMode, refreshable=True) |