Example #1
0
void Widget::unbounce()
{
    QPropertyAnimation* anim = qobject_cast<QPropertyAnimation*>(m_animation.animationAt(1));
    if (!anim)
        return;
    disconnect(anim, SIGNAL(finished()), this, SLOT(unbounce()));
    connect(anim, SIGNAL(finished()), this, SLOT(doneBounce()));
    anim->setDirection(QAnimationGroup::Backward);
    anim->setEasingCurve(QEasingCurve::InBounce);
    anim->setDuration(m_settings.get("gui/bounce_duration").toInt() * 0.75f);
    anim->start();
}
Example #2
0
void
Context::Applet::collapse( bool on )
{
    qreal finalHeight = ( on ) ? m_heightCollapseOn : m_heightCollapseOff;
    const qreal maxHeight = containment()->size().height();
    if( (finalHeight > maxHeight) || (finalHeight < 0) )
        finalHeight = maxHeight;

    prepareGeometryChange();
    // warning: view() currently can return pointer to ToolbarView, not the ContextView
    ContextView *v = ContextView::self(); // may return null
    // Plasma::Applet::view() might return 0, if the widget is not yet constructed, etc.
    // \sa https://bugs.kde.org/show_bug.cgi?id=258741. If view is not available
    // yet, regardless of the animation setting the preferred size is set
    // straight away.
    if( !v || !AmarokConfig::animateAppletCollapse() )
    {
        setPreferredHeight( finalHeight );
        emit sizeHintChanged( Qt::PreferredSize );
        updateGeometry();
        return;
    }

    if( finalHeight == size().height() )
        return;

    // debug() << pluginName() << (on ? "collapsing to" : "uncollapsing to") << finalHeight;
    QPropertyAnimation *pan = m_animation.data();
    if( !pan )
        pan = new QPropertyAnimation( this, "preferredSize" );
    if( pan->state() == QAbstractAnimation::Running )
        pan->stop();
    pan->setDuration( 600 );
    pan->setEasingCurve( QEasingCurve::InQuad );
    pan->setStartValue( size() );
    pan->setEndValue( QSizeF(size().width(), finalHeight) );
    connect( pan, SIGNAL(finished()), SLOT(collapseAnimationFinished()) );
    m_animation = pan;
    pan->setDirection( QAbstractAnimation::Forward );

    v->addCollapseAnimation( pan );
}
Example #3
0
void Widget::reverseStart()
{
    //If last message, play hide animation.
    if (m_messageQueue.size() <= 1) {
        QPropertyAnimation* bounceAnim = qobject_cast<QPropertyAnimation*>(m_animation.animationAt(1));
        if(bounceAnim) {
            if(bounceAnim->state() == QAbstractAnimation::Running){
                return;
            }
        }

        if (!m_messageQueue.isEmpty()){
            if(m_animation.animationAt(1)){
                doneBounce();
            }
            m_messageQueue.pop_front();
        }

        unsigned int duration = m_settings.get("gui/out_animation_duration").toInt();

        QPropertyAnimation* anim = qobject_cast<QPropertyAnimation*>(m_animation.animationAt(0));
        if (!anim) {
            return;
        }

        disconnect(anim, SIGNAL(valueChanged(QVariant)), this, m_activePositionSlot.c_str());

        anim->setDirection(QAnimationGroup::Backward);
        anim->setEasingCurve(QEasingCurve::Type(m_settings.get("gui/out_animation").toInt()));
        anim->setDuration(duration);
        anim->setCurrentTime(duration);

        connect(anim, SIGNAL(valueChanged(QVariant)), this, m_activePositionSlot.c_str());

        anim->start();
        //m_shortcutGrabber.disableShortcuts();
    } else {
        autoNext();
    }
}