diff options
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 38646d2b1..48e0a3064 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -1100,11 +1100,62 @@ <include file-name="QPixmap" location="global"/> </extra-includes> </value-type> + + <template name="qcolor_repr"> + switch(%CPPSELF.spec()) { + case QColor::Rgb: + { + qreal r, g, b, a; + %CPPSELF.getRgbF(&r, &g, &b, &a); + QString repr = QString().sprintf("PySide.QtGui.QColor.fromRgbF(%.6f, %.6f, %.6f, %.6f)", r, g, b, a); + %PYARG_0 = PyString_FromString(qPrintable(repr)); + break; + } + case QColor::Hsv: + { + qreal h, s, v, a; + %CPPSELF.getHsvF(&h, &s, &v, &a); + QString repr = QString().sprintf("PySide.QtGui.QColor.fromHsvF(%.6f, %.6f, %.6f, %.6f)", h, s, v, a); + %PYARG_0 = PyString_FromString(qPrintable(repr)); + break; + } + case QColor::Cmyk: + { + qreal c, m, y, k, a; + %CPPSELF.getCmykF(&c, &m, &y, &k, &a); + QString repr = QString().sprintf("PySide.QtGui.QColor.fromCmykF(%.6f, %.6f, %.6f, %.6f, %.6f)", c, m, y, k, a); + %PYARG_0 = PyString_FromString(qPrintable(repr)); + break; + } + #if QT_VERSION >= 0x040600 + case QColor::Hsl: + { + qreal h, s, l, a; + %CPPSELF.getHsvF(&h, &s, &l, &a); + QString repr = QString().sprintf("PySide.QtGui.QColor.fromHslF(%.6f, %.6f, %.6f, %.6f)", h, s, l, a); + %PYARG_0 = PyString_FromString(qPrintable(repr)); + break; + } + #endif + default: + %PYARG_0 = 0; + } + </template> <value-type name="QColor"> <enum-type name="Spec"/> <extra-includes> <include file-name="QVariant" location="global"/> </extra-includes> + <add-function signature="__repr__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="qcolor_repr" /> + </inject-code> + </add-function> + <add-function signature="__str__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="qcolor_repr" /> + </inject-code> + </add-function> <add-function signature="__reduce__" return-type="PyObject*"> <inject-code class="target" position="beginning"> PyObject *createFunction = 0; |