IconEditor/IconEditorPalette.py

Mon, 25 Mar 2013 03:11:06 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Mon, 25 Mar 2013 03:11:06 +0100
branch
Py2 comp.
changeset 2525
8b507a9a2d40
parent 2302
f29e9405c851
child 3057
10516539f238
permissions
-rw-r--r--

Script changes: Future import added, super calls modified and unicode behavior for str.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
2302
f29e9405c851 Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
3 # Copyright (c) 2009 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a palette widget for the icon editor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
10 from __future__ import unicode_literals # __IGNORE_WARNING__
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
11
1112
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
12 from PyQt4.QtCore import pyqtSignal, Qt
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
13 from PyQt4.QtGui import QWidget, QColor, QPainter, QBoxLayout, QLabel, QFrame, \
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
14 QPushButton, QSpinBox, QGroupBox, QVBoxLayout, QRadioButton, QSpacerItem, \
8a7d1b9d18db Improved code quality by getting rid of star imports. That way pyflakes can do its job. A few bugs fixed found by flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 945
diff changeset
15 QSizePolicy, QPixmap, QColorDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
17
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class IconEditorPalette(QWidget):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 Class implementing a palette widget for the icon editor.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 @signal colorSelected(QColor) emitted after a new color has been selected
618
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
23 @signal compositingChanged(QPainter.CompositionMode) emitted to signal a change
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
24 of the compositing mode
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 464
diff changeset
26 colorSelected = pyqtSignal(QColor)
618
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
27 compositingChanged = pyqtSignal(QPainter.CompositionMode)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 464
diff changeset
28
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
29 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param parent reference to the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
35 super(IconEditorPalette, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 if self.layoutDirection == Qt.Horizontal:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 direction = QBoxLayout.LeftToRight
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 direction = QBoxLayout.TopToBottom
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__layout = QBoxLayout(direction, self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.setLayout(self.__layout)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.__preview = QLabel(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__preview.setFrameStyle(QFrame.Panel | QFrame.Sunken)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.__preview.setFixedHeight(64)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.__preview.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__preview.setWhatsThis(self.trUtf8(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """<b>Preview</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """<p>This is a 1:1 preview of the current icon.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 ))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.__layout.addWidget(self.__preview)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.__color = QLabel(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.__color.setFrameStyle(QFrame.Panel | QFrame.Sunken)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.__color.setFixedHeight(24)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 self.__color.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.__color.setWhatsThis(self.trUtf8(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """<b>Current Color</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """<p>This is the currently selected color used for drawing.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 ))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.__layout.addWidget(self.__color)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.__colorTxt = QLabel(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.__colorTxt.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__colorTxt.setWhatsThis(self.trUtf8(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """<b>Current Color Value</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """<p>This is the currently selected color value used for drawing.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 ))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.__layout.addWidget(self.__colorTxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__colorButton = QPushButton(self.trUtf8("Select Color"), self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.__colorButton.setWhatsThis(self.trUtf8(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """<b>Select Color</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """<p>Select the current drawing color via a color selection dialog.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 ))
464
a2b1d1770ef0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 414
diff changeset
77 self.__colorButton.clicked[()].connect(self.__selectColor)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.__layout.addWidget(self.__colorButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__colorAlpha = QSpinBox(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__colorAlpha.setRange(0, 255)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__colorAlpha.setWhatsThis(self.trUtf8(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 """<b>Select alpha channel value</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 """<p>Select the value for the alpha channel of the current color.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 ))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.__layout.addWidget(self.__colorAlpha)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 464
diff changeset
87 self.__colorAlpha.valueChanged[int].connect(self.__alphaChanged)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
618
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
89 self.__compositingGroup = QGroupBox(self.trUtf8("Compositing"), self)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
90 self.__compositingGroupLayout = QVBoxLayout(self.__compositingGroup)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
91 self.__compositingGroup.setLayout(self.__compositingGroupLayout)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
92 self.__sourceButton = QRadioButton(self.trUtf8("Replace"),
618
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
93 self.__compositingGroup)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
94 self.__sourceButton.setWhatsThis(self.trUtf8(
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
95 """<b>Replace</b>"""
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
96 """<p>Replace the existing pixel with a new color.</p>"""
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
97 ))
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
98 self.__sourceButton.clicked[bool].connect(self.__compositingChanged)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
99 self.__compositingGroupLayout.addWidget(self.__sourceButton)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
100 self.__sourceOverButton = QRadioButton(self.trUtf8("Blend"),
618
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
101 self.__compositingGroup)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
102 self.__sourceOverButton.setWhatsThis(self.trUtf8(
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
103 """<b>Blend</b>"""
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
104 """<p>Blend the new color over the existing pixel.</p>"""
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
105 ))
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
106 self.__sourceOverButton.setChecked(True)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
107 self.__sourceOverButton.clicked[bool].connect(self.__compositingChanged)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
108 self.__compositingGroupLayout.addWidget(self.__sourceOverButton)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
109 self.__layout.addWidget(self.__compositingGroup)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
110
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 spacer = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.__layout.addItem(spacer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 def previewChanged(self, pixmap):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 Public slot to update the preview.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.__preview.setPixmap(pixmap)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 def colorChanged(self, color):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 Public slot to update the color preview.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 self.__currentColor = color
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 self.__currentAlpha = color.alpha()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 pm = QPixmap(90, 18)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 pm.fill(color)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 self.__color.setPixmap(pm)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 self.__colorTxt.setText(
414
8c91e942d2da Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
132 "{0:d}, {1:d}, {2:d}, {3:d}".format(
8c91e942d2da Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
133 color.red(), color.green(), color.blue(), color.alpha()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.__colorAlpha.setValue(self.__currentAlpha)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 def __selectColor(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 Private slot to select a new drawing color.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 col = QColorDialog.getColor(self.__currentColor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 col.setAlpha(self.__currentAlpha)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 if col.isValid():
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 464
diff changeset
145 self.colorSelected.emit(col)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 def __alphaChanged(self, val):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 Private slot to track changes of the alpha channel.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 @param val value of the alpha channel
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 if val != self.__currentAlpha:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 826
diff changeset
154 col = QColor(self.__currentColor)
826
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
155 col.setAlpha(val)
2e3e2055e715 Fixed a few PEP 8 related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
156 self.colorSelected.emit(col)
618
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
157
619
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
158 def setCompositingMode(self, mode):
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
159 """
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
160 Public method to set the compositing mode.
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
161
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
162 @param mode compositing mode to set (QPainter.CompositionMode)
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
163 """
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
164 if mode == QPainter.CompositionMode_Source:
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
165 self.__sourceButton.setChecked(True)
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
166 elif mode == QPainter.CompositionMode_SourceOver:
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
167 self.__sourceOverButton.setChecked(True)
52f88b8fe8b2 Fixed a forgotten initialisation statement and supporting method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 618
diff changeset
168
618
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
169 def __compositingChanged(self, on):
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
170 """
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
171 Private slot to handle a change of the compositing mode.
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
172
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
173 @param on flag indicating the checked state of the compositing button (boolean)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
174 """
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
175 if on:
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
176 if self.__sourceButton.isChecked():
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
177 self.compositingChanged.emit(QPainter.CompositionMode_Source)
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
178 elif self.__sourceOverButton.isChecked():
42580bfc0777 Added use of compositing modes to the icon editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 495
diff changeset
179 self.compositingChanged.emit(QPainter.CompositionMode_SourceOver)

eric ide

mercurial