41 @param parent parent widget (QWidget) |
41 @param parent parent widget (QWidget) |
42 """ |
42 """ |
43 super(HgDiffDialog, self).__init__(parent) |
43 super(HgDiffDialog, self).__init__(parent) |
44 self.setupUi(self) |
44 self.setupUi(self) |
45 |
45 |
|
46 self.refreshButton = self.buttonBox.addButton( |
|
47 self.tr("Refresh"), QDialogButtonBox.ActionRole) |
|
48 self.refreshButton.setToolTip( |
|
49 self.tr("Press to refresh the display")) |
|
50 self.refreshButton.setEnabled(False) |
46 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) |
51 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) |
47 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
52 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
48 |
53 |
49 self.searchWidget.attachTextEdit(self.contents) |
54 self.searchWidget.attachTextEdit(self.contents) |
50 |
55 |
96 if version == "WORKING": |
101 if version == "WORKING": |
97 return None |
102 return None |
98 else: |
103 else: |
99 return str(version) |
104 return str(version) |
100 |
105 |
101 def start(self, fn, versions=None, bundle=None, qdiff=False): |
106 def start(self, fn, versions=None, bundle=None, qdiff=False, |
|
107 refreshable=False): |
102 """ |
108 """ |
103 Public slot to start the hg diff command. |
109 Public slot to start the hg diff command. |
104 |
110 |
105 @param fn filename to be diffed (string) |
111 @param fn filename to be diffed (string) |
106 @param versions list of versions to be diffed (list of up to 2 strings |
112 @keyparam versions list of versions to be diffed (list of up to |
107 or None) |
113 2 strings or None) |
108 @param bundle name of a bundle file (string) |
114 @keyparam bundle name of a bundle file (string) |
109 @param qdiff flag indicating qdiff command shall be used (boolean) |
115 @keyparam qdiff flag indicating qdiff command shall be used (boolean) |
110 """ |
116 @keyparam refreshable flag indicating a refreshable diff (boolean) |
|
117 """ |
|
118 self.refreshButton.setVisible(refreshable) |
|
119 |
111 self.errorGroup.hide() |
120 self.errorGroup.hide() |
112 self.inputGroup.show() |
121 self.inputGroup.show() |
|
122 self.inputGroup.setEnabled(True) |
113 self.intercept = False |
123 self.intercept = False |
114 self.filename = fn |
124 self.filename = fn |
115 |
125 |
116 self.contents.clear() |
126 self.contents.clear() |
117 self.paras = 0 |
127 self.paras = 0 |
220 the button. |
230 the button. |
221 """ |
231 """ |
222 QApplication.restoreOverrideCursor() |
232 QApplication.restoreOverrideCursor() |
223 self.inputGroup.setEnabled(False) |
233 self.inputGroup.setEnabled(False) |
224 self.inputGroup.hide() |
234 self.inputGroup.hide() |
|
235 self.refreshButton.setEnabled(True) |
225 |
236 |
226 if self.paras == 0: |
237 if self.paras == 0: |
227 self.contents.setCurrentCharFormat(self.cNormalFormat) |
238 self.contents.setCurrentCharFormat(self.cNormalFormat) |
228 self.contents.setPlainText( |
239 self.contents.setPlainText( |
229 self.tr('There is no difference.')) |
240 self.tr('There is no difference.')) |
230 |
241 |
231 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.paras > 0) |
242 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.paras > 0) |
|
243 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) |
232 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
244 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) |
233 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
245 self.buttonBox.button(QDialogButtonBox.Close).setFocus( |
234 Qt.OtherFocusReason) |
246 Qt.OtherFocusReason) |
235 |
247 |
236 tc = self.contents.textCursor() |
248 tc = self.contents.textCursor() |
349 |
361 |
350 @param button button that was clicked (QAbstractButton) |
362 @param button button that was clicked (QAbstractButton) |
351 """ |
363 """ |
352 if button == self.buttonBox.button(QDialogButtonBox.Save): |
364 if button == self.buttonBox.button(QDialogButtonBox.Save): |
353 self.on_saveButton_clicked() |
365 self.on_saveButton_clicked() |
|
366 elif button == self.refreshButton: |
|
367 self.on_refreshButton_clicked() |
354 |
368 |
355 @pyqtSlot(int) |
369 @pyqtSlot(int) |
356 def on_filesCombo_activated(self, index): |
370 def on_filesCombo_activated(self, index): |
357 """ |
371 """ |
358 Private slot to handle the selection of a file. |
372 Private slot to handle the selection of a file. |
444 self.tr( |
458 self.tr( |
445 '<p>The patch file <b>{0}</b> could not be saved.' |
459 '<p>The patch file <b>{0}</b> could not be saved.' |
446 '<br>Reason: {1}</p>') |
460 '<br>Reason: {1}</p>') |
447 .format(fname, str(why))) |
461 .format(fname, str(why))) |
448 |
462 |
|
463 @pyqtSlot() |
|
464 def on_refreshButton_clicked(self): |
|
465 """ |
|
466 Private slot to refresh the display. |
|
467 """ |
|
468 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) |
|
469 |
|
470 self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) |
|
471 self.refreshButton.setEnabled(False) |
|
472 |
|
473 self.start(self.filename, refreshable=True) |
|
474 |
449 def on_passwordCheckBox_toggled(self, isOn): |
475 def on_passwordCheckBox_toggled(self, isOn): |
450 """ |
476 """ |
451 Private slot to handle the password checkbox toggled. |
477 Private slot to handle the password checkbox toggled. |
452 |
478 |
453 @param isOn flag indicating the status of the check box (boolean) |
479 @param isOn flag indicating the status of the check box (boolean) |