// Test getting and setting easing properties via the metaobject system. void tst_QEasingCurve::properties() { tst_QEasingProperties obj; QEasingCurve inOutBack(QEasingCurve::InOutBack); qreal overshoot = 1.5; inOutBack.setOvershoot(overshoot); qreal amplitude = inOutBack.amplitude(); qreal period = inOutBack.period(); obj.setEasing(inOutBack); QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing")); QCOMPARE(easing.type(), QEasingCurve::InOutBack); QCOMPARE(easing.overshoot(), overshoot); QCOMPARE(easing.amplitude(), amplitude); QCOMPARE(easing.period(), period); QEasingCurve linear(QEasingCurve::Linear); overshoot = linear.overshoot(); amplitude = linear.amplitude(); period = linear.period(); obj.setProperty("easing", qVariantFromValue(QEasingCurve(QEasingCurve::Linear))); easing = qVariantValue<QEasingCurve>(obj.property("easing")); QCOMPARE(easing.type(), QEasingCurve::Linear); QCOMPARE(easing.overshoot(), overshoot); QCOMPARE(easing.amplitude(), amplitude); QCOMPARE(easing.period(), period); }
Window::Window(QWidget *parent) : QWidget(parent), m_iconSize(64, 64) { m_ui.setupUi(this); QButtonGroup *buttonGroup = findChild<QButtonGroup *>(); // ### workaround for uic in 4.4 m_ui.easingCurvePicker->setIconSize(m_iconSize); m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50); buttonGroup->setId(m_ui.lineRadio, 0); buttonGroup->setId(m_ui.circleRadio, 1); QEasingCurve dummy; m_ui.periodSpinBox->setValue(dummy.period()); m_ui.amplitudeSpinBox->setValue(dummy.amplitude()); m_ui.overshootSpinBox->setValue(dummy.overshoot()); connect(m_ui.easingCurvePicker, SIGNAL(currentRowChanged(int)), this, SLOT(curveChanged(int))); connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(pathChanged(int))); connect(m_ui.periodSpinBox, SIGNAL(valueChanged(double)), this, SLOT(periodChanged(double))); connect(m_ui.amplitudeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(amplitudeChanged(double))); connect(m_ui.overshootSpinBox, SIGNAL(valueChanged(double)), this, SLOT(overshootChanged(double))); createCurveIcons(); QPixmap pix(QLatin1String(":/images/qt-logo.png")); m_item = new PixmapItem(pix); m_scene.addItem(m_item); m_ui.graphicsView->setScene(&m_scene); m_anim = new Animation(m_item, "pos"); m_anim->setEasingCurve(QEasingCurve::OutBounce); m_ui.easingCurvePicker->setCurrentRow(int(QEasingCurve::OutBounce)); startAnimation(); }
/*! Compare this easing curve with \a other and returns true if they are equal. It will also compare the properties of a curve. */ bool QEasingCurve::operator==(const QEasingCurve &other) const { bool res = d_ptr->func == other.d_ptr->func && d_ptr->type == other.d_ptr->type; if (res) { if (d_ptr->config && other.d_ptr->config) { // catch the config content res = d_ptr->config->operator==(*(other.d_ptr->config)); } else if (d_ptr->config || other.d_ptr->config) { // one one has a config object, which could contain default values res = qFuzzyCompare(amplitude(), other.amplitude()) && qFuzzyCompare(period(), other.period()) && qFuzzyCompare(overshoot(), other.overshoot()); } } return res; }