void UIAnimation::prepare() { /* Prepare animation-machine: */ m_pAnimationMachine = new QStateMachine(this); /* Create 'start' state: */ m_pStateStart = new QState(m_pAnimationMachine); connect(m_pStateStart, SIGNAL(propertiesAssigned()), this, SIGNAL(sigStateEnteredStart())); /* Create 'final' state: */ m_pStateFinal = new QState(m_pAnimationMachine); connect(m_pStateFinal, SIGNAL(propertiesAssigned()), this, SIGNAL(sigStateEnteredFinal())); /* Prepare 'forward' animation: */ m_pForwardAnimation = new QPropertyAnimation(parent(), m_pszPropertyName, m_pAnimationMachine); m_pForwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); m_pForwardAnimation->setDuration(m_iAnimationDuration); /* Prepare 'reverse' animation: */ m_pReverseAnimation = new QPropertyAnimation(parent(), m_pszPropertyName, m_pAnimationMachine); m_pReverseAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); m_pReverseAnimation->setDuration(m_iAnimationDuration); /* Prepare state-transitions: */ QSignalTransition *pStartToFinal = m_pStateStart->addTransition(parent(), m_pszSignalForward, m_pStateFinal); pStartToFinal->addAnimation(m_pForwardAnimation); QSignalTransition *pFinalToStart = m_pStateFinal->addTransition(parent(), m_pszSignalReverse, m_pStateStart); pFinalToStart->addAnimation(m_pReverseAnimation); /* Fetch animation-borders: */ update(); /* Choose initial state: */ m_pAnimationMachine->setInitialState(!m_fReverse ? m_pStateStart : m_pStateFinal); /* Start animation-machine: */ m_pAnimationMachine->start(); }
void UIPopupPane::prepareAnimation() { /* Install 'show' animation for 'minimumSizeHint' property: */ connect(this, SIGNAL(sigToShow()), this, SIGNAL(sigShow()), Qt::QueuedConnection); m_pShowAnimation = UIAnimation::installPropertyAnimation(this, "minimumSizeHint", "hiddenSizeHint", "shownSizeHint", SIGNAL(sigShow()), SIGNAL(sigHide())); connect(m_pShowAnimation, SIGNAL(sigStateEnteredFinal()), this, SLOT(sltMarkAsShown())); /* Install 'hover' animation for 'opacity' property: */ UIAnimation::installPropertyAnimation(this, "opacity", "defaultOpacity", "hoveredOpacity", SIGNAL(sigHoverEnter()), SIGNAL(sigHoverLeave()), m_fHovered); }
void UISlidingToolBar::prepareAnimation() { /* Prepare mdi-sub-window geometry animation itself: */ connect(this, SIGNAL(sigShown()), this, SIGNAL(sigExpand()), Qt::QueuedConnection); m_pAnimation = UIAnimation::installPropertyAnimation(this, "widgetGeometry", "startWidgetGeometry", "finalWidgetGeometry", SIGNAL(sigExpand()), SIGNAL(sigCollapse())); connect(m_pAnimation, SIGNAL(sigStateEnteredStart()), this, SLOT(sltMarkAsCollapsed())); connect(m_pAnimation, SIGNAL(sigStateEnteredFinal()), this, SLOT(sltMarkAsExpanded())); /* Update geometry animation: */ updateAnimation(); }