13 class IconEditorPalette(QWidget): |
13 class IconEditorPalette(QWidget): |
14 """ |
14 """ |
15 Class implementing a palette widget for the icon editor. |
15 Class implementing a palette widget for the icon editor. |
16 |
16 |
17 @signal colorSelected(QColor) emitted after a new color has been selected |
17 @signal colorSelected(QColor) emitted after a new color has been selected |
|
18 @signal compositingChanged(QPainter.CompositionMode) emitted to signal a change |
|
19 of the compositing mode |
18 """ |
20 """ |
19 colorSelected = pyqtSignal(QColor) |
21 colorSelected = pyqtSignal(QColor) |
|
22 compositingChanged = pyqtSignal(QPainter.CompositionMode) |
20 |
23 |
21 def __init__(self, parent = None): |
24 def __init__(self, parent = None): |
22 """ |
25 """ |
23 Constructor |
26 Constructor |
24 |
27 |
76 """<p>Select the value for the alpha channel of the current color.</p>""" |
79 """<p>Select the value for the alpha channel of the current color.</p>""" |
77 )) |
80 )) |
78 self.__layout.addWidget(self.__colorAlpha) |
81 self.__layout.addWidget(self.__colorAlpha) |
79 self.__colorAlpha.valueChanged[int].connect(self.__alphaChanged) |
82 self.__colorAlpha.valueChanged[int].connect(self.__alphaChanged) |
80 |
83 |
|
84 self.__compositingGroup = QGroupBox(self.trUtf8("Compositing"), self) |
|
85 self.__compositingGroupLayout = QVBoxLayout(self.__compositingGroup) |
|
86 self.__compositingGroup.setLayout(self.__compositingGroupLayout) |
|
87 self.__sourceButton = QRadioButton(self.trUtf8("Replace"), |
|
88 self.__compositingGroup) |
|
89 self.__sourceButton.setWhatsThis(self.trUtf8( |
|
90 """<b>Replace</b>""" |
|
91 """<p>Replace the existing pixel with a new color.</p>""" |
|
92 )) |
|
93 self.__sourceButton.clicked[bool].connect(self.__compositingChanged) |
|
94 self.__compositingGroupLayout.addWidget(self.__sourceButton) |
|
95 self.__sourceOverButton = QRadioButton(self.trUtf8("Blend"), |
|
96 self.__compositingGroup) |
|
97 self.__sourceOverButton.setWhatsThis(self.trUtf8( |
|
98 """<b>Blend</b>""" |
|
99 """<p>Blend the new color over the existing pixel.</p>""" |
|
100 )) |
|
101 self.__sourceOverButton.setChecked(True) |
|
102 self.__sourceOverButton.clicked[bool].connect(self.__compositingChanged) |
|
103 self.__compositingGroupLayout.addWidget(self.__sourceOverButton) |
|
104 self.__layout.addWidget(self.__compositingGroup) |
|
105 |
81 spacer = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) |
106 spacer = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) |
82 self.__layout.addItem(spacer) |
107 self.__layout.addItem(spacer) |
83 |
108 |
84 def previewChanged(self, pixmap): |
109 def previewChanged(self, pixmap): |
85 """ |
110 """ |
122 """ |
147 """ |
123 if val != self.__currentAlpha: |
148 if val != self.__currentAlpha: |
124 col = QColor(self.__currentColor) |
149 col = QColor(self.__currentColor) |
125 col.setAlpha(val) |
150 col.setAlpha(val) |
126 self.colorSelected.emit(col) |
151 self.colorSelected.emit(col) |
|
152 |
|
153 def __compositingChanged(self, on): |
|
154 """ |
|
155 Private slot to handle a change of the compositing mode. |
|
156 |
|
157 @param on flag indicating the checked state of the compositing button (boolean) |
|
158 """ |
|
159 if on: |
|
160 if self.__sourceButton.isChecked(): |
|
161 self.compositingChanged.emit(QPainter.CompositionMode_Source) |
|
162 elif self.__sourceOverButton.isChecked(): |
|
163 self.compositingChanged.emit(QPainter.CompositionMode_SourceOver) |