1
2
3
4 """ pyforms.gui.Controls.ControlEventTimeline.TimelinePopupWindow
5
6 """
7
8 from PyQt4 import uic
9 from PyQt4 import QtCore, QtGui
10 import pyforms.Utils.tools as tools
11
12
13
14
15 __author__ = ["Ricardo Ribeiro", "Hugo Cachitas"]
16 __credits__ = ["Ricardo Ribeiro", "Hugo Cachitas"]
17 __license__ = "MIT"
18 __version__ = "0.0"
19 __maintainer__ = "Ricardo Ribeiro"
20 __email__ = "ricardojvr@gmail.com"
21 __status__ = "Development"
22
23
25 """
26 Opens a dialog where the user can specify the behavior annotated
27 in the selected line, as well as some related options.
28
29 The parent timeline widget must be given, as well as the track
30 identifier to edit.
31 """
32
59
61 """Handles comboBox index change."""
62 cb = self._ui.comboBox
63 self.behavior = cb.itemText(cb.currentIndex())
64
66 """Add a behavior to the already existing ones."""
67 cb = self._ui.comboBox
68 text, ok = QtGui.QInputDialog.getText(
69 self, 'Add behavior', 'Description:', text='')
70 if ok:
71 self.behavior = str(text)
72 self.behaviors.append(self.behavior)
73 self._ui.comboBox.addItem(self.behavior)
74 cb.setCurrentIndex(cb.findText(self.behavior))
75
76
77
78 if not cb.isEnabled():
79 cb.removeItem(cb.findText(self._default_comboBox_text))
80 cb.setEnabled(True)
81
83 """Remove a behavior from the already existing ones."""
84 cb = self._ui.comboBox
85 i = cb.currentIndex()
86 self.behaviors.remove(str(cb.itemText(i)))
87 cb.removeItem(i)
88
89
90
91 if cb.count() < 1:
92 cb.addItem(self._default_comboBox_text)
93 cb.setEnabled(False)
94
99
101 """
102 Shows selected colors in two QLabel widgets.
103
104 The first shows true color, while the second presents the color
105 with an opacity as seen in the timeline and with some dummy text
106 to preview readability.
107 """
108 pixmap = QtGui.QPixmap(50, 25)
109 color = QtGui.QColor(*self.color.getRgb())
110
111
112 color.setAlpha(int(255 * 1.0))
113 pixmap.fill(color)
114 self._ui.label_color.setPixmap(pixmap)
115
116
117 color.setAlpha(int(255 * 0.5))
118 pixmap.fill(color)
119 painter = QtGui.QPainter(pixmap)
120 painter.setFont(QtGui.QFont('Decorative', 8))
121 painter.drawText(pixmap.rect(), QtCore.Qt.AlignCenter, "Text")
122 painter.end()
123 self._ui.label_color_alpha.setPixmap(pixmap)
124
126 """
127 Gets existing track labels already assigned.
128
129 Scans the timeline track labels and sets the comboBox value
130 accordingly.
131 """
132 d = self._parent._tracks_info
133 cb = self._ui.comboBox
134
135
136 for key, value in d.items():
137
138
139 if value[0] != self._parent._defaulttracklabel:
140 self.behavior = value[0]
141 if self.behavior not in self.behaviors:
142 cb.addItem(self.behavior)
143 self.behaviors.append(self.behavior)
144
145
146 if key == self.current_track:
147
148 cb.setCurrentIndex(cb.findText(self.behavior))
149
150
151
152 if cb.count() < 1:
153 cb.addItem(self._default_comboBox_text)
154 cb.setEnabled(False)
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196