6 """ |
6 """ |
7 Module implementing the Diff colours configuration page. |
7 Module implementing the Diff colours configuration page. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import pyqtSlot |
10 from PyQt6.QtCore import pyqtSlot |
11 from PyQt6.QtGui import QPalette |
|
12 from PyQt6.QtWidgets import QColorDialog |
11 from PyQt6.QtWidgets import QColorDialog |
13 |
12 |
14 from .ConfigurationPageBase import ConfigurationPageBase |
13 from .ConfigurationPageBase import ConfigurationPageBase |
15 from .Ui_DiffColoursPage import Ui_DiffColoursPage |
14 from .Ui_DiffColoursPage import Ui_DiffColoursPage |
16 |
15 |
31 |
30 |
32 self.__coloursDict = {} |
31 self.__coloursDict = {} |
33 |
32 |
34 monospacedFont = Preferences.getEditorOtherFonts("MonospacedFont") |
33 monospacedFont = Preferences.getEditorOtherFonts("MonospacedFont") |
35 self.__allSamples = ( |
34 self.__allSamples = ( |
36 self.textSample, self.addedSample, self.removedSample, |
35 self.textSample, |
37 self.replacedSample, self.contextSample, self.headerSample, |
36 self.addedSample, |
38 self.whitespaceSample) |
37 self.removedSample, |
|
38 self.replacedSample, |
|
39 self.contextSample, |
|
40 self.headerSample, |
|
41 self.whitespaceSample |
|
42 ) |
39 for sample in self.__allSamples: |
43 for sample in self.__allSamples: |
40 sample.setFont(monospacedFont) |
44 sample.setFont(monospacedFont) |
41 |
45 |
42 # set initial values |
46 # set initial values |
43 self.__initColour( |
47 self.__initColour( |
152 |
156 |
153 @param colourKey key of the diff colour |
157 @param colourKey key of the diff colour |
154 @type str |
158 @type str |
155 """ |
159 """ |
156 colour = self.__coloursDict[colourKey][0] |
160 colour = self.__coloursDict[colourKey][0] |
157 for sample in self.__allSamples: |
161 for key in self.__coloursDict: |
158 pl = sample.palette() |
162 if key == "TextColor": |
159 pl.setColor(QPalette.ColorRole.Text, colour) |
163 self.__coloursDict[key][1].setStyleSheet( |
160 sample.setPalette(pl) |
164 "QLineEdit {{ color: {0}; }}".format(colour.name()) |
161 sample.repaint() |
165 ) |
|
166 else: |
|
167 self.__coloursDict[key][1].setStyleSheet( |
|
168 "QLineEdit {{ color: {0}; background-color: {1}; }}" |
|
169 .format(colour.name(), self.__coloursDict[key][0].name()) |
|
170 ) |
162 |
171 |
163 def __updateSampleBackgroundColour(self, colourKey): |
172 def __updateSampleBackgroundColour(self, colourKey): |
164 """ |
173 """ |
165 Private slot to update the background colour of a sample. |
174 Private slot to update the background colour of a sample. |
166 |
175 |
168 @type str |
177 @type str |
169 """ |
178 """ |
170 sample = self.__coloursDict[colourKey][1] |
179 sample = self.__coloursDict[colourKey][1] |
171 if sample: |
180 if sample: |
172 colour = self.__coloursDict[colourKey][0] |
181 colour = self.__coloursDict[colourKey][0] |
173 pl = sample.palette() |
182 sample.setStyleSheet( |
174 pl.setColor(QPalette.ColorRole.Base, colour) |
183 "QLineEdit {{ color: {0}; background-color: {1}; }}" |
175 sample.setPalette(pl) |
184 .format(self.__coloursDict["TextColor"][0].name(), |
176 sample.repaint() |
185 colour.name()) |
|
186 ) |
177 |
187 |
178 |
188 |
179 def create(dlg): |
189 def create(dlg): |
180 """ |
190 """ |
181 Module function to create the configuration page. |
191 Module function to create the configuration page. |