当前位置: 首页>>代码示例>>C++>>正文


C++ QPropertyAnimation::state方法代码示例

本文整理汇总了C++中QPropertyAnimation::state方法的典型用法代码示例。如果您正苦于以下问题:C++ QPropertyAnimation::state方法的具体用法?C++ QPropertyAnimation::state怎么用?C++ QPropertyAnimation::state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPropertyAnimation的用法示例。


在下文中一共展示了QPropertyAnimation::state方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeHintChanged

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 );
}
开发者ID:cancamilo,项目名称:amarok,代码行数:42,代码来源:Applet.cpp

示例2: reverseStart

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();
    }
}
开发者ID:ptrxyz,项目名称:twmn,代码行数:40,代码来源:widget.cpp

示例3: drawControl

void FancyTabProxyStyle::drawControl(
    ControlElement element, const QStyleOption* option,
    QPainter* p, const QWidget* widget) const
{

    const QStyleOptionTab* v_opt = qstyleoption_cast<const QStyleOptionTab*>(option);

    if (element != CE_TabBarTab || !v_opt) {
        QProxyStyle::drawControl(element, option, p, widget);
        return;
    }

    const QRect rect = v_opt->rect;
    const bool selected = v_opt->state & State_Selected;
    const bool vertical_tabs = v_opt->shape == QTabBar::RoundedWest;
    const QString text = v_opt->text;

    if (selected) {
        //background
        p->save();
        QLinearGradient grad(rect.topLeft(), rect.topRight());
        grad.setColorAt(0, QColor(255, 255, 255, 140));
        grad.setColorAt(1, QColor(255, 255, 255, 210));
        p->fillRect(rect.adjusted(0, 0, 0, -1), grad);
        p->restore();

        //shadows
        p->setPen(QColor(0, 0, 0, 110));
        p->drawLine(rect.topLeft() + QPoint(1, -1), rect.topRight() - QPoint(0, 1));
        p->drawLine(rect.bottomLeft(), rect.bottomRight());
        p->setPen(QColor(0, 0, 0, 40));
        p->drawLine(rect.topLeft(), rect.bottomLeft());

        //highlights
        p->setPen(QColor(255, 255, 255, 50));
        p->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0, 2));
        p->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0, 1));
        p->setPen(QColor(255, 255, 255, 40));
        p->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
        p->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
        p->drawLine(rect.bottomLeft() + QPoint(0, -1), rect.bottomRight() - QPoint(0, 1));
    }

    QTransform m;
    if (vertical_tabs) {
        m = QTransform::fromTranslate(rect.left(), rect.bottom());
        m.rotate(-90);
    }
    else {
        m = QTransform::fromTranslate(rect.left(), rect.top());
    }

    const QRect draw_rect(QPoint(0, 0), m.mapRect(rect).size());

    p->save();
    p->setTransform(m);

    QRect icon_rect(QPoint(8, 0), v_opt->iconSize);
    QRect text_rect(icon_rect.topRight() + QPoint(4, 0), draw_rect.size());
    text_rect.setRight(draw_rect.width());
    icon_rect.translate(0, (draw_rect.height() - icon_rect.height()) / 2);

    QFont boldFont(p->font());
    boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
    boldFont.setBold(true);
    p->setFont(boldFont);
    p->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
    int textFlags = Qt::AlignHCenter | Qt::AlignVCenter;
    p->drawText(text_rect, textFlags, text);
    p->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
    if (widget) {
        const QString fader_key = "tab_" + text + "_fader";
        const QString animation_key = "tab_" + text + "_animation";

        const QString tab_hover = widget->property("tab_hover").toString();
        int fader = widget->property(fader_key.toUtf8().constData()).toInt();
        QPropertyAnimation* animation = widget->property(animation_key.toUtf8().constData()).value<QPropertyAnimation*>();

        if (!animation) {
            QWidget* mut_widget = const_cast<QWidget*>(widget);
            fader = 0;
            mut_widget->setProperty(fader_key.toUtf8().constData(), fader);
            animation = new QPropertyAnimation(mut_widget, fader_key.toUtf8(), mut_widget);
            connect(animation, SIGNAL(valueChanged(QVariant)), mut_widget, SLOT(update()));
            mut_widget->setProperty(animation_key.toUtf8().constData(), QVariant::fromValue(animation));
        }

        if (text == tab_hover) {
            if (animation->state() != QAbstractAnimation::Running && fader != 40) {
                animation->stop();
                animation->setDuration(80);
                animation->setEndValue(40);
                animation->start();
            }
        }
        else {
            if (animation->state() != QAbstractAnimation::Running && fader != 0) {
                animation->stop();
                animation->setDuration(160);
                animation->setEndValue(0);
//.........这里部分代码省略.........
开发者ID:Martii,项目名称:qupzilla,代码行数:101,代码来源:fancytabwidget.cpp


注:本文中的QPropertyAnimation::state方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。