Exemplo n.º 1
0
CubeView::CubeView(QWidget *parent)
    : QGLView(parent)
    , fbo(0)
    , tangle(0.0f)
    , cangle(0.0f)
    , oangle(0.0f)
    , needsUpdate(true)
{
    innerCamera = new QGLCamera(this);

    QPropertyAnimation *animation;

    animation = new QPropertyAnimation(this, "teapotAngle", this);
    animation->setStartValue(0.0f);
    animation->setEndValue(360.0f);
    animation->setDuration(1000);
    animation->setLoopCount(-1);
    animation->start();

    animation = new QPropertyAnimation(this, "cubeAngle", this);
    animation->setStartValue(0.0f);
    animation->setEndValue(360.0f);
    animation->setDuration(5000);
    animation->setLoopCount(-1);
    animation->start();

    animation = new QPropertyAnimation(this, "orbitAngle", this);
    animation->setStartValue(0.0f);
    animation->setEndValue(360.0f);
    animation->setDuration(5000);
    animation->setLoopCount(-1);
    animation->start();
}
Exemplo n.º 2
0
QAbstractAnimation *QSanRoomSkin::createHuaShenAnimation(QPixmap &huashenAvatar, QPoint topLeft, QGraphicsItem *parent,
    QGraphicsItem *&huashenAvatarCreated) const
{
    QLabel *avatar = new QLabel;
    avatar->setStyleSheet("QLabel { background-color: transparent; }");
    avatar->setPixmap(huashenAvatar);
    QGraphicsProxyWidget *widget = new QGraphicsProxyWidget(parent);
    widget->setWidget(avatar);
    widget->setPos(topLeft);

    QPropertyAnimation *animation = new QPropertyAnimation(widget, "opacity");
    animation->setLoopCount(2000);
    JsonArray huashenConfig = _m_animationConfig["huashen"].value<JsonArray>();
    int duration;
    if (tryParse(huashenConfig[0], duration) && huashenConfig[1].canConvert<JsonArray>()) {
        animation->setDuration(duration);
        JsonArray keyValues = huashenConfig[1].value<JsonArray>();
        for (int i = 0; i < keyValues.size(); i++) {
            QVariant keyValue = keyValues[i];
            if (!keyValue.canConvert<JsonArray>() || keyValue.value<JsonArray>().length() != 2) continue;
            double step;
            double val;
            JsonArray keyArr = keyValue.value<JsonArray>();
            if (!tryParse(keyArr[0], step) || !tryParse(keyArr[1], val)) continue;
            animation->setKeyValueAt(step, val);
        }
    }
    huashenAvatarCreated = widget;
    return animation;
}
Exemplo n.º 3
0
void TabBar::setTabHighlighted(int index)
{
    const QByteArray propertyName = highlightPropertyName(index);
    const QColor highlightColor = KColorScheme(QPalette::Active, KColorScheme::Window).foreground(KColorScheme::PositiveText).color();

    if (tabTextColor(index) != highlightColor)
    {
        if (ReKonfig::animatedTabHighlighting())
        {
            m_tabHighlightEffect->setEnabled(true);
            m_tabHighlightEffect->setProperty(propertyName, qreal(0.9));
            QPropertyAnimation *anim = new QPropertyAnimation(m_tabHighlightEffect, propertyName);
            m_highlightAnimation.insert(propertyName, anim);

            //setup the animation
            anim->setStartValue(0.9);
            anim->setEndValue(0.0);
            anim->setDuration(500);
            anim->setLoopCount(2);
            anim->start(QAbstractAnimation::DeleteWhenStopped);

            m_animationMapper->setMapping(anim, index);
            connect(anim, SIGNAL(finished()), m_animationMapper, SLOT(map()));
        }

        setTabTextColor(index, highlightColor);
    }
}
Exemplo n.º 4
0
void MainWindow::addRotateTransform(MySimpleTextItem *item)
{
    QPropertyAnimation* anRotation = new QPropertyAnimation(item, "rotation");
    anRotation->setStartValue(0.0);
    anRotation->setEndValue(360.0);
    int ms = rand()%4000 + 1000;
    anRotation->setDuration(ms);
    anRotation->setEasingCurve(QEasingCurve::InBounce);
    anRotation->setLoopCount(5);
    _group.addAnimation(anRotation);
}
Exemplo n.º 5
0
void MainWindow::addScaleTransform(MySimpleTextItem *item)
{
    QPropertyAnimation* anScale = new QPropertyAnimation(item, "scale");
    anScale->setStartValue(7.0);
    int r = rand()%16 + 7;
    anScale->setEndValue(r);
    int ms = rand()%4000 + 1000;
    anScale->setDuration(ms);
    anScale->setEasingCurve(QEasingCurve::CosineCurve);
    anScale->setLoopCount(5);
    _group.addAnimation(anScale);
}
QPropertyAnimation * BezierManeuverSegment::animation()
{
    //std::cout << "Bezier creating animation ..."
    //          << std::endl;
    QPropertyAnimation * animation =
            new BezierManeuverAnimation(start, key1, key2, end);
    Q_CHECK_PTR(animation);
    animation->setEasingCurve(QEasingCurve::Linear);
    animation->setLoopCount(1);
    animation->setDuration(5000);
    //std::cout << "Bezier returning animation ..."
    //          << std::endl;
    return animation;
}
Exemplo n.º 7
0
void MainWindow::addTranslateTransform(MySimpleTextItem *item)
{
    int w = (int)_scene.width();
    int h = (int)_scene.height();
    QPropertyAnimation* anX = new QPropertyAnimation(item, "x");
    anX->setStartValue(item->x());
    qreal endW = rand()%w;
    anX->setEndValue(endW);
    int ms = rand()%4000 + 1000;
    anX->setDuration(ms);
    anX->setEasingCurve(QEasingCurve::InBack);
    anX->setLoopCount(5);
    _group.addAnimation(anX);

    QPropertyAnimation* anY = new QPropertyAnimation(item, "rotation");
    anY->setStartValue(item->y());
    qreal endH = rand()%h;
    anY->setEndValue(endH);
    ms = rand()%4000 + 1000;
    anY->setDuration(ms);
    anY->setEasingCurve(QEasingCurve::BezierSpline);
    anY->setLoopCount(5);
    _group.addAnimation(anY);
}
Exemplo n.º 8
0
void View3D::startModelRotationRecursive(QObject* pObject)
{
    //TODO this won't work with QEntities
    if(Renderable3DEntity* pItem = dynamic_cast<Renderable3DEntity*>(pObject)) {
        QPropertyAnimation *anim = new QPropertyAnimation(pItem, QByteArrayLiteral("rotZ"));
        anim->setDuration(30000);
        anim->setStartValue(QVariant::fromValue(pItem->rotZ()));
        anim->setEndValue(QVariant::fromValue(pItem->rotZ() + 360.0f));
        anim->setLoopCount(-1);
        anim->start();
        m_lPropertyAnimations << anim;
    }

    for(int i = 0; i < pObject->children().size(); ++i) {
        startModelRotationRecursive(pObject->children().at(i));
    }
}
Exemplo n.º 9
0
void DeviceView::onBlinkClick(){
    _blinking = true;
    _blinkBtn->setDisabled(true);
    _dev->blink();

    _colorizeEffect = new QGraphicsColorizeEffect();
    _colorizeEffect->setColor(Qt::yellow);
    _colorisation = 0;
    _colorizeEffect->setStrength(_colorisation);
    setGraphicsEffect(_colorizeEffect);

    QPropertyAnimation *animation = new QPropertyAnimation(this, "colorisation");
    animation->setDuration(200);
    animation->setLoopCount(10);
    animation->setStartValue(0.0);
    animation->setEndValue(0.5);
    animation->setEasingCurve(QEasingCurve::CosineCurve);
    animation->start();

    QTimer::singleShot(2100, this, SLOT(onBlinkingFinished()));
}
Exemplo n.º 10
0
LrcView::LrcView(QWidget *parent) :
    QLabel(parent)
{
//////////////    setGeometry(276, 113, 731, 476);

    //创建 动画
    lab_left_top = new QLabel(this);
    lab_left_bottom = new QLabel(this);

    lab_left_top ->setGeometry(20, 40, 100, 100);
    lab_left_bottom  ->setGeometry(20, 100, 240, 320);

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateGif()));
    timer ->start(100);

    //创建 后续歌词
    textNext = new QLabel(this);
    textNext ->setGeometry(260, 260, 450, 200);
    textNext ->setAlignment(Qt::AlignTop);
    textNext ->setStyleSheet(
                "QLabel{"
//                    "color: rgba(40, 16, 144, 255);"
//                    "color: rgba(92, 133, 20, 255);"
//                    "color: rgba(95, 110, 13, 255);"       //黄绿色
                    "color: rgba(38, 79, 16, 255);"        //墨绿色
//                    "color: rgba(13, 72, 110, 255);"        //蓝绿色
                    "font-family: 楷体;"
                    "font-size: 20px;"
                "}"
                );

    //创建 当前播放歌词
    currentLrc = new CurrentLrc(this);
    currentLrc ->setGeometry(260, 232, 450, 26);

    //创建 播放过的歌词
    textPrevious = new QLabel(this);
    textPrevious ->setGeometry(260, 6, 450, 225);
    textPrevious ->setAlignment(Qt::AlignBottom);
    textPrevious ->setStyleSheet(
                "QLabel{"
                    "color: rgba(38, 79, 16, 255);"
                    "font-family: 楷体;"
                    "font-size: 20px;"
                "}"
                );
    this->setMouseTracking(true);
    textNext->setMouseTracking(true);
    currentLrc->setMouseTracking(true);
    textPrevious->setMouseTracking(true);
    lab_left_top->setMouseTracking(true);
    lab_left_bottom->setMouseTracking(true);


/*
    QAxWidget *flash = new QAxWidget(this);
    flash->setControl(QString::fromUtf8("{d27cdb6e-ae6d-11cf-96b8-444553540000}"));
    QString name=qApp->applicationDirPath();
    flash->dynamicCall("LoadMovie(long,string)",0,qApp->applicationDirPath()+"/top.swf");
    flash->show();
    QGridLayout *layout = new QGridLayout;
    layout->addWidget(flash);
    layout->setMargin(0);
    setLayout(layout);
*/
/*
    QPropertyAnimation *animation = new QPropertyAnimation(lab_left_bottom, "pos");
    animation->setKeyValueAt(0.0, QPoint(lab_left_bottom->x(), lab_left_bottom->y()));
    animation->setKeyValueAt(0.5, QPoint(this->x()-lab_left_bottom->width(), lab_left_bottom->y()));
    animation->setKeyValueAt(1.0, QPoint(lab_left_bottom->x(), lab_left_bottom->y()));
    animation->setDuration(20000);
    animation->setLoopCount(-1);
    animation->start();
*/
    QPropertyAnimation *animation = new QPropertyAnimation(lab_left_bottom, "geometry");
    animation->setKeyValueAt(0.0, QRectF(lab_left_bottom->pos(), lab_left_bottom->size()));
    animation->setKeyValueAt(0.5, QRectF(lab_left_bottom->x()+50, lab_left_bottom->y()+50, lab_left_bottom->width()-100, lab_left_bottom->height()-133));
    animation->setKeyValueAt(1.0, QRectF(lab_left_bottom->pos(), lab_left_bottom->size()));
    animation->setDuration(20000);
    animation->setLoopCount(-1);
    animation->start();
}
Exemplo n.º 11
0
int main(int argc, char* argv[])
{
    QGuiApplication app(argc, argv);
    Qt3D::QWindow view;
    Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
    view.registerAspect(input);

    // Root entity
    Qt3D::QEntity *rootEntity = new Qt3D::QEntity();

    // Camera
    Qt3D::QCamera *cameraEntity = view.defaultCamera();

    cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
    cameraEntity->setPosition(QVector3D(0, 0, -40.0f));
    cameraEntity->setUpVector(QVector3D(0, 1, 0));
    cameraEntity->setViewCenter(QVector3D(0, 0, 0));
    input->setCamera(cameraEntity);

    // Material
    Qt3D::QMaterial *material = new Qt3D::QPhongMaterial(rootEntity);

    // Torus
    Qt3D::QEntity *torusEntity = new Qt3D::QEntity(rootEntity);
    Qt3D::QTorusMesh *torusMesh = new Qt3D::QTorusMesh;
    torusMesh->setRadius(5);
    torusMesh->setMinorRadius(1);
    torusMesh->setRings(100);
    torusMesh->setSlices(20);

    Qt3D::QTransform *torusTransform = new Qt3D::QTransform;
    Qt3D::QScaleTransform *torusScaleTransform = new Qt3D::QScaleTransform;
    torusScaleTransform->setScale3D(QVector3D(1.5, 1, 0.5));

    Qt3D::QRotateTransform *torusRotateTransform = new Qt3D::QRotateTransform;
    torusRotateTransform->setAxis(QVector3D(1, 0, 0));
    torusRotateTransform->setAngleDeg(45);

    torusTransform->addTransform(torusScaleTransform);
    torusTransform->addTransform(torusRotateTransform);


    torusEntity->addComponent(torusMesh);
    torusEntity->addComponent(torusTransform);
    torusEntity->addComponent(material);

    // Sphere
    Qt3D::QEntity *sphereEntity = new Qt3D::QEntity(rootEntity);
    Qt3D::QSphereMesh *sphereMesh = new Qt3D::QSphereMesh;
    sphereMesh->setRadius(3);

    Qt3D::QTransform *sphereTransform = new Qt3D::QTransform;
    Qt3D::QTranslateTransform *sphereTranslateTransform = new Qt3D::QTranslateTransform;
    sphereTranslateTransform->setTranslation(QVector3D(20, 0, 0));

    Qt3D::QRotateTransform *sphereRotateTransform = new Qt3D::QRotateTransform;
    QPropertyAnimation *sphereRotateTransformAnimation = new QPropertyAnimation(sphereRotateTransform);
    sphereRotateTransformAnimation->setTargetObject(sphereRotateTransform);
    sphereRotateTransformAnimation->setPropertyName("angle");
    sphereRotateTransformAnimation->setStartValue(QVariant::fromValue(0));
    sphereRotateTransformAnimation->setEndValue(QVariant::fromValue(360));
    sphereRotateTransformAnimation->setDuration(10000);
    sphereRotateTransformAnimation->setLoopCount(-1);
    sphereRotateTransformAnimation->start();

    sphereRotateTransform->setAxis(QVector3D(0, 1, 0));
    sphereRotateTransform->setAngleDeg(0);

    sphereTransform->addTransform(sphereTranslateTransform);
    sphereTransform->addTransform(sphereRotateTransform);

    sphereEntity->addComponent(sphereMesh);
    sphereEntity->addComponent(sphereTransform);
    sphereEntity->addComponent(material);

    view.setRootEntity(rootEntity);
    view.show();

    return app.exec();
}