13 |
13 |
14 from PyQt6.QtCore import QTimer, QEvent, pyqtSlot |
14 from PyQt6.QtCore import QTimer, QEvent, pyqtSlot |
15 from PyQt6.QtGui import QFontMetrics, QBrush, QTextCursor |
15 from PyQt6.QtGui import QFontMetrics, QBrush, QTextCursor |
16 from PyQt6.QtWidgets import QWidget, QApplication, QDialogButtonBox |
16 from PyQt6.QtWidgets import QWidget, QApplication, QDialogButtonBox |
17 |
17 |
18 from E5Gui import E5MessageBox |
18 from E5Gui import EricMessageBox |
19 from E5Gui.E5MainWindow import E5MainWindow |
19 from E5Gui.EricMainWindow import EricMainWindow |
20 from E5Gui.E5PathPicker import E5PathPickerModes |
20 from E5Gui.EricPathPicker import EricPathPickerModes |
21 |
21 |
22 import UI.PixmapCache |
22 import UI.PixmapCache |
23 |
23 |
24 from .Ui_CompareDialog import Ui_CompareDialog |
24 from .Ui_CompareDialog import Ui_CompareDialog |
25 |
25 |
99 self.setupUi(self) |
99 self.setupUi(self) |
100 |
100 |
101 if files is None: |
101 if files is None: |
102 files = [] |
102 files = [] |
103 |
103 |
104 self.file1Picker.setMode(E5PathPickerModes.OPEN_FILE_MODE) |
104 self.file1Picker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
105 self.file2Picker.setMode(E5PathPickerModes.OPEN_FILE_MODE) |
105 self.file2Picker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
106 |
106 |
107 self.diffButton = self.buttonBox.addButton( |
107 self.diffButton = self.buttonBox.addButton( |
108 self.tr("Compare"), QDialogButtonBox.ButtonRole.ActionRole) |
108 self.tr("Compare"), QDialogButtonBox.ButtonRole.ActionRole) |
109 self.diffButton.setToolTip( |
109 self.diffButton.setToolTip( |
110 self.tr("Press to perform the comparison of the two files")) |
110 self.tr("Press to perform the comparison of the two files")) |
239 filename1 = self.file1Picker.text() |
239 filename1 = self.file1Picker.text() |
240 try: |
240 try: |
241 with open(filename1, "r", encoding="utf-8") as f1: |
241 with open(filename1, "r", encoding="utf-8") as f1: |
242 lines1 = f1.readlines() |
242 lines1 = f1.readlines() |
243 except OSError: |
243 except OSError: |
244 E5MessageBox.critical( |
244 EricMessageBox.critical( |
245 self, |
245 self, |
246 self.tr("Compare Files"), |
246 self.tr("Compare Files"), |
247 self.tr( |
247 self.tr( |
248 """<p>The file <b>{0}</b> could not be read.</p>""") |
248 """<p>The file <b>{0}</b> could not be read.</p>""") |
249 .format(filename1)) |
249 .format(filename1)) |
252 filename2 = self.file2Picker.text() |
252 filename2 = self.file2Picker.text() |
253 try: |
253 try: |
254 with open(filename2, "r", encoding="utf-8") as f2: |
254 with open(filename2, "r", encoding="utf-8") as f2: |
255 lines2 = f2.readlines() |
255 lines2 = f2.readlines() |
256 except OSError: |
256 except OSError: |
257 E5MessageBox.critical( |
257 EricMessageBox.critical( |
258 self, |
258 self, |
259 self.tr("Compare Files"), |
259 self.tr("Compare Files"), |
260 self.tr( |
260 self.tr( |
261 """<p>The file <b>{0}</b> could not be read.</p>""") |
261 """<p>The file <b>{0}</b> could not be read.</p>""") |
262 .format(filename2)) |
262 .format(filename2)) |
456 else: |
456 else: |
457 self.hsb1.valueChanged.disconnect(self.hsb2.setValue) |
457 self.hsb1.valueChanged.disconnect(self.hsb2.setValue) |
458 self.hsb2.valueChanged.disconnect(self.hsb1.setValue) |
458 self.hsb2.valueChanged.disconnect(self.hsb1.setValue) |
459 |
459 |
460 |
460 |
461 class CompareWindow(E5MainWindow): |
461 class CompareWindow(EricMainWindow): |
462 """ |
462 """ |
463 Main window class for the standalone dialog. |
463 Main window class for the standalone dialog. |
464 """ |
464 """ |
465 def __init__(self, files=None, parent=None): |
465 def __init__(self, files=None, parent=None): |
466 """ |
466 """ |