Fixed QColor reduce function.
Fixes bug #989. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
57b291fe66
commit
2487a08062
1 changed files with 11 additions and 10 deletions
|
|
@ -1165,42 +1165,43 @@
|
||||||
<insert-template name="qcolor_repr" />
|
<insert-template name="qcolor_repr" />
|
||||||
</inject-code>
|
</inject-code>
|
||||||
</add-function>
|
</add-function>
|
||||||
|
<add-function signature="__setstate__(PyObject*)" return-type="PyObject">
|
||||||
|
<inject-code>
|
||||||
|
Shiboken::AutoDecRef func(PyObject_GetAttr(%PYSELF, PyTuple_GET_ITEM(%1, 0)));
|
||||||
|
PyObject* args = PyTuple_GET_ITEM(%1, 1);
|
||||||
|
%PYARG_0 = PyObject_Call(func, args, NULL);
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
<add-function signature="__reduce__" return-type="PyObject">
|
<add-function signature="__reduce__" return-type="PyObject">
|
||||||
<inject-code class="target" position="beginning">
|
<inject-code class="target" position="beginning">
|
||||||
PyObject *createFunction = 0;
|
|
||||||
|
|
||||||
switch(%CPPSELF.spec()) {
|
switch(%CPPSELF.spec()) {
|
||||||
case QColor::Rgb:
|
case QColor::Rgb:
|
||||||
{
|
{
|
||||||
qreal r, g, b, a;
|
qreal r, g, b, a;
|
||||||
createFunction = PyObject_GetAttrString(%PYSELF, "fromRgbF");
|
|
||||||
%CPPSELF.getRgbF(&r, &g, &b, &a);
|
%CPPSELF.getRgbF(&r, &g, &b, &a);
|
||||||
%PYARG_0 = Py_BuildValue("(N(ffff))", createFunction, r, g, b, a);
|
%PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setRgbF", (float)r, (float)g, (float)b, (float)a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QColor::Hsv:
|
case QColor::Hsv:
|
||||||
{
|
{
|
||||||
qreal h, s, v, a;
|
qreal h, s, v, a;
|
||||||
createFunction = PyObject_GetAttrString(%PYSELF, "fromHsvF");
|
|
||||||
%CPPSELF.getHsvF(&h, &s, &v, &a);
|
%CPPSELF.getHsvF(&h, &s, &v, &a);
|
||||||
%PYARG_0 = Py_BuildValue("(N(ffff))", createFunction, h, s, v, a);
|
%PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setHsvF", (float)h, (float)s, (float)v, (float)a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QColor::Cmyk:
|
case QColor::Cmyk:
|
||||||
{
|
{
|
||||||
qreal c, m, y, k, a;
|
qreal c, m, y, k, a;
|
||||||
createFunction = PyObject_GetAttrString(%PYSELF, "fromCmykF");
|
|
||||||
%CPPSELF.getCmykF(&c, &m, &y, &k, &a);
|
%CPPSELF.getCmykF(&c, &m, &y, &k, &a);
|
||||||
%PYARG_0 = Py_BuildValue("(N(fffff))", createFunction, c, m, y, k, a);
|
%PYARG_0 = Py_BuildValue("(ON(s(fffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setCmykF", (float)c, (float)m, (float)y, (float)k, (float)a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if QT_VERSION >= 0x040600
|
#if QT_VERSION >= 0x040600
|
||||||
case QColor::Hsl:
|
case QColor::Hsl:
|
||||||
{
|
{
|
||||||
qreal h, s, l, a;
|
qreal h, s, l, a;
|
||||||
createFunction = PyObject_GetAttrString(%PYSELF, "fromHslF");
|
|
||||||
%CPPSELF.getHslF(&h, &s, &l, &a);
|
%CPPSELF.getHslF(&h, &s, &l, &a);
|
||||||
%PYARG_0 = Py_BuildValue("(N(ffff))", createFunction, h, s, l, a);
|
%PYARG_0 = Py_BuildValue("(ON(s(ffff)))", Py_TYPE(%PYSELF), PyTuple_New(0), "setHslF", (float)h, (float)s, (float)l, (float)a);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue