slideShowEngine::AnimationState slideShowEngine::applyAnimation()
{
effect e;
QEasingCurve curve;
qreal currentValue;
Pixmap *item;

    if(m_currentStep==EnterAnimation)
        e=m_currentNode.enterEffect();
    else
        if(m_currentStep==DisplayAnimation)
            e=m_currentNode.displayEffect();
        else
            if(m_currentStep==ExitAnimation)
                e=m_currentNode.exitEffect();

    int duration=e.duration();
    //int elapsed=m_stepCurrentTime;
    curve.setPeriod(duration);
    qreal startVal=qreal(e.startValue());
    qreal endVal=qreal(e.endValue());

    curve.setType(e.easingCurve());
    //qreal valore=qreal(m_stepCurrentTime*TIMER_ANIMATION);
    qreal valore=qreal(m_stepCurrentTime);
    //qreal valore=qreal(m_stepCurrentTime*10);
    valore=valore/(qreal(duration));
    //valore=valore/10;
    //currentValue=curve.valueForProgress(valore);
    currentValue=endVal+(1.0-curve.valueForProgress(valore))*(startVal-endVal);    


    item=m_PixmapList[m_currentSlideIndex];

    if(e.effectType()=="pos")
        item->setProperty(e.effectType().toLatin1(),QVariant(QPointF(currentValue,0)));
    else
        item->setProperty(e.effectType().toLatin1(),QVariant(currentValue));


    //if(m_stepCurrentTime*TIMER_ANIMATION < e.duration()/**10*/)
    if(m_stepCurrentTime < duration)
    //if(m_stepCurrentTime*10 < e.duration()/**10*/)
        return RunningAnimation;
    else
        return EndAnimation;

}
static PyObject *meth_QEasingCurve_setPeriod(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        qreal a0;
        QEasingCurve *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "Bd", &sipSelf, sipType_QEasingCurve, &sipCpp, &a0))
        {
            sipCpp->setPeriod(a0);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QEasingCurve, sipName_setPeriod, doc_QEasingCurve_setPeriod);

    return NULL;
}
Beispiel #3
0
void Window::periodChanged(double value)
{
    QEasingCurve curve = m_anim->easingCurve();
    curve.setPeriod(value);
    m_anim->setEasingCurve(curve);
}
bool MStyleSheetAttribute::writeAttribute(MUniqueStringCache::Index filename,
        MStyle *style,
        const QMetaProperty &property,
        M::Orientation orientation) const
{
    // first check if the attribute is cached orientation independent, if not found
    // check for the given orientation
    QVariant cachedVariant = variantCache[M::Landscape + 1][value][property.userType()];
    if (cachedVariant.isValid()) {
        return property.write(style, cachedVariant);
    } else {
        cachedVariant = variantCache[orientation][value][property.userType()];
        if (cachedVariant.isValid()) {
            style->setOrientationDependent(true);
            return property.write(style, cachedVariant);
        }
    }

    bool conversionOK = false;
    // most types are the same in landscape and portrait
    CacheOrientationFlags cacheOrientation = CacheOrientationFlags(PortraitFlag | LandscapeFlag);

    QLatin1String vs = MStyleSheetParser::stringCacheWithoutReverseLookup()->indexToString(value);
    QByteArray valueString = QByteArray::fromRawData(vs.latin1(), strlen(vs.latin1()));

    const int attributeType = property.userType();
    if (attributeType == QMetaType::Bool) {
        bool result = booleanFromString(valueString, &conversionOK);
        if (conversionOK) {
            return fillProperty(property, style, cacheOrientation, result);
        }
    } else if (attributeType == QMetaType::Int) {
        int integer = attributeToInt(valueString, &conversionOK);
        if (conversionOK) {
            return fillProperty(property, style, cacheOrientation, integer);
        }
    } else if (attributeType == QMetaType::QColor) {
        if(valueString == "none")
            return fillProperty(property, style, cacheOrientation, QColor());

        QColor color = colorFromString(valueString, &conversionOK);
        if (conversionOK) {
            return fillProperty(property, style, cacheOrientation, color);
        }
    } else if (attributeType == QMetaType::QReal) {
        qreal real = attributeToFloat(valueString, &conversionOK);
        if (conversionOK) {
            return fillProperty(property, style, cacheOrientation, real);
        }
    } else if (attributeType == qMetaTypeId<const QPixmap*>()) {
        if(valueString == "none")
            return fillProperty(property, style, cacheOrientation, qVariantFromValue((const QPixmap *) NULL));

        //"image: image_id;"
        //"image: image_id 64px 64px;"
        //"image: "image id";"
        //"image: "image id" 64px 64px;"

        QList<QByteArray> list;
        if (valueString.startsWith('\"')) {
            //parse name inside quotes
            int idx = valueString.indexOf('\"', 1);
            if (idx != -1) {
                //get quoted image_id
                QByteArray imageid = valueString.mid(1, idx - 1);

                //split rest of the parameters
                QByteArray values = valueString.mid(idx + 1).trimmed();
                list = values.split(' ');
                list.removeAll("");

                //insert image_id as first parameter
                list.insert(0, imageid);
            }
        } else {
            //no quotes, just split the parameters
            list = valueString.split(' ');
            list.removeAll("");
        }

        //only image_id
        if (list.size() == 1) {
            const QPixmap *pixmap = MTheme::pixmap(list.at(0));
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(pixmap), false);
        }
        //image_id + width + height
        else if (list.size() == 3) {
            int width = attributeToInt(list.at(1), &conversionOK, WidthAttribute, orientation, &cacheOrientation);
            int height = attributeToInt(list.at(2), &conversionOK, HeightAttribute, orientation, &cacheOrientation);
            const QPixmap *pixmap = MTheme::pixmap(list.at(0), QSize(width, height));
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(pixmap), false);
        }
        //no parameters
        else if (list.size() == 0) {
            //init null pixmap which is ok if someone does not want to use it
            return fillProperty(property, style, cacheOrientation, qVariantFromValue((const QPixmap *) NULL));
        }
    } else if (attributeType == qMetaTypeId<const MScalableImage*>() || attributeType == qMetaTypeId<MBackgroundTiles>()) {
        //"background: image_id left right top bottom;"
        //"background: image_id;"
        //"background: "image id" left right top bottom;"
        //"background: "image id";"

        QList<QByteArray> list;
        if (valueString.startsWith('\"')) {
            //parse name inside quotes
            int idx = valueString.indexOf('\"', 1);
            if (idx != -1) {
                //get quoted image_id
                QByteArray imageid = valueString.mid(1, idx - 1);

                //split rest of the parameters
                QByteArray values = valueString.mid(idx + 1).trimmed();
                list = values.split(' ');
                list.removeAll("");
                //insert image_id as first parameter
                list.insert(0, imageid);
            }
        } else {
            //no quotes, just split the parameters
            list = valueString.split(' ');
            list.removeAll("");
        }

        //no parameters
        if (valueString.isEmpty() || valueString == "none") {
            //init null image which is ok if someone does not want to use it
            if(attributeType == qMetaTypeId<const MScalableImage*>())
                return fillProperty(property, style, cacheOrientation, qVariantFromValue((const MScalableImage *) NULL));
            else
                return fillProperty(property, style, cacheOrientation, QVariant::fromValue(MBackgroundTiles()), false);
        }
        //only image_id
        else if (list.size() == 1) {
            if(attributeType == qMetaTypeId<const MScalableImage*>()) {
                const MScalableImage *image = MTheme::scalableImage(list.at(0), 0, 0, 0, 0);
                return fillProperty(property, style, cacheOrientation, qVariantFromValue(image), false);
            } else {
                return fillProperty(property, style, cacheOrientation, QVariant::fromValue(MBackgroundTiles(list.at(0), 0,0,0,0)), false);
            }
        }
        //image_id + border width paramaters
        else if (list.size() == 5) {
            //image_id and the border parameters
            if(attributeType == qMetaTypeId<const MScalableImage*>()) {
                const MScalableImage *image = MTheme::scalableImage(list.at(0),
                                                attributeToInt(list.at(1), &conversionOK),
                                                attributeToInt(list.at(2), &conversionOK),
                                                attributeToInt(list.at(3), &conversionOK),
                                                attributeToInt(list.at(4), &conversionOK));
                return fillProperty(property, style, cacheOrientation, qVariantFromValue(image), false);
            } else {
                return fillProperty(property, style, cacheOrientation, QVariant::fromValue(MBackgroundTiles(list.at(0),
                                                                attributeToInt(list.at(1), &conversionOK),
                                                                attributeToInt(list.at(2), &conversionOK),
                                                                attributeToInt(list.at(3), &conversionOK),
                                                                attributeToInt(list.at(4), &conversionOK))), false);
            }
        }
    } else if (attributeType == QMetaType::QSize || attributeType == QMetaType::QSizeF) {
        //size: 25px 25px;

        //just split into pieces and create QSize or QSizeF depending on the attributeType
        QList<QByteArray> list = valueString.split(' ');
        list.removeAll("");
        if (list.size() == 2) {
            if (attributeType == QMetaType::QSize) {
                int width = attributeToInt(list.at(0), &conversionOK, WidthAttribute, orientation, &cacheOrientation);
                int height = attributeToInt(list.at(1), &conversionOK, HeightAttribute, orientation, &cacheOrientation);
                return fillProperty(property, style, cacheOrientation, QSize(width, height));
            } else {
                qreal width = attributeToFloat(list.at(0), &conversionOK, WidthAttribute, orientation, &cacheOrientation);
                qreal height = attributeToFloat(list.at(1), &conversionOK, HeightAttribute, orientation, &cacheOrientation);
                return fillProperty(property, style, cacheOrientation, QSizeF(width, height));
            }
        }
    } else if (attributeType == QMetaType::QPoint || attributeType == QMetaType::QPointF) {
        //"point: 256px 123px;

        //just split into pieces and create QPoint or QPointF depending on the attributeType
        QList<QByteArray> list = valueString.split(' ');
        list.removeAll("");
        if (list.size() == 2) {
            if (attributeType == QMetaType::QPoint) {
                int x = attributeToInt(list.at(0), &conversionOK, WidthAttribute, orientation, &cacheOrientation);
                int y = attributeToInt(list.at(1), &conversionOK, HeightAttribute, orientation, &cacheOrientation);
                return fillProperty(property, style, cacheOrientation, QPoint(x, y));
            } else {
                qreal x = attributeToFloat(list.at(0), &conversionOK, WidthAttribute, orientation, &cacheOrientation);
                qreal y = attributeToFloat(list.at(1), &conversionOK, HeightAttribute, orientation, &cacheOrientation);
                return fillProperty(property, style, cacheOrientation, QPointF(x, y));
            }
        }
    } else if (attributeType == QMetaType::QFont) {
        QFont font = fontFromString(valueString, &conversionOK);
        if (conversionOK) {
            return fillProperty(property, style, cacheOrientation, font);
        }
    } else if (attributeType == QMetaType::QString) {
        if (valueString.length() >= 2) {
            if ((valueString.at(0) == 0x22) && (valueString.at(valueString.length()-1) == 0x22)) {
                return fillProperty(property, style, cacheOrientation, QString(valueString.mid(1, valueString.length() - 2)));
            }
        } else if (valueString.length() == 0) {
            return fillProperty(property, style, cacheOrientation, QString());
        }
    } else if (attributeType == QMetaType::QChar) {
        if (valueString.length() == 3) {
            if ((valueString.at(0) == '\'') && (valueString.at(2) == '\'')) {
                return fillProperty(property, style, cacheOrientation, static_cast<QChar>(valueString.at(1)));
            }
        }
    } else if (attributeType == qMetaTypeId<Qt::Alignment>()) {
        if (DataTypeConverter.ALIGNMENTS.contains(valueString)) {
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.ALIGNMENTS[valueString]));
        }
    } else if (attributeType == qMetaTypeId<Qt::Orientation>()) {
        if (DataTypeConverter.ORIENTATIONS.contains(valueString)) {
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.ORIENTATIONS[valueString]));
        }
    } else if (attributeType == qMetaTypeId<QTextCharFormat::UnderlineStyle>()) {
        if (DataTypeConverter.UNDERLINESTYLES.contains(valueString)) {
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.UNDERLINESTYLES[valueString]));
        }
    } else if (attributeType == qMetaTypeId<Qt::PenStyle>()) {
        if (DataTypeConverter.PENSTYLES.contains(valueString)) {
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.PENSTYLES[valueString]));
        }
    } else if (attributeType == qMetaTypeId<Qt::Axis>()) {
        if (DataTypeConverter.AXES.contains(valueString)) {
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.AXES[valueString]));
        }
    } else if (attributeType == qMetaTypeId<MFeedback>()) {
        MFeedback feedback(valueString);
        return fillProperty(property, style, cacheOrientation, qVariantFromValue(feedback));
    } else if (attributeType == QMetaType::QEasingCurve) {
        QEasingCurve curve;
        // curve type
        QList<QByteArray> list = valueString.split(',');
        if (list.size() > 0) {
            if (DataTypeConverter.EASINGCURVETYPES.contains(list.at(0))) {
                int type = DataTypeConverter.EASINGCURVETYPES[list.at(0)];
                if (type < FirstCustomType)
                    curve.setType(static_cast<QEasingCurve::Type>(type));
                else if (type == OvershotBezier)
                    curve = MOvershotBezierEasingCurve();
                // curve amplitude
                if (list.size() > 1) {
                    curve.setAmplitude((qreal) list.at(1).toDouble());
                    // curve overshoot
                    if (list.size() > 2) {
                        curve.setOvershoot((qreal) list.at(2).toDouble());
                        // curve period
                        if (list.size() > 3) {
                            curve.setPeriod((qreal) list.at(3).toDouble());
                        }
                    }
                }
                return fillProperty(property, style, cacheOrientation, qVariantFromValue(curve));
            }
        }
    } else if (attributeType == qMetaTypeId<QTextOption::WrapMode>()) {
        if (DataTypeConverter.WRAPMODES.contains(valueString)) {
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.WRAPMODES[valueString]));
        }
    }

    MStyleSheetParser::outputParseError(MStyleSheetParser::stringCacheWithReverseLookup()->indexToString(filename), "Not a valid attribute(" + QLatin1String(property.typeName()) + "): " + MStyleSheetParser::stringCacheWithoutReverseLookup()->indexToString(name) + " : " + valueString, MStyleSheetParser::getLineNum(MStyleSheetParser::stringCacheWithReverseLookup()->indexToString(filename), position));
    return false;
}