IconEditor/IconEditorPalette.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 2992
dbdf27746da5
child 3145
a9de05d4a22f
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
8 """ 8 """
9 9
10 from __future__ import unicode_literals # __IGNORE_WARNING__ 10 from __future__ import unicode_literals # __IGNORE_WARNING__
11 11
12 from PyQt4.QtCore import pyqtSignal, Qt 12 from PyQt4.QtCore import pyqtSignal, Qt
13 from PyQt4.QtGui import QWidget, QColor, QPainter, QBoxLayout, QLabel, QFrame, \ 13 from PyQt4.QtGui import QWidget, QColor, QPainter, QBoxLayout, QLabel, \
14 QPushButton, QSpinBox, QGroupBox, QVBoxLayout, QRadioButton, QSpacerItem, \ 14 QFrame, QPushButton, QSpinBox, QGroupBox, QVBoxLayout, QRadioButton, \
15 QSizePolicy, QPixmap, QColorDialog 15 QSpacerItem, QSizePolicy, QPixmap, QColorDialog
16 16
17 17
18 class IconEditorPalette(QWidget): 18 class IconEditorPalette(QWidget):
19 """ 19 """
20 Class implementing a palette widget for the icon editor. 20 Class implementing a palette widget for the icon editor.
21 21
22 @signal colorSelected(QColor) emitted after a new color has been selected 22 @signal colorSelected(QColor) emitted after a new color has been selected
23 @signal compositingChanged(QPainter.CompositionMode) emitted to signal a change 23 @signal compositingChanged(QPainter.CompositionMode) emitted to signal a
24 of the compositing mode 24 change of the compositing mode
25 """ 25 """
26 colorSelected = pyqtSignal(QColor) 26 colorSelected = pyqtSignal(QColor)
27 compositingChanged = pyqtSignal(QPainter.CompositionMode) 27 compositingChanged = pyqtSignal(QPainter.CompositionMode)
28 28
29 def __init__(self, parent=None): 29 def __init__(self, parent=None):
63 63
64 self.__colorTxt = QLabel(self) 64 self.__colorTxt = QLabel(self)
65 self.__colorTxt.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) 65 self.__colorTxt.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
66 self.__colorTxt.setWhatsThis(self.trUtf8( 66 self.__colorTxt.setWhatsThis(self.trUtf8(
67 """<b>Current Color Value</b>""" 67 """<b>Current Color Value</b>"""
68 """<p>This is the currently selected color value used for drawing.</p>""" 68 """<p>This is the currently selected color value used for"""
69 """ drawing.</p>"""
69 )) 70 ))
70 self.__layout.addWidget(self.__colorTxt) 71 self.__layout.addWidget(self.__colorTxt)
71 72
72 self.__colorButton = QPushButton(self.trUtf8("Select Color"), self) 73 self.__colorButton = QPushButton(self.trUtf8("Select Color"), self)
73 self.__colorButton.setWhatsThis(self.trUtf8( 74 self.__colorButton.setWhatsThis(self.trUtf8(
74 """<b>Select Color</b>""" 75 """<b>Select Color</b>"""
75 """<p>Select the current drawing color via a color selection dialog.</p>""" 76 """<p>Select the current drawing color via a color selection"""
77 """ dialog.</p>"""
76 )) 78 ))
77 self.__colorButton.clicked[()].connect(self.__selectColor) 79 self.__colorButton.clicked[()].connect(self.__selectColor)
78 self.__layout.addWidget(self.__colorButton) 80 self.__layout.addWidget(self.__colorButton)
79 81
80 self.__colorAlpha = QSpinBox(self) 82 self.__colorAlpha = QSpinBox(self)
81 self.__colorAlpha.setRange(0, 255) 83 self.__colorAlpha.setRange(0, 255)
82 self.__colorAlpha.setWhatsThis(self.trUtf8( 84 self.__colorAlpha.setWhatsThis(self.trUtf8(
83 """<b>Select alpha channel value</b>""" 85 """<b>Select alpha channel value</b>"""
84 """<p>Select the value for the alpha channel of the current color.</p>""" 86 """<p>Select the value for the alpha channel of the current"""
87 """ color.</p>"""
85 )) 88 ))
86 self.__layout.addWidget(self.__colorAlpha) 89 self.__layout.addWidget(self.__colorAlpha)
87 self.__colorAlpha.valueChanged[int].connect(self.__alphaChanged) 90 self.__colorAlpha.valueChanged[int].connect(self.__alphaChanged)
88 91
89 self.__compositingGroup = QGroupBox(self.trUtf8("Compositing"), self) 92 self.__compositingGroup = QGroupBox(self.trUtf8("Compositing"), self)
102 self.__sourceOverButton.setWhatsThis(self.trUtf8( 105 self.__sourceOverButton.setWhatsThis(self.trUtf8(
103 """<b>Blend</b>""" 106 """<b>Blend</b>"""
104 """<p>Blend the new color over the existing pixel.</p>""" 107 """<p>Blend the new color over the existing pixel.</p>"""
105 )) 108 ))
106 self.__sourceOverButton.setChecked(True) 109 self.__sourceOverButton.setChecked(True)
107 self.__sourceOverButton.clicked[bool].connect(self.__compositingChanged) 110 self.__sourceOverButton.clicked[bool].connect(
111 self.__compositingChanged)
108 self.__compositingGroupLayout.addWidget(self.__sourceOverButton) 112 self.__compositingGroupLayout.addWidget(self.__sourceOverButton)
109 self.__layout.addWidget(self.__compositingGroup) 113 self.__layout.addWidget(self.__compositingGroup)
110 114
111 spacer = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) 115 spacer = QSpacerItem(
116 10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)
112 self.__layout.addItem(spacer) 117 self.__layout.addItem(spacer)
113 118
114 def previewChanged(self, pixmap): 119 def previewChanged(self, pixmap):
115 """ 120 """
116 Public slot to update the preview. 121 Public slot to update the preview.
122
123 @param pixmap new preview pixmap (QPixmap)
117 """ 124 """
118 self.__preview.setPixmap(pixmap) 125 self.__preview.setPixmap(pixmap)
119 126
120 def colorChanged(self, color): 127 def colorChanged(self, color):
121 """ 128 """
122 Public slot to update the color preview. 129 Public slot to update the color preview.
130
131 @param color new color (QColor)
123 """ 132 """
124 self.__currentColor = color 133 self.__currentColor = color
125 self.__currentAlpha = color.alpha() 134 self.__currentAlpha = color.alpha()
126 135
127 pm = QPixmap(90, 18) 136 pm = QPixmap(90, 18)
168 177
169 def __compositingChanged(self, on): 178 def __compositingChanged(self, on):
170 """ 179 """
171 Private slot to handle a change of the compositing mode. 180 Private slot to handle a change of the compositing mode.
172 181
173 @param on flag indicating the checked state of the compositing button (boolean) 182 @param on flag indicating the checked state of the compositing button
183 (boolean)
174 """ 184 """
175 if on: 185 if on:
176 if self.__sourceButton.isChecked(): 186 if self.__sourceButton.isChecked():
177 self.compositingChanged.emit(QPainter.CompositionMode_Source) 187 self.compositingChanged.emit(
188 QPainter.CompositionMode_Source)
178 elif self.__sourceOverButton.isChecked(): 189 elif self.__sourceOverButton.isChecked():
179 self.compositingChanged.emit(QPainter.CompositionMode_SourceOver) 190 self.compositingChanged.emit(
191 QPainter.CompositionMode_SourceOver)

eric ide

mercurial