From: Thomas Hartmann Date: Wed, 21 Nov 2012 10:53:45 +0000 (+0100) Subject: Prevent easing example warnings. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=02c110e989c44dcc18c5f0498dbc01ead87e069f;p=profile%2Fivi%2Fqtbase.git Prevent easing example warnings. examples/widgets/animation/easing was spitting out a lot of "QEasingCurve: Invalid tcb curve" warnings. The reason was that in case of the TCP curve we do not provide defaults. The function createEasingCurve() now provides reasonable values for the custom curves to show what is possible and how to use them. Change-Id: I880d8d0f0ce2872ce2019f7d2e000f4c4ce136e2 Reviewed-by: Mitch Curtis Reviewed-by: Alessandro Portale --- diff --git a/examples/widgets/animation/easing/window.cpp b/examples/widgets/animation/easing/window.cpp index f5ff439..0a9df0f 100644 --- a/examples/widgets/animation/easing/window.cpp +++ b/examples/widgets/animation/easing/window.cpp @@ -75,6 +75,23 @@ Window::Window(QWidget *parent) startAnimation(); } +QEasingCurve createEasingCurve(QEasingCurve::Type curveType) +{ + QEasingCurve curve(curveType); + + if (curveType == QEasingCurve::BezierSpline) { + curve.addCubicBezierSegment(QPointF(0.4, 0.1), QPointF(0.6, 0.9), QPointF(1.0, 1.0)); + + } else if (curveType == QEasingCurve::TCBSpline) { + curve.addTCBSegment(QPointF(0.0, 0.0), 0, 0, 0); + curve.addTCBSegment(QPointF(0.3, 0.4), 0.2, 1, -0.2); + curve.addTCBSegment(QPointF(0.7, 0.6), -0.2, 1, 0.2); + curve.addTCBSegment(QPointF(1.0, 1.0), 0, 0, 0); + } + + return curve; +} + void Window::createCurveIcons() { QPixmap pix(m_iconSize); @@ -88,7 +105,7 @@ void Window::createCurveIcons() // Skip QEasingCurve::Custom for (int i = 0; i < QEasingCurve::NCurveTypes - 1; ++i) { painter.fillRect(QRect(QPoint(0, 0), m_iconSize), brush); - QEasingCurve curve((QEasingCurve::Type)i); + QEasingCurve curve = createEasingCurve((QEasingCurve::Type) i); painter.setPen(QColor(0, 0, 255, 64)); qreal xAxis = m_iconSize.height()/1.5; qreal yAxis = m_iconSize.width()/3; @@ -139,7 +156,7 @@ void Window::startAnimation() void Window::curveChanged(int row) { QEasingCurve::Type curveType = (QEasingCurve::Type)row; - m_anim->setEasingCurve(curveType); + m_anim->setEasingCurve(createEasingCurve(curveType)); m_anim->setCurrentTime(0); bool isElastic = curveType >= QEasingCurve::InElastic && curveType <= QEasingCurve::OutInElastic;