122 il = indLevel + 1 |
122 il = indLevel + 1 |
123 istring = il * indString |
123 istring = il * indString |
124 estring = os.linesep + indLevel * indString |
124 estring = os.linesep + indLevel * indString |
125 |
125 |
126 # now generate the code |
126 # now generate the code |
127 code = 'QColorDialog.' |
127 if self.parentSelf.isChecked(): |
|
128 parent = "self" |
|
129 elif self.parentNone.isChecked(): |
|
130 parent = "None" |
|
131 elif self.parentOther.isChecked(): |
|
132 parent = self.parentEdit.text() |
|
133 if parent == "": |
|
134 parent = "None" |
|
135 |
|
136 resvar = self.eResultVar.text() |
|
137 if not resvar: |
|
138 resvar = "color" |
|
139 code = '{0} = QColorDialog.'.format(resvar) |
128 if self.rColor.isChecked(): |
140 if self.rColor.isChecked(): |
129 code += 'getColor(' |
141 code += 'getColor({0}'.format(os.linesep) |
130 if self.eColor.currentText(): |
142 if self.eColor.currentText(): |
131 col = self.eColor.currentText() |
143 col = self.eColor.currentText() |
132 if col.startswith('#'): |
144 if col.startswith('#'): |
133 code += 'QColor("{0}")'.format(col) |
145 code += '{0}QColor("{1}"),{2}'.format( |
|
146 istring, col, os.linesep) |
134 else: |
147 else: |
135 code += 'QColor({0})'.format(col) |
148 code += '{0}QColor({1}),{2}'.format( |
136 code += ', None,{0}'.format(os.linesep) |
149 istring, col, os.linesep) |
|
150 else: |
|
151 code += '{0}QColor(Qt.white),{1}'.format(istring, os.linesep) |
|
152 code += '{0}{1},{2}'.format(istring, parent, os.linesep) |
137 code += '{0}self.trUtf8("{1}"),{2}'.format( |
153 code += '{0}self.trUtf8("{1}"),{2}'.format( |
138 istring, self.eTitle.text(), os.linesep) |
154 istring, self.eTitle.text(), os.linesep) |
139 code += '{0}QColorDialog.ColorDialogOptions(' \ |
155 code += '{0}QColorDialog.ColorDialogOptions(' \ |
140 'QColorDialog.ShowAlphaChannel)'.format(istring) |
156 'QColorDialog.ShowAlphaChannel)'.format(istring) |
141 code += '){0}'.format(estring) |
157 code += '){0}'.format(estring) |
142 elif self.rRGBA.isChecked(): |
158 elif self.rRGBA.isChecked(): |
143 code += 'getColor(' |
159 code += 'getColor({0}'.format(os.linesep) |
144 if not self.eRGB.text(): |
160 if not self.eRGB.text(): |
145 code += 'QColor({0:d}, {1:d}, {2:d}, {3:d}),{4}'.format( |
161 code += '{0}QColor({1:d}, {2:d}, {3:d}, {4:d}),{5}'.format( |
146 self.sRed.value(), self.sGreen.value(), self.sBlue.value(), |
162 istring, self.sRed.value(), self.sGreen.value(), |
147 self.sAlpha.value(), os.linesep) |
163 self.sBlue.value(), self.sAlpha.value(), os.linesep) |
148 else: |
164 else: |
149 code += '{0},{1}'.format(self.eRGB.text(), os.linesep) |
165 code += '{0}{1},{2}'.format( |
150 code += '{0}None,{1}'.format(istring, os.linesep) |
166 istring, self.eRGB.text(), os.linesep) |
|
167 code += '{0}{1},{2}'.format(istring, parent, os.linesep) |
151 code += '{0}self.trUtf8("{1}"),{2}'.format( |
168 code += '{0}self.trUtf8("{1}"),{2}'.format( |
152 istring, self.eTitle.text(), os.linesep) |
169 istring, self.eTitle.text(), os.linesep) |
153 code += '{0}QColorDialog.ColorDialogOptions(' \ |
170 code += '{0}QColorDialog.ColorDialogOptions(' \ |
154 'QColorDialog.ShowAlphaChannel)'.format(istring) |
171 'QColorDialog.ShowAlphaChannel)'.format(istring) |
155 code += '){0}'.format(estring) |
172 code += '){0}'.format(estring) |