Preferences/ConfigurationPages/DiffColoursPage.py

changeset 6116
f3d3c996c193
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
equal deleted inserted replaced
6115:ac3a98f3ebc2 6116:f3d3c996c193
40 self.whitespaceSample) 40 self.whitespaceSample)
41 for sample in self.__allSamples: 41 for sample in self.__allSamples:
42 sample.setFont(monospacedFont) 42 sample.setFont(monospacedFont)
43 43
44 # set initial values 44 # set initial values
45 self.__initColour("TextColor", self.textButton, 45 self.__initColour(
46 self.__updateSampleTextColour, 46 "TextColor",
47 self.__selectTextColour, self.textSample) 47 self.textButton,
48 self.__initColour("AddedColor", self.addedButton, 48 self.__updateSampleTextColour,
49 self.__updateSampleBackgroundColour, 49 lambda: self.__selectTextColour(self.textButton),
50 self.__selectBackgroundColour, self.addedSample) 50 self.textSample)
51 self.__initColour("RemovedColor", self.removedButton, 51 self.__initColour(
52 self.__updateSampleBackgroundColour, 52 "AddedColor",
53 self.__selectBackgroundColour, self.removedSample) 53 self.addedButton,
54 self.__initColour("ReplacedColor", self.replacedButton, 54 self.__updateSampleBackgroundColour,
55 self.__updateSampleBackgroundColour, 55 lambda: self.__selectBackgroundColour(self.addedButton),
56 self.__selectBackgroundColour, self.replacedSample) 56 self.addedSample)
57 self.__initColour("ContextColor", self.contextButton, 57 self.__initColour(
58 self.__updateSampleBackgroundColour, 58 "RemovedColor",
59 self.__selectBackgroundColour, self.contextSample) 59 self.removedButton,
60 self.__initColour("HeaderColor", self.headerButton, 60 self.__updateSampleBackgroundColour,
61 self.__updateSampleBackgroundColour, 61 lambda: self.__selectBackgroundColour(self.removedButton),
62 self.__selectBackgroundColour, self.headerSample) 62 self.removedSample)
63 self.__initColour("BadWhitespaceColor", self.whitespaceButton, 63 self.__initColour(
64 self.__updateSampleBackgroundColour, 64 "ReplacedColor",
65 self.__selectBackgroundColour, self.whitespaceSample) 65 self.replacedButton,
66 self.__updateSampleBackgroundColour,
67 lambda: self.__selectBackgroundColour(self.replacedButton),
68 self.replacedSample)
69 self.__initColour(
70 "ContextColor",
71 self.contextButton,
72 self.__updateSampleBackgroundColour,
73 lambda: self.__selectBackgroundColour(self.contextButton),
74 self.contextSample)
75 self.__initColour(
76 "HeaderColor",
77 self.headerButton,
78 self.__updateSampleBackgroundColour,
79 lambda: self.__selectBackgroundColour(self.headerButton),
80 self.headerSample)
81 self.__initColour(
82 "BadWhitespaceColor",
83 self.whitespaceButton,
84 self.__updateSampleBackgroundColour,
85 lambda: self.__selectBackgroundColour(self.whitespaceButton),
86 self.whitespaceSample)
66 87
67 def save(self): 88 def save(self):
68 """ 89 """
69 Public slot to save the Diff colours configuration. 90 Public slot to save the Diff colours configuration.
70 """ 91 """
93 self.__coloursDict[colourKey] = [colour, sampleWidget] 114 self.__coloursDict[colourKey] = [colour, sampleWidget]
94 if initSlot: 115 if initSlot:
95 initSlot(colourKey) 116 initSlot(colourKey)
96 117
97 @pyqtSlot() 118 @pyqtSlot()
98 def __selectTextColour(self): 119 def __selectTextColour(self, button):
99 """ 120 """
100 Private slot to select the text colour. 121 Private slot to select the text colour.
122
123 @param button reference to the button been pressed
124 @type QPushButton
101 """ 125 """
102 button = self.sender()
103 colorKey = button.property("colorKey") 126 colorKey = button.property("colorKey")
104 127
105 colour = QColorDialog.getColor(self.__coloursDict[colorKey][0], self) 128 colour = QColorDialog.getColor(self.__coloursDict[colorKey][0], self)
106 if colour.isValid(): 129 if colour.isValid():
107 self.__coloursDict[colorKey][0] = colour 130 self.__coloursDict[colorKey][0] = colour
108 self.__updateSampleTextColour(colorKey) 131 self.__updateSampleTextColour(colorKey)
109 132
110 @pyqtSlot() 133 @pyqtSlot()
111 def __selectBackgroundColour(self): 134 def __selectBackgroundColour(self, button):
112 """ 135 """
113 Private slot to select a background colour. 136 Private slot to select a background colour.
137
138 @param button reference to the button been pressed
139 @type QPushButton
114 """ 140 """
115 button = self.sender()
116 colorKey = button.property("colorKey") 141 colorKey = button.property("colorKey")
117 142
118 colour = QColorDialog.getColor(self.__coloursDict[colorKey][0], self, 143 colour = QColorDialog.getColor(self.__coloursDict[colorKey][0], self,
119 "", QColorDialog.ShowAlphaChannel) 144 "", QColorDialog.ShowAlphaChannel)
120 if colour.isValid(): 145 if colour.isValid():

eric ide

mercurial