eric6/Plugins/VcsPlugins/vcsSubversion/SvnDiffDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8176
31965986ecd1
child 8218
7c09585bd960
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
39 """ 39 """
40 super(SvnDiffDialog, self).__init__(parent) 40 super(SvnDiffDialog, self).__init__(parent)
41 self.setupUi(self) 41 self.setupUi(self)
42 42
43 self.refreshButton = self.buttonBox.addButton( 43 self.refreshButton = self.buttonBox.addButton(
44 self.tr("Refresh"), QDialogButtonBox.ActionRole) 44 self.tr("Refresh"), QDialogButtonBox.ButtonRole.ActionRole)
45 self.refreshButton.setToolTip( 45 self.refreshButton.setToolTip(
46 self.tr("Press to refresh the display")) 46 self.tr("Press to refresh the display"))
47 self.refreshButton.setEnabled(False) 47 self.refreshButton.setEnabled(False)
48 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) 48 self.buttonBox.button(
49 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 49 QDialogButtonBox.StandardButton.Save).setEnabled(False)
50 self.buttonBox.button(
51 QDialogButtonBox.StandardButton.Close).setDefault(True)
50 52
51 self.searchWidget.attachTextEdit(self.contents) 53 self.searchWidget.attachTextEdit(self.contents)
52 54
53 self.process = QProcess() 55 self.process = QProcess()
54 self.vcs = vcs 56 self.vcs = vcs
68 70
69 @param e close event (QCloseEvent) 71 @param e close event (QCloseEvent)
70 """ 72 """
71 if ( 73 if (
72 self.process is not None and 74 self.process is not None and
73 self.process.state() != QProcess.NotRunning 75 self.process.state() != QProcess.ProcessState.NotRunning
74 ): 76 ):
75 self.process.terminate() 77 self.process.terminate()
76 QTimer.singleShot(2000, self.process.kill) 78 QTimer.singleShot(2000, self.process.kill)
77 self.process.waitForFinished(3000) 79 self.process.waitForFinished(3000)
78 80
126 args = [] 128 args = []
127 args.append('diff') 129 args.append('diff')
128 self.vcs.addArguments(args, self.vcs.options['global']) 130 self.vcs.addArguments(args, self.vcs.options['global'])
129 self.vcs.addArguments(args, self.vcs.options['diff']) 131 self.vcs.addArguments(args, self.vcs.options['diff'])
130 if '--diff-cmd' in self.vcs.options['diff']: 132 if '--diff-cmd' in self.vcs.options['diff']:
131 self.buttonBox.button(QDialogButtonBox.Save).hide() 133 self.buttonBox.button(QDialogButtonBox.StandardButton.Save).hide()
132 134
133 if versions is not None: 135 if versions is not None:
134 self.raise_() 136 self.raise_()
135 self.activateWindow() 137 self.activateWindow()
136 138
204 self.refreshButton.setEnabled(True) 206 self.refreshButton.setEnabled(True)
205 207
206 if self.paras == 0: 208 if self.paras == 0:
207 self.contents.setPlainText(self.tr('There is no difference.')) 209 self.contents.setPlainText(self.tr('There is no difference.'))
208 210
209 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.paras > 0) 211 self.buttonBox.button(
210 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 212 QDialogButtonBox.StandardButton.Save).setEnabled(self.paras > 0)
211 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 213 self.buttonBox.button(
212 self.buttonBox.button(QDialogButtonBox.Close).setFocus( 214 QDialogButtonBox.StandardButton.Close).setEnabled(True)
213 Qt.OtherFocusReason) 215 self.buttonBox.button(
216 QDialogButtonBox.StandardButton.Close).setDefault(True)
217 self.buttonBox.button(
218 QDialogButtonBox.StandardButton.Close).setFocus(
219 Qt.FocusReason.OtherFocusReason)
214 220
215 tc = self.contents.textCursor() 221 tc = self.contents.textCursor()
216 tc.movePosition(QTextCursor.Start) 222 tc.movePosition(QTextCursor.MoveOperation.Start)
217 self.contents.setTextCursor(tc) 223 self.contents.setTextCursor(tc)
218 self.contents.ensureCursorVisible() 224 self.contents.ensureCursorVisible()
219 225
220 self.filesCombo.addItem(self.tr("<Start>"), 0) 226 self.filesCombo.addItem(self.tr("<Start>"), 0)
221 self.filesCombo.addItem(self.tr("<End>"), -1) 227 self.filesCombo.addItem(self.tr("<End>"), -1)
231 Private method to append text to the end of the contents pane. 237 Private method to append text to the end of the contents pane.
232 238
233 @param txt text to insert (string) 239 @param txt text to insert (string)
234 """ 240 """
235 tc = self.contents.textCursor() 241 tc = self.contents.textCursor()
236 tc.movePosition(QTextCursor.End) 242 tc.movePosition(QTextCursor.MoveOperation.End)
237 self.contents.setTextCursor(tc) 243 self.contents.setTextCursor(tc)
238 self.contents.insertPlainText(txt) 244 self.contents.insertPlainText(txt)
239 245
240 def __extractFileName(self, line): 246 def __extractFileName(self, line):
241 """ 247 """
267 Private slot to handle the readyReadStandardOutput signal. 273 Private slot to handle the readyReadStandardOutput signal.
268 274
269 It reads the output of the process, formats it and inserts it into 275 It reads the output of the process, formats it and inserts it into
270 the contents pane. 276 the contents pane.
271 """ 277 """
272 self.process.setReadChannel(QProcess.StandardOutput) 278 self.process.setReadChannel(QProcess.ProcessChannel.StandardOutput)
273 279
274 while self.process.canReadLine(): 280 while self.process.canReadLine():
275 line = str(self.process.readLine(), 281 line = str(self.process.readLine(),
276 Preferences.getSystem("IOEncoding"), 282 Preferences.getSystem("IOEncoding"),
277 'replace') 283 'replace')
303 """ 309 """
304 Private slot called by a button of the button box clicked. 310 Private slot called by a button of the button box clicked.
305 311
306 @param button button that was clicked (QAbstractButton) 312 @param button button that was clicked (QAbstractButton)
307 """ 313 """
308 if button == self.buttonBox.button(QDialogButtonBox.Save): 314 if button == self.buttonBox.button(
315 QDialogButtonBox.StandardButton.Save
316 ):
309 self.on_saveButton_clicked() 317 self.on_saveButton_clicked()
310 elif button == self.refreshButton: 318 elif button == self.refreshButton:
311 self.on_refreshButton_clicked() 319 self.on_refreshButton_clicked()
312 320
313 @pyqtSlot(int) 321 @pyqtSlot(int)
319 """ 327 """
320 para = self.filesCombo.itemData(index) 328 para = self.filesCombo.itemData(index)
321 329
322 if para == 0: 330 if para == 0:
323 tc = self.contents.textCursor() 331 tc = self.contents.textCursor()
324 tc.movePosition(QTextCursor.Start) 332 tc.movePosition(QTextCursor.MoveOperation.Start)
325 self.contents.setTextCursor(tc) 333 self.contents.setTextCursor(tc)
326 self.contents.ensureCursorVisible() 334 self.contents.ensureCursorVisible()
327 elif para == -1: 335 elif para == -1:
328 tc = self.contents.textCursor() 336 tc = self.contents.textCursor()
329 tc.movePosition(QTextCursor.End) 337 tc.movePosition(QTextCursor.MoveOperation.End)
330 self.contents.setTextCursor(tc) 338 self.contents.setTextCursor(tc)
331 self.contents.ensureCursorVisible() 339 self.contents.ensureCursorVisible()
332 else: 340 else:
333 # step 1: move cursor to end 341 # step 1: move cursor to end
334 tc = self.contents.textCursor() 342 tc = self.contents.textCursor()
335 tc.movePosition(QTextCursor.End) 343 tc.movePosition(QTextCursor.MoveOperation.End)
336 self.contents.setTextCursor(tc) 344 self.contents.setTextCursor(tc)
337 self.contents.ensureCursorVisible() 345 self.contents.ensureCursorVisible()
338 346
339 # step 2: move cursor to desired line 347 # step 2: move cursor to desired line
340 tc = self.contents.textCursor() 348 tc = self.contents.textCursor()
341 delta = tc.blockNumber() - para 349 delta = tc.blockNumber() - para
342 tc.movePosition(QTextCursor.PreviousBlock, QTextCursor.MoveAnchor, 350 tc.movePosition(
343 delta) 351 QTextCursor.MoveOperation.PreviousBlock,
352 QTextCursor.MoveMode.MoveAnchor,
353 delta)
344 self.contents.setTextCursor(tc) 354 self.contents.setTextCursor(tc)
345 self.contents.ensureCursorVisible() 355 self.contents.ensureCursorVisible()
346 356
347 @pyqtSlot() 357 @pyqtSlot()
348 def on_saveButton_clicked(self): 358 def on_saveButton_clicked(self):
406 @pyqtSlot() 416 @pyqtSlot()
407 def on_refreshButton_clicked(self): 417 def on_refreshButton_clicked(self):
408 """ 418 """
409 Private slot to refresh the display. 419 Private slot to refresh the display.
410 """ 420 """
411 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 421 self.buttonBox.button(
412 422 QDialogButtonBox.StandardButton.Close).setEnabled(False)
413 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) 423
424 self.buttonBox.button(
425 QDialogButtonBox.StandardButton.Save).setEnabled(False)
414 self.refreshButton.setEnabled(False) 426 self.refreshButton.setEnabled(False)
415 427
416 self.start(self.filename, refreshable=True) 428 self.start(self.filename, refreshable=True)
417 429
418 def on_passwordCheckBox_toggled(self, isOn): 430 def on_passwordCheckBox_toggled(self, isOn):
420 Private slot to handle the password checkbox toggled. 432 Private slot to handle the password checkbox toggled.
421 433
422 @param isOn flag indicating the status of the check box (boolean) 434 @param isOn flag indicating the status of the check box (boolean)
423 """ 435 """
424 if isOn: 436 if isOn:
425 self.input.setEchoMode(QLineEdit.Password) 437 self.input.setEchoMode(QLineEdit.EchoMode.Password)
426 else: 438 else:
427 self.input.setEchoMode(QLineEdit.Normal) 439 self.input.setEchoMode(QLineEdit.EchoMode.Normal)
428 440
429 @pyqtSlot() 441 @pyqtSlot()
430 def on_sendButton_clicked(self): 442 def on_sendButton_clicked(self):
431 """ 443 """
432 Private slot to send the input to the subversion process. 444 Private slot to send the input to the subversion process.

eric ide

mercurial