--- a/src/eric7/UI/DiffDialog.py Sat Nov 11 10:13:29 2023 +0100 +++ b/src/eric7/UI/DiffDialog.py Sat Nov 11 12:44:51 2023 +0100 @@ -14,7 +14,7 @@ from difflib import context_diff, unified_diff -from PyQt6.QtCore import QEvent, pyqtSlot +from PyQt6.QtCore import QEvent, QTimer, pyqtSlot from PyQt6.QtGui import QTextCursor from PyQt6.QtWidgets import QApplication, QDialogButtonBox, QWidget @@ -33,11 +33,14 @@ Class implementing a dialog to compare two files. """ - def __init__(self, parent=None): + def __init__(self, files=None, parent=None): """ Constructor - @param parent reference to the parent widget (QWidget) + @param files list of two file names to be diffed + @type list of two str + @param parent reference to the parent widget + @type QWidget """ super().__init__(parent) self.setupUi(self) @@ -75,6 +78,11 @@ self.file1Picker.textChanged.connect(self.__fileChanged) self.file2Picker.textChanged.connect(self.__fileChanged) + if len(files) == 2: + self.file1Picker.setText(files[0]) + self.file2Picker.setText(files[1]) + QTimer.singleShot(0, self.on_diffButton_clicked) + def show(self, filename=None): """ Public slot to show the dialog. @@ -281,17 +289,20 @@ Main window class for the standalone dialog. """ - def __init__(self, parent=None): + def __init__(self, files=None, parent=None): """ Constructor - @param parent reference to the parent widget (QWidget) + @param files list of two file names to be diffed + @type list of two str + @param parent reference to the parent widget + @type QWidget """ super().__init__(parent) self.setStyle(Preferences.getUI("Style"), Preferences.getUI("StyleSheet")) - self.cw = DiffDialog(self) + self.cw = DiffDialog(files=files, parent=self) self.cw.installEventFilter(self) size = self.cw.size() self.setCentralWidget(self.cw)