diff -r 51ceecf32585 -r 39d8b26ff557 UI/CompareDialog.py --- a/UI/CompareDialog.py Fri Jun 23 18:46:40 2017 +0200 +++ b/UI/CompareDialog.py Sat Jun 24 12:15:03 2017 +0200 @@ -18,7 +18,7 @@ from difflib import _mdiff, IS_CHARACTER_JUNK from PyQt5.QtCore import QTimer, QEvent, pyqtSlot -from PyQt5.QtGui import QColor, QFontMetrics, QBrush, QTextCursor +from PyQt5.QtGui import QFontMetrics, QBrush, QTextCursor from PyQt5.QtWidgets import QWidget, QApplication, QDialogButtonBox from E5Gui import E5MessageBox @@ -133,20 +133,7 @@ self.on_synchronizeCheckBox_toggled(True) - font = Preferences.getEditorOtherFonts("MonospacedFont") - self.contents_1.setFontFamily(font.family()) - self.contents_1.setFontPointSize(font.pointSize()) - self.contents_2.setFontFamily(font.family()) - self.contents_2.setFontPointSize(font.pointSize()) - self.fontHeight = QFontMetrics(self.contents_1.currentFont()).height() - - self.cNormalFormat = self.contents_1.currentCharFormat() - self.cInsertedFormat = self.contents_1.currentCharFormat() - self.cInsertedFormat.setBackground(QBrush(QColor(190, 237, 190))) - self.cDeletedFormat = self.contents_1.currentCharFormat() - self.cDeletedFormat.setBackground(QBrush(QColor(237, 190, 190))) - self.cReplacedFormat = self.contents_1.currentCharFormat() - self.cReplacedFormat.setBackground(QBrush(QColor(190, 190, 237))) + self.__generateFormats() # connect some of our widgets explicitly self.file1Picker.textChanged.connect(self.__fileChanged) @@ -171,7 +158,29 @@ else: self.file1Label.hide() self.file2Label.hide() - + + def __generateFormats(self): + """ + Private method to generate the various text formats. + """ + font = Preferences.getEditorOtherFonts("MonospacedFont") + self.contents_1.setFontFamily(font.family()) + self.contents_1.setFontPointSize(font.pointSize()) + self.contents_2.setFontFamily(font.family()) + self.contents_2.setFontPointSize(font.pointSize()) + self.fontHeight = QFontMetrics(self.contents_1.currentFont()).height() + + self.cNormalFormat = self.contents_1.currentCharFormat() + self.cInsertedFormat = self.contents_1.currentCharFormat() + self.cInsertedFormat.setBackground( + QBrush(Preferences.getDiffColour("AddedColor"))) + self.cDeletedFormat = self.contents_1.currentCharFormat() + self.cDeletedFormat.setBackground( + QBrush(Preferences.getDiffColour("RemovedColor"))) + self.cReplacedFormat = self.contents_1.currentCharFormat() + self.cReplacedFormat.setBackground( + QBrush(Preferences.getDiffColour("ReplacedColor"))) + def show(self, filename=None): """ Public slot to show the dialog. @@ -296,6 +305,8 @@ self.contents_1.clear() self.contents_2.clear() + self.__generateFormats() + # counters for changes added = 0 deleted = 0